Skip to content

Expenses API

Record and retrieve business expenses programmatically.

The Expenses API allows you to log operating costs from external systems — travel management platforms, expense reporting tools, or corporate card integrations — and have them flow directly into your Cashfin financials.

Use Cases

  • Expense Reporting Tools: Push approved expense claims into Cashfin automatically
  • Travel Management: Sync travel bookings and costs when they are confirmed
  • Card Integrations: Record transactions from corporate card feeds

Endpoints

MethodEndpointDescription
POST/business/expense/createCreate a new expense
GET/business/expense/listList all expenses
GET/business/expense/details/:idGet expense details

Create Expense

Log a new business expense.

http
POST /business/expense/create

Request Body

FieldTypeRequiredDescription
titlestringYesExpense description
amountnumberYesTotal expense amount
expensedatestringYesDate of expense (ISO 8601)
descriptionstringNoAdditional notes
vendoridstringNoVendor ID to associate this expense with
statusstringNoInitial status (default: draft)
itemsarrayNoLine items (see Item Object below)

Item Object

FieldTypeDescription
itemidstringProduct ID
namestringItem name
quantityintegerQuantity
ratenumberPrice per unit

Example Request

bash
curl -X POST "https://api.cashfin.africa/business/expense/create" \
  -H "Authorization: cs_your_client_secret" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Team lunch",
    "amount": 5000.00,
    "expensedate": "2024-01-15",
    "description": "Monthly team lunch meeting",
    "status": "approved"
  }'
javascript
const response = await fetch(
  "https://api.cashfin.africa/business/expense/create",
  {
    method: "POST",
    headers: {
      Authorization: "cs_your_client_secret",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      title: "Team lunch",
      amount: 5000.0,
      expensedate: "2024-01-15",
      description: "Monthly team lunch meeting",
      status: "approved",
    }),
  }
);
const data = await response.json();
php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL            => "https://api.cashfin.africa/business/expense/create",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST           => true,
  CURLOPT_POSTFIELDS     => json_encode([
    'title'       => 'Team lunch',
    'amount'      => 5000.00,
    'expensedate' => '2024-01-15',
    'description' => 'Monthly team lunch meeting',
    'status'      => 'approved',
  ]),
  CURLOPT_HTTPHEADER     => [
    "Authorization: cs_your_client_secret",
    "Content-Type: application/json"
  ],
]);

$result = json_decode(curl_exec($curl), true);
python
import requests

response = requests.post(
    'https://api.cashfin.africa/business/expense/create',
    headers={
        'Authorization': 'cs_your_client_secret',
        'Content-Type': 'application/json'
    },
    json={
        'title': 'Team lunch',
        'amount': 5000.00,
        'expensedate': '2024-01-15',
        'description': 'Monthly team lunch meeting',
        'status': 'approved',
    }
)

Success Response

json
{
  "success": true,
  "message": "Expense created successfully",
  "data": {
    "_id": "507f1f77bcf86cd799439070",
    "title": "EXP-2024-001 - Team lunch",
    "amount": 5000.0,
    "status": "approved",
    "expensedate": "2024-01-15T00:00:00.000Z",
    "sourceorigin": "api",
    "active": true,
    "createdat": "2024-01-15T12:00:00.000Z"
  }
}

List Expenses

Retrieve a paginated list of expenses.

http
GET /business/expense/list

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger10Results per page (max: 100)
searchstring-Search by title or description
statusstring-Filter by status: draft, approved, paid, partially_paid, rejected

Example Request

bash
curl -X GET "https://api.cashfin.africa/business/expense/list?page=1&limit=10&status=approved" \
  -H "Authorization: cs_your_client_secret"
javascript
const response = await fetch(
  "https://api.cashfin.africa/business/expense/list?status=approved",
  {
    headers: { Authorization: "cs_your_client_secret" },
  }
);
const data = await response.json();
python
import requests

response = requests.get(
    'https://api.cashfin.africa/business/expense/list',
    headers={'Authorization': 'cs_your_client_secret'},
    params={'page': 1, 'limit': 10, 'status': 'approved'}
)

Success Response

json
{
  "success": true,
  "data": [
    {
      "_id": "507f1f77bcf86cd799439070",
      "title": "EXP-2024-001 - Team lunch",
      "amount": 5000.0,
      "status": "approved",
      "expensedate": "2024-01-15T00:00:00.000Z",
      "createdat": "2024-01-15T12:00:00.000Z"
    }
  ],
  "pagination": {
    "total": 30,
    "page": 1,
    "limit": 10,
    "pages": 3
  }
}

Get Expense Details

Retrieve full details of a specific expense.

http
GET /business/expense/details/:id

Path Parameters

ParameterTypeRequiredDescription
idstringYesExpense ID (MongoDB ObjectID)

Example Request

bash
curl -X GET "https://api.cashfin.africa/business/expense/details/507f1f77bcf86cd799439070" \
  -H "Authorization: cs_your_client_secret"
javascript
const expenseId = "507f1f77bcf86cd799439070";

const response = await fetch(
  `https://api.cashfin.africa/business/expense/details/${expenseId}`,
  {
    headers: { Authorization: "cs_your_client_secret" },
  }
);
const data = await response.json();
python
import requests

expense_id = '507f1f77bcf86cd799439070'

response = requests.get(
    f'https://api.cashfin.africa/business/expense/details/{expense_id}',
    headers={'Authorization': 'cs_your_client_secret'}
)

Success Response

json
{
  "success": true,
  "data": {
    "_id": "507f1f77bcf86cd799439070",
    "title": "EXP-2024-001 - Team lunch",
    "amount": 5000.0,
    "tax": 0,
    "taxamount": 0,
    "discount": 0,
    "status": "approved",
    "description": "Monthly team lunch meeting",
    "expensedate": "2024-01-15T00:00:00.000Z",
    "items": [],
    "vendor": null,
    "account": null,
    "createdat": "2024-01-15T12:00:00.000Z",
    "updatedat": "2024-01-15T12:00:00.000Z"
  }
}

Error Responses

Expense Not Found

json
{
  "success": false,
  "error": "Expense not found"
}

Invalid Date Format

json
{
  "success": false,
  "error": "Invalid expensedate format. Use ISO 8601 (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ)"
}

Cashfin Business API Documentation