AI-categorize expenses
Sweep every uncategorized expense in the firm and assign a category from the existing list using AI classification.
When to use
After bulk-importing expenses (OCR, supplier sync, e-Factura SPV) thecategory_id is often null. This endpoint sweeps every such row and assigns a category from the firm’s existing list — system defaults plus custom categories, merged. Existing categorizations are never overwritten.
Call repeatedly until remaining = 0. Each call processes up to cap expenses (a server-side constant returned in the response), so a large backlog can be drained in controlled passes rather than a single long-running request.
Permissions
Requireswrite permission on expenses.
Request
BATCH_MAX_PER_CALL), so very large values are clamped silently. Omit for “process up to the server cap.”Response
| Field | Meaning |
|---|---|
processed | Expenses inspected this call. |
categorized | Expenses that received a category_id. |
skipped | Classifier declined to assign a category (low confidence or no obvious match in the firm’s list). |
errors | Per-row failures — logged server-side, retryable on next call. |
remaining | Uncategorized expenses still queued. Stop when this hits 0. |
batch_size | Expenses per classifier call (informational). |
cap | Hard ceiling per invocation (informational). |
Driver pattern
Errors
- 401 — missing / invalid bearer token
- 403 — API key lacks
writepermission on expenses - 502
ai_unavailable— classifier call failed; safe to retry - 503
ai_not_configured— AI categorization is not enabled on this deployment
Authorizations
Use your API key (sk_live_xxx or sk_test_xxx)
Body
Optional override for the per-call cap. The server still
enforces its own BATCH_MAX_PER_CALL ceiling, so very
large values are silently clamped.
Response
Batch run summary
Expenses inspected this call.
Expenses that received a category.
Classifier declined to assign a category (low confidence or no match).
Per-row failures (logged server-side).
Uncategorized expenses still in the queue. Call again until 0.
Expenses per classifier call (server constant).
Hard ceiling per invocation (server constant).