Skip to content

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.

PropertyValue
EndpointFetch All Expenses
MethodGET
URL/api/v1/expenses
AuthenticationBearer Token

Request Headers:

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

Query Parameters:

ParameterTypeRequiredDescription
from_datedateNoStart date filter
to_datedateNoEnd date filter
category_idintegerNoFilter 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
}

Fetch Expense Categories

Retrieve all expense categories.

PropertyValue
EndpointFetch Expense Categories
MethodGET
URL/api/v1/expenses/categories
AuthenticationBearer Token

Success Response (200 OK):

json
{
    "success": true,
    "data": [
        {"id": 1, "name": "Office Supplies"},
        {"id": 2, "name": "Utilities"},
        {"id": 3, "name": "Equipment"}
    ]
}

Fetch Expense

Retrieve details of a specific expense.

PropertyValue
EndpointFetch Expense
MethodGET
URL/api/v1/expenses/{id}
AuthenticationBearer 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"
    }
}

Create Expense

Record a new expense.

PropertyValue
EndpointCreate Expense
MethodPOST
URL/api/v1/expenses
AuthenticationBearer Token

Request Body:

json
{
    "isp_id": 1,
    "branch_id": 1,
    "user_id": 1,
    "category_id": 1,
    "amount": 5000,
    "description": "Office supplies"
}
ParameterTypeRequiredDescription
category_idintegerYesExpense category ID
amountdecimalYesExpense amount
descriptionstringNoExpense description

Success Response (201 Created):

json
{
    "success": true,
    "message": "Expense recorded successfully",
    "data": {
        "id": 1
    }
}

Update Expense

Update an existing expense record.

PropertyValue
EndpointUpdate Expense
MethodPUT
URL/api/v1/expenses/{id}
AuthenticationBearer Token

Request Body:

json
{
    "amount": 6000,
    "description": "Updated description"
}

Success Response (200 OK):

json
{
    "success": true,
    "message": "Expense updated successfully"
}

Delete Expense

Delete an expense record.

PropertyValue
EndpointDelete Expense
MethodDELETE
URL/api/v1/expenses/{id}
AuthenticationBearer Token

Success Response (200 OK):

json
{
    "success": true,
    "message": "Expense deleted successfully"
}

www.onezeroart.com