Skip to content

Expenses

Expenses endpoints need the Expenses product. Members file and edit their own drafts; editing someone else’s needs expenses:submission:manage. Receipt capture needs the Expenses pro plan. Full details: Expenses API.

Recipe: from a receipt photo to an approval request

Upload the photo as multipart/form-data. A draft expense is created at once and text recognition fills in vendor, amounts and lines a few seconds later.

Terminal window
EXPENSE_ID=$(curl -s -X POST "$OPEX/api/expenses/capture" \
-H "X-API-Key: $OPEX_API_KEY" -F "[email protected]" | jq -r .id)
{ "id": "880e1c07-1c4a-4754-ba00-bdbd397f89d5" }

Read the draft back (GET /api/expenses/$EXPENSE_ID) to see what was recognised, then fill in or correct what you know:

Terminal window
curl -s -X PATCH "$OPEX/api/expenses/$EXPENSE_ID" \
-H "X-API-Key: $OPEX_API_KEY" -H "content-type: application/json" \
-d '{"vendorName":"Grab","documentKind":"receipt","currency":"IDR","totalCents":6500000,
"category":"Travel & Transportation"}' \
| jq '{id, status, vendor_name, total_cents, currency}'
{
"id": "880e1c07-1c4a-4754-ba00-bdbd397f89d5",
"status": "draft",
"vendor_name": "Grab",
"total_cents": 6500000,
"currency": "IDR"
}

totalCents: 6500000 is Rp 65.000. Category names come from GET /api/expenses/categories. Then submit it:

Terminal window
curl -s -X POST "$OPEX/api/expenses/$EXPENSE_ID/submit" -H "X-API-Key: $OPEX_API_KEY" \
| jq '{id, status}'
{ "id": "880e1c07-1c4a-4754-ba00-bdbd397f89d5", "status": "pending" }

The expense now waits in its approvers’ approval inbox. Without the pro plan, skip the capture step and create the draft with POST /api/expenses instead.

Recipe: list your expenses waiting for approval

Terminal window
curl -s "$OPEX/api/expenses?mine=1&status=pending&pageSize=3" -H "X-API-Key: $OPEX_API_KEY" \
| jq '{total, items: [.items[] | {vendor_name, total_cents, currency, status}]}'
{
"total": 2,
"items": [
{ "vendor_name": "Grab", "total_cents": 6500000, "currency": "IDR", "status": "pending" },
{
"vendor_name": "Kopi Kenangan",
"total_cents": 9000000,
"currency": "IDR",
"status": "pending"
}
]
}