Appearance
User - Expenses
Base URL:
https://your-domain.com
Admin endpoints for managing expenses. All endpoints require admin/staff authentication.
Fetch All Expenses
Retrieve all expense records with optional filters.
| Property | Value |
|---|---|
| Endpoint | Fetch All Expenses |
| Method | GET |
| URL | /api/v1/expenses |
| Authentication | Bearer Token |
Request Headers:
| Header | Value | Required |
|---|---|---|
Accept | application/json | Yes |
Authorization | Bearer your-auth-token | Yes |
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
from_date | date | No | Start date filter |
to_date | date | No | End date filter |
category_id | integer | No | Filter by category |
Success Response (200 OK):
json
{
"success": true,
"data": [
{
"id": 1,
"category_id": 1,
"category_name": "Office Supplies",
"amount": 5000,
"description": "Printer paper and ink",
"created_by": "Admin",
"created_at": "2024-01-15 10:30:00"
}
],
"total": 25000
}Code Examples:
bash
curl -X GET "https://your-domain.com/api/v1/expenses?from_date=2025-01-01" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$response = $client->request('GET', '/api/v1/expenses', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'query' => [
'from_date' => '2025-01-01',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const params = new URLSearchParams({
from_date: '2025-01-01',
});
const response = await fetch(`${BASE_URL}/api/v1/expenses?${params}`, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
response = requests.get(
f"{BASE_URL}/api/v1/expenses",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
params={
"from_date": "2025-01-01",
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
endpoint := baseURL + "/api/v1/expenses"
q := url.Values{}
q.Set("from_date", "2025-01-01")
endpoint += "?" + q.Encode()
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let response = client
.get(format!("{BASE_URL}/api/v1/expenses"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.query(&[
("from_date", "2025-01-01"),
])
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Fetch Expense Categories
Retrieve all expense categories.
| Property | Value |
|---|---|
| Endpoint | Fetch Expense Categories |
| Method | GET |
| URL | /api/v1/expenses/categories |
| Authentication | Bearer Token |
Success Response (200 OK):
json
{
"success": true,
"data": [
{"id": 1, "name": "Office Supplies"},
{"id": 2, "name": "Utilities"},
{"id": 3, "name": "Equipment"}
]
}Code Examples:
bash
curl -X GET "https://your-domain.com/api/v1/expenses/categories" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$response = $client->request('GET', '/api/v1/expenses/categories', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const response = await fetch(`${BASE_URL}/api/v1/expenses/categories`, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
response = requests.get(
f"{BASE_URL}/api/v1/expenses/categories",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
endpoint := baseURL + "/api/v1/expenses/categories"
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let response = client
.get(format!("{BASE_URL}/api/v1/expenses/categories"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Fetch Expense
Retrieve details of a specific expense.
| Property | Value |
|---|---|
| Endpoint | Fetch Expense |
| Method | GET |
| URL | /api/v1/expenses/{id} |
| Authentication | Bearer Token |
Success Response (200 OK):
json
{
"success": true,
"data": {
"id": 1,
"category_id": 1,
"category_name": "Office Supplies",
"amount": 5000,
"description": "Printer paper and ink",
"receipt_url": null,
"created_by": "Admin",
"created_at": "2024-01-15 10:30:00"
}
}Code Examples:
bash
curl -X GET "https://your-domain.com/api/v1/expenses/1" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$expenseId = 1;
$response = $client->request('GET', "/api/v1/expenses/{$expenseId}", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const expenseId = 1;
const response = await fetch(`${BASE_URL}/api/v1/expenses/${expenseId}`, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
expense_id = 1
response = requests.get(
f"{BASE_URL}/api/v1/expenses/{expense_id}",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
expenseId := 1
endpoint := baseURL + "/api/v1/expenses/" + strconv.Itoa(expenseId)
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let expense_id = 1;
let response = client
.get(format!("{BASE_URL}/api/v1/expenses/{expense_id}"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Create Expense
Record a new expense.
| Property | Value |
|---|---|
| Endpoint | Create Expense |
| Method | POST |
| URL | /api/v1/expenses |
| Authentication | Bearer Token |
Request Body:
json
{
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"category_id": 1,
"amount": 5000,
"description": "Office supplies"
}| Parameter | Type | Required | Description |
|---|---|---|---|
category_id | integer | Yes | Expense category ID |
amount | decimal | Yes | Expense amount |
description | string | No | Expense description |
Success Response (201 Created):
json
{
"success": true,
"message": "Expense recorded successfully",
"data": {
"id": 1
}
}Code Examples:
bash
curl -X POST "https://your-domain.com/api/v1/expenses" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-auth-token" \
-d '{
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"category_id": 1,
"amount": 5000,
"description": "Office supplies"
}'php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$response = $client->request('POST', '/api/v1/expenses', [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'json' => [
'isp_id' => 1,
'branch_id' => 1,
'user_id' => 1,
'category_id' => 1,
'amount' => 5000,
'description' => 'Office supplies',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const response = await fetch(`${BASE_URL}/api/v1/expenses`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
body: JSON.stringify({
isp_id: 1,
branch_id: 1,
user_id: 1,
category_id: 1,
amount: 5000,
description: 'Office supplies',
}),
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
response = requests.post(
f"{BASE_URL}/api/v1/expenses",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
json={
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"category_id": 1,
"amount": 5000,
"description": "Office supplies",
},
)
data = response.json()
print(data)go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
endpoint := baseURL + "/api/v1/expenses"
payload, _ := json.Marshal(map[string]any{
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"category_id": 1,
"amount": 5000,
"description": "Office supplies",
})
req, _ := http.NewRequest("POST", endpoint, bytes.NewBuffer(payload))
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
use serde_json::json;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let response = client
.post(format!("{BASE_URL}/api/v1/expenses"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.json(&json!({
"isp_id": 1,
"branch_id": 1,
"user_id": 1,
"category_id": 1,
"amount": 5000,
"description": "Office supplies"
}))
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Update Expense
Update an existing expense record.
| Property | Value |
|---|---|
| Endpoint | Update Expense |
| Method | PUT |
| URL | /api/v1/expenses/{id} |
| Authentication | Bearer Token |
Request Body:
json
{
"amount": 6000,
"description": "Updated description"
}Success Response (200 OK):
json
{
"success": true,
"message": "Expense updated successfully"
}Code Examples:
bash
curl -X PUT "https://your-domain.com/api/v1/expenses/1" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-auth-token" \
-d '{
"amount": 6000,
"description": "Updated description"
}'php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$expenseId = 1;
$response = $client->request('PUT', "/api/v1/expenses/{$expenseId}", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
'json' => [
'amount' => 6000,
'description' => 'Updated description',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const expenseId = 1;
const response = await fetch(`${BASE_URL}/api/v1/expenses/${expenseId}`, {
method: 'PUT',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
body: JSON.stringify({
amount: 6000,
description: 'Updated description',
}),
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
expense_id = 1
response = requests.put(
f"{BASE_URL}/api/v1/expenses/{expense_id}",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
json={
"amount": 6000,
"description": "Updated description",
},
)
data = response.json()
print(data)go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
expenseId := 1
endpoint := baseURL + "/api/v1/expenses/" + strconv.Itoa(expenseId)
payload, _ := json.Marshal(map[string]any{
"amount": 6000,
"description": "Updated description",
})
req, _ := http.NewRequest("PUT", endpoint, bytes.NewBuffer(payload))
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
use serde_json::json;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let expense_id = 1;
let response = client
.put(format!("{BASE_URL}/api/v1/expenses/{expense_id}"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.json(&json!({
"amount": 6000,
"description": "Updated description"
}))
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}Delete Expense
Delete an expense record.
| Property | Value |
|---|---|
| Endpoint | Delete Expense |
| Method | DELETE |
| URL | /api/v1/expenses/{id} |
| Authentication | Bearer Token |
Success Response (200 OK):
json
{
"success": true,
"message": "Expense deleted successfully"
}Code Examples:
bash
curl -X DELETE "https://your-domain.com/api/v1/expenses/1" \
-H "Accept: application/json" \
-H "Authorization: Bearer your-auth-token"php
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://your-domain.com']);
$expenseId = 1;
$response = $client->request('DELETE', "/api/v1/expenses/{$expenseId}", [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer your-auth-token',
],
]);
$data = json_decode($response->getBody(), true);
print_r($data);javascript
const BASE_URL = 'https://your-domain.com';
const TOKEN = 'your-auth-token';
const expenseId = 1;
const response = await fetch(`${BASE_URL}/api/v1/expenses/${expenseId}`, {
method: 'DELETE',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${TOKEN}`,
},
});
const data = await response.json();
console.log(data);python
import requests
BASE_URL = "https://your-domain.com"
TOKEN = "your-auth-token"
expense_id = 1
response = requests.delete(
f"{BASE_URL}/api/v1/expenses/{expense_id}",
headers={
"Accept": "application/json",
"Authorization": f"Bearer {TOKEN}",
},
)
data = response.json()
print(data)go
package main
import (
"fmt"
"io"
"net/http"
"strconv"
)
const baseURL = "https://your-domain.com"
const token = "your-auth-token"
func main() {
expenseId := 1
endpoint := baseURL + "/api/v1/expenses/" + strconv.Itoa(expenseId)
req, _ := http.NewRequest("DELETE", endpoint, nil)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
}rust
use reqwest::Client;
const BASE_URL: &str = "https://your-domain.com";
const TOKEN: &str = "your-auth-token";
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let client = Client::new();
let expense_id = 1;
let response = client
.delete(format!("{BASE_URL}/api/v1/expenses/{expense_id}"))
.header("Accept", "application/json")
.bearer_auth(TOKEN)
.send()
.await?;
let data: serde_json::Value = response.json().await?;
println!("{data:#}");
Ok(())
}