Expenses API
Expenses, receipt capture and categories. Every endpoint below is part of the stable v1 contract. Base URL https://app.aio.opexcg.com; send your key in X-API-Key.
GET /api/expenses: List expensesGET /api/expenses/:id: Get an expensePOST /api/expenses: Create an expensePATCH /api/expenses/:id: Update an expensePOST /api/expenses/:id/submit: Submit an expense for approvalPOST /api/expenses/capture: Capture a receiptGET /api/expenses/categories: List expense categories
List expenses
GET /api/expenses
Expenses you may see, newest first by default. A dateFrom or dateTo that is not YYYY-MM-DD answers 400. Amounts are integer minor units of currency (totalCents: 8500000 in IDR is Rp 85.000).
Sort keys: created (default), issued, total, vendor, status, submittedBy.
- Product: Expenses (
expenses) - Permission: any member
Query parameters
| Field | Type | Required | Description |
|---|---|---|---|
page |
string |
no | 1-based page number. Default 1. |
pageSize |
string |
no | Rows per page, 1 to 100. Larger values are clamped. Default 20. |
search |
string |
no | Free-text filter (trimmed, first 200 characters). |
sort |
string |
no | Sort key. Unknown keys fall back to the endpoint’s default sort. |
dir |
string |
no | asc or desc (default). |
status |
string |
no | draft, pending, approved, rejected or paid. |
mine |
string |
no | 1 or true: only expenses you submitted. |
submitterId |
string |
no | Only expenses of this member. |
projectId |
string |
no | Only expenses charged to this project. |
dateFrom |
string |
no | Issued on or after this day (YYYY-MM-DD). |
dateTo |
string |
no | Issued on or before this day (YYYY-MM-DD). |
category |
string |
no | Category name. |
Response 200
One page of expenses.
| Field | Type | Description |
|---|---|---|
items |
object[] |
|
items[].id |
string |
|
items[].submitted_by_user_id |
string |
|
items[].status |
"draft" | "pending" | "approved" | "rejected" | "paid" |
|
items[].vendor_name |
string | null |
|
items[].invoice_number |
string | null |
|
items[].document_kind |
string |
receipt, invoice, … (other until recognised). |
items[].issued_at |
number | null |
Epoch milliseconds. |
items[].currency |
string | null |
|
items[].subtotal_cents |
number | null |
|
items[].tax_cents |
number | null |
|
items[].total_cents |
number | null |
Integer minor units of currency. |
items[].category |
string | null |
|
items[].project_id |
string | null |
|
items[].submission_id |
string | null |
The batch this expense was filed in, if any. |
items[].rejection_reason |
string | null |
|
items[].ocr_confidence |
number | null |
Set once receipt recognition ran. |
items[].created_at |
number |
|
items[].project_name |
string | null |
|
items[].submitted_by_name |
string | null |
|
total |
number |
|
page |
number |
|
pageSize |
number |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Errors: invalid_date_range, plus the shared ones. Meanings: error codes.
Example
curl -X GET 'https://app.aio.opexcg.com/api/expenses?pageSize=2&search=Kopi' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "items": [ { "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc", "tenant_id": "opexcg-tenant", "submitted_by_user_id": "usr-fitri-handayani", "vendor_name": "Kopi Kenangan", "vendor_tax_id": null, "invoice_number": null, "document_kind": "receipt", "issued_at": 1793965650435, "due_at": null, "currency": "IDR", "subtotal_cents": 0, "tax_cents": 0, "total_cents": 8500000, "category": "Meals & Entertainment", "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6", "submission_id": null, "subject_type": null, "subject_id": null, "status": "draft", "ocr_raw_json": null, "ocr_confidence": null, "file_asset_id": null, "approved_by": null, "approved_at": null, "pm_approved_amount_cents": null, "pm_approved_currency": null, "pm_approved_project_id": null, "correction_requested_at": null, "rejection_reason": null, "reimbursed_at": null, "paid_at": null, "created_at": 1794052050465, "created_by": "usr-fitri-handayani", "modified_at": 1794052050465, "modified_by": "usr-fitri-handayani", "deleted_at": null, "deleted_by": null, "project_name": "Customer portal rollout", "submitted_by_name": "Fitri Handayani" }, { "id": "exp-opexcg-target-073", "tenant_id": "opexcg-tenant", "submitted_by_user_id": "usr-sari-wulandari", "vendor_name": "Kopi Kalyan", "vendor_tax_id": null, "invoice_number": "OPEXCG-TARGET-073", "document_kind": "receipt", "issued_at": 1789862400000, "due_at": null, "currency": "IDR", "subtotal_cents": 29000000, "tax_cents": 0, "total_cents": 29000000, "category": "Meals", "project_id": "prj-presales", "submission_id": "sub-opexcg-presales-01", "subject_type": null, "subject_id": null, "status": "pending", "ocr_raw_json": null, "ocr_confidence": null, "file_asset_id": null, "approved_by": null, "approved_at": null, "pm_approved_amount_cents": null, "pm_approved_currency": null, "pm_approved_project_id": null, "correction_requested_at": null, "rejection_reason": null, "reimbursed_at": null, "paid_at": null, "created_at": 1789776000000, "created_by": "usr-sari-wulandari", "modified_at": 1789776000000, "modified_by": "usr-sari-wulandari", "deleted_at": null, "deleted_by": null, "project_name": "Presales", "submitted_by_name": "Sari Wulandari" } ], "total": 2, "page": 1, "pageSize": 2}Get an expense
GET /api/expenses/:id
One expense with its line items. Amounts are integer minor units of currency (totalCents: 8500000 in IDR is Rp 85.000).
- Product: Expenses (
expenses) - Permission: any member
Path parameters
| Field | Type | Required | Description |
|---|---|---|---|
id |
string |
yes | Expense id. |
Response 200
The expense.
| Field | Type | Description |
|---|---|---|
id |
string |
|
submitted_by_user_id |
string |
|
status |
"draft" | "pending" | "approved" | "rejected" | "paid" |
|
vendor_name |
string | null |
|
invoice_number |
string | null |
|
document_kind |
string |
receipt, invoice, … (other until recognised). |
issued_at |
number | null |
Epoch milliseconds. |
currency |
string | null |
|
subtotal_cents |
number | null |
|
tax_cents |
number | null |
|
total_cents |
number | null |
Integer minor units of currency. |
category |
string | null |
|
project_id |
string | null |
|
submission_id |
string | null |
The batch this expense was filed in, if any. |
rejection_reason |
string | null |
|
ocr_confidence |
number | null |
Set once receipt recognition ran. |
created_at |
number |
|
lines |
object[] |
|
lines[].id |
string |
|
lines[].description |
string | null |
|
lines[].qty |
number | null |
|
lines[].unit_amount_cents |
number | null |
|
lines[].amount_cents |
number |
|
lines[].tax_cents |
number |
|
lines[].gl_code |
string | null |
|
fileUrl |
string | null |
Path of the captured document (send your API key). |
submitter_name |
string | null |
|
approval_instance_id |
string | null |
Approval timeline: GET /api/approvals/instances/{id}. |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Errors: not_found, plus the shared ones. Meanings: error codes.
Example
curl -X GET 'https://app.aio.opexcg.com/api/expenses/79a3e8b7-b420-499b-adb9-a8d52c1fc5dc' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc", "tenant_id": "opexcg-tenant", "submitted_by_user_id": "usr-fitri-handayani", "vendor_name": "Kopi Kenangan", "vendor_tax_id": null, "invoice_number": null, "document_kind": "receipt", "issued_at": 1793965650435, "due_at": null, "currency": "IDR", "subtotal_cents": 0, "tax_cents": 0, "total_cents": 8500000, "category": "Meals & Entertainment", "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6", "submission_id": null, "subject_type": null, "subject_id": null, "status": "draft", "ocr_raw_json": null, "ocr_confidence": null, "file_asset_id": null, "approved_by": null, "approved_at": null, "pm_approved_amount_cents": null, "pm_approved_currency": null, "pm_approved_project_id": null, "correction_requested_at": null, "rejection_reason": null, "reimbursed_at": null, "paid_at": null, "created_at": 1794052050465, "created_by": "usr-fitri-handayani", "modified_at": 1794052050465, "modified_by": "usr-fitri-handayani", "deleted_at": null, "deleted_by": null, "lines": [], "fileUrl": null, "attachments": [], "submitter_currency": null, "submitter_name": "Fitri Handayani", "approval_instance_id": null}Create an expense
POST /api/expenses
Creates a draft expense filed by the caller. Amounts are integer minor units of currency (totalCents: 8500000 in IDR is Rp 85.000). Dates are epoch milliseconds. Charging a project needs access to that project.
- Product: Expenses (
expenses) - Permission: any member
Request body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
vendorName |
string |
no | max length 200 |
vendorTaxId |
string |
no | max length 60 |
invoiceNumber |
string |
no | max length 120 |
documentKind |
"invoice" | "receipt" | "nota" | "billing" | "other" |
no | |
issuedAt |
integer |
no | |
dueAt |
integer | null |
no | |
currency |
string |
no | max length 8 |
subtotalCents |
integer |
no | min 0 |
taxCents |
integer |
no | min 0 |
totalCents |
integer |
no | min 0 |
category |
string |
no | max length 120 |
projectId |
string | null |
no | |
subjectType |
"ticket" | "task" | null |
no | |
subjectId |
string | null |
no | |
lines |
object[] |
no | max 200 items |
lines[].description |
string |
no | max length 300 |
lines[].qty |
integer |
no | min 0 |
lines[].unitAmountCents |
integer |
no | min 0 |
lines[].amountCents |
integer |
no | min 0 |
lines[].taxCents |
integer |
no | min 0 |
lines[].glCode |
string |
no | max length 60 |
Response 201
The new draft.
| Field | Type | Description |
|---|---|---|
id |
string |
|
submitted_by_user_id |
string |
|
status |
"draft" | "pending" | "approved" | "rejected" | "paid" |
|
vendor_name |
string | null |
|
invoice_number |
string | null |
|
document_kind |
string |
receipt, invoice, … (other until recognised). |
issued_at |
number | null |
Epoch milliseconds. |
currency |
string | null |
|
subtotal_cents |
number | null |
|
tax_cents |
number | null |
|
total_cents |
number | null |
Integer minor units of currency. |
category |
string | null |
|
project_id |
string | null |
|
submission_id |
string | null |
The batch this expense was filed in, if any. |
rejection_reason |
string | null |
|
ocr_confidence |
number | null |
Set once receipt recognition ran. |
created_at |
number |
|
lines |
object[] |
|
lines[].id |
string |
|
lines[].description |
string | null |
|
lines[].qty |
number | null |
|
lines[].unit_amount_cents |
number | null |
|
lines[].amount_cents |
number |
|
lines[].tax_cents |
number |
|
lines[].gl_code |
string | null |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Example
curl -X POST 'https://app.aio.opexcg.com/api/expenses' \ -H "X-API-Key: $OPEX_API_KEY" \ -H "content-type: application/json" \ -d '{"vendorName":"Kopi Kenangan","documentKind":"receipt","issuedAt":1793965650435,"currency":"IDR","totalCents":8500000,"category":"Meals & Entertainment","projectId":"99e5d1dd-334c-4bc3-88c7-7d84558bf7c6"}'Response 201:
{ "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc", "tenant_id": "opexcg-tenant", "submitted_by_user_id": "usr-fitri-handayani", "vendor_name": "Kopi Kenangan", "vendor_tax_id": null, "invoice_number": null, "document_kind": "receipt", "issued_at": 1793965650435, "due_at": null, "currency": "IDR", "subtotal_cents": 0, "tax_cents": 0, "total_cents": 8500000, "category": "Meals & Entertainment", "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6", "submission_id": null, "subject_type": null, "subject_id": null, "status": "draft", "ocr_raw_json": null, "ocr_confidence": null, "file_asset_id": null, "approved_by": null, "approved_at": null, "pm_approved_amount_cents": null, "pm_approved_currency": null, "pm_approved_project_id": null, "correction_requested_at": null, "rejection_reason": null, "reimbursed_at": null, "paid_at": null, "created_at": 1794052050465, "created_by": "usr-fitri-handayani", "modified_at": 1794052050465, "modified_by": "usr-fitri-handayani", "deleted_at": null, "deleted_by": null, "lines": []}Update an expense
PATCH /api/expenses/:id
Changes a draft. You can edit your own drafts; editing someone else’s needs expenses:submission:manage. Expenses that left draft answer 409 locked.
- Product: Expenses (
expenses) - Permission: any member
- Also: Own drafts, or expenses:submission:manage.
Path parameters
| Field | Type | Required | Description |
|---|---|---|---|
id |
string |
yes | Expense id. |
Request body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
vendorName |
string |
no | max length 200 |
vendorTaxId |
string |
no | max length 60 |
invoiceNumber |
string |
no | max length 120 |
documentKind |
"invoice" | "receipt" | "nota" | "billing" | "other" |
no | |
issuedAt |
integer |
no | |
dueAt |
integer | null |
no | |
currency |
string |
no | max length 8 |
subtotalCents |
integer |
no | min 0 |
taxCents |
integer |
no | min 0 |
totalCents |
integer |
no | min 0 |
category |
string |
no | max length 120 |
projectId |
string | null |
no | |
subjectType |
"ticket" | "task" | null |
no | |
subjectId |
string | null |
no | |
lines |
object[] |
no | max 200 items |
lines[].description |
string |
no | max length 300 |
lines[].qty |
integer |
no | min 0 |
lines[].unitAmountCents |
integer |
no | min 0 |
lines[].amountCents |
integer |
no | min 0 |
lines[].taxCents |
integer |
no | min 0 |
lines[].glCode |
string |
no | max length 60 |
Response 200
The updated draft.
| Field | Type | Description |
|---|---|---|
id |
string |
|
submitted_by_user_id |
string |
|
status |
"draft" | "pending" | "approved" | "rejected" | "paid" |
|
vendor_name |
string | null |
|
invoice_number |
string | null |
|
document_kind |
string |
receipt, invoice, … (other until recognised). |
issued_at |
number | null |
Epoch milliseconds. |
currency |
string | null |
|
subtotal_cents |
number | null |
|
tax_cents |
number | null |
|
total_cents |
number | null |
Integer minor units of currency. |
category |
string | null |
|
project_id |
string | null |
|
submission_id |
string | null |
The batch this expense was filed in, if any. |
rejection_reason |
string | null |
|
ocr_confidence |
number | null |
Set once receipt recognition ran. |
created_at |
number |
|
lines |
object[] |
|
lines[].id |
string |
|
lines[].description |
string | null |
|
lines[].qty |
number | null |
|
lines[].unit_amount_cents |
number | null |
|
lines[].amount_cents |
number |
|
lines[].tax_cents |
number |
|
lines[].gl_code |
string | null |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Errors: not_found, forbidden, locked, project_mismatch, plus the shared ones. Meanings: error codes.
Example
curl -X PATCH 'https://app.aio.opexcg.com/api/expenses/79a3e8b7-b420-499b-adb9-a8d52c1fc5dc' \ -H "X-API-Key: $OPEX_API_KEY" \ -H "content-type: application/json" \ -d '{"totalCents":9000000}'Response 200:
{ "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc", "tenant_id": "opexcg-tenant", "submitted_by_user_id": "usr-fitri-handayani", "vendor_name": "Kopi Kenangan", "vendor_tax_id": null, "invoice_number": null, "document_kind": "receipt", "issued_at": 1793965650435, "due_at": null, "currency": "IDR", "subtotal_cents": 0, "tax_cents": 0, "total_cents": 9000000, "category": "Meals & Entertainment", "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6", "submission_id": null, "subject_type": null, "subject_id": null, "status": "draft", "ocr_raw_json": null, "ocr_confidence": null, "file_asset_id": null, "approved_by": null, "approved_at": null, "pm_approved_amount_cents": null, "pm_approved_currency": null, "pm_approved_project_id": null, "correction_requested_at": null, "rejection_reason": null, "reimbursed_at": null, "paid_at": null, "created_at": 1794052050465, "created_by": "usr-fitri-handayani", "modified_at": 1794052050649, "modified_by": "usr-fitri-handayani", "deleted_at": null, "deleted_by": null, "lines": []}Submit an expense for approval
POST /api/expenses/:id/submit
Sends a draft (or a rejected expense) for approval. The answer carries the new status, usually pending; approvers then decide it through the approvals endpoints. Pending, approved and paid expenses answer 409 invalid_transition.
- Product: Expenses (
expenses) - Permission: any member
- Also: Own drafts, or expenses:submission:manage.
Path parameters
| Field | Type | Required | Description |
|---|---|---|---|
id |
string |
yes | Expense id. |
Response 200
The submitted expense.
| Field | Type | Description |
|---|---|---|
id |
string |
|
submitted_by_user_id |
string |
|
status |
"draft" | "pending" | "approved" | "rejected" | "paid" |
|
vendor_name |
string | null |
|
invoice_number |
string | null |
|
document_kind |
string |
receipt, invoice, … (other until recognised). |
issued_at |
number | null |
Epoch milliseconds. |
currency |
string | null |
|
subtotal_cents |
number | null |
|
tax_cents |
number | null |
|
total_cents |
number | null |
Integer minor units of currency. |
category |
string | null |
|
project_id |
string | null |
|
submission_id |
string | null |
The batch this expense was filed in, if any. |
rejection_reason |
string | null |
|
ocr_confidence |
number | null |
Set once receipt recognition ran. |
created_at |
number |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Errors: not_found, forbidden, invalid_transition, submission_locked, plus the shared ones. Meanings: error codes.
Example
curl -X POST 'https://app.aio.opexcg.com/api/expenses/79a3e8b7-b420-499b-adb9-a8d52c1fc5dc/submit' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "id": "79a3e8b7-b420-499b-adb9-a8d52c1fc5dc", "tenant_id": "opexcg-tenant", "submitted_by_user_id": "usr-fitri-handayani", "vendor_name": "Kopi Kenangan", "vendor_tax_id": null, "invoice_number": null, "document_kind": "receipt", "issued_at": 1793965650435, "due_at": null, "currency": "IDR", "subtotal_cents": 0, "tax_cents": 0, "total_cents": 9000000, "category": "Meals & Entertainment", "project_id": "99e5d1dd-334c-4bc3-88c7-7d84558bf7c6", "submission_id": null, "subject_type": null, "subject_id": null, "status": "pending", "ocr_raw_json": null, "ocr_confidence": null, "file_asset_id": null, "approved_by": null, "approved_at": null, "pm_approved_amount_cents": null, "pm_approved_currency": null, "pm_approved_project_id": null, "correction_requested_at": null, "rejection_reason": null, "reimbursed_at": null, "paid_at": null, "created_at": 1794052050465, "created_by": "usr-fitri-handayani", "modified_at": 1794052050824, "modified_by": "usr-fitri-handayani", "deleted_at": null, "deleted_by": null}Capture a receipt
POST /api/expenses/capture
Uploads a receipt or invoice as multipart/form-data (field file) and creates a draft expense for it. Text recognition fills vendor, totals and lines a few seconds later, so read the expense again before submitting. Needs the Expenses pro tier; the file counts toward the workspace’s storage.
- Product: Expenses (
expenses) - Permission: any member
- Also: Expenses pro tier (402 tier_required otherwise).
Request body (multipart/form-data)
| Field | Type | Required | Description |
|---|---|---|---|
file |
file |
yes | The receipt or invoice: an image or PDF, up to 25 MB. |
Response 201
The new draft’s id.
| Field | Type | Description |
|---|---|---|
id |
string |
The new draft’s id. |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Errors: no_file, empty_file, too_large, quota_exceeded, tier_required, plus the shared ones. Meanings: error codes.
Example
curl -X POST 'https://app.aio.opexcg.com/api/expenses/capture' \ -H "X-API-Key: $OPEX_API_KEY" \Response 201:
{ "id": "91a2aee5-6803-4a61-b64e-47e0b3462139"}List expense categories
GET /api/expenses/categories
The workspace’s active expense categories. Use a category name as category on an expense.
- Product: Expenses (
expenses) - Permission: any member
Response 200
The categories.
| Field | Type | Description |
|---|---|---|
items |
object[] |
|
items[].id |
string |
|
items[].name |
string |
|
items[].description |
string | null |
|
items[].is_active |
number |
|
items[].display_order |
number |
Objects may carry more fields than listed; only the listed ones are part of the contract.
Example
curl -X GET 'https://app.aio.opexcg.com/api/expenses/categories' \ -H "X-API-Key: $OPEX_API_KEY"Response 200:
{ "items": [ { "id": "canonical:Travel & Transportation", "tenant_id": "", "name": "Travel & Transportation", "description": null, "is_active": 1, "display_order": 0, "created_at": 0, "created_by": null, "modified_at": 0, "modified_by": null, "deleted_at": null, "deleted_by": null }, { "id": "canonical:Meals & Entertainment", "tenant_id": "", "name": "Meals & Entertainment", "description": null, "is_active": 1, "display_order": 1, "created_at": 0, "created_by": null, "modified_at": 0, "modified_by": null, "deleted_at": null, "deleted_by": null } ]}