Errors
Every error is an RFC 7807 problem with a stable code and a request id. Branch on the code; retry by status.
Every error response from /v1/* follows
RFC 7807 Problem+JSON, extended with two
Acreum-specific fields: a stable code and a request_id.
Content-Type: application/problem+jsonThe shape
{
"type": "https://docs.acreum.io/errors/DOCUMENT_ALREADY_POSTED",
"title": "Document already posted",
"status": 409,
"detail": "The document has already been posted to the general ledger and is now immutable except via adjustment documents.",
"code": "DOCUMENT_ALREADY_POSTED",
"request_id": "018f0b3d-7c2e-7a3a-9f52-2a14d86e08ad",
"instance": "/v1/documents/4f2c…/post"
}| Field | Always present | Meaning |
|---|---|---|
type | yes | Documentation URI for the error code. |
title | yes | Short human-readable title. Stable per code. |
status | yes | HTTP status code. Mirrors the response status. |
detail | yes | Human-readable description of this occurrence. Not stable; copy may change. |
code | yes | The stable identifier. Branch on this, not on status or detail. |
request_id | yes | UUID identifying this request. Provide it to support. |
instance | yes | The request path that produced the error. |
errors | some codes | Array of per-field entries: on VALIDATION_FAILED one per invalid field, on INSUFFICIENT_SCOPE one per missing scope. |
context | some codes | Machine-readable detail for the code, for example the missing activation conditions on CONTRACT_ACTIVATION_NOT_READY. |
How to consume errors
- Branch on
code. It is the stable contract. New codes will be added; existing codes will not change meaning. - Fall back on
status. Group4xx(client mistake),429(back off) and5xx(transient or server bug; retry with backoff or escalate). - Surface
detailto humans, never to business logic. - Always log
request_id. It is the single id that correlates the request across HTTP logs, traces, the audit log and error tracking.
async function call(url: string, init: RequestInit) {
const res = await fetch(url, init);
if (!res.ok) {
const problem = await res.json();
switch (problem.code) {
case 'IDEMPOTENCY_CONFLICT':
throw new IdempotencyConflict(problem);
case 'INSUFFICIENT_SCOPE':
throw new ScopeMissing(problem);
case 'RATE_LIMITED':
return retryWithBackoff(res.headers.get('Retry-After'));
default:
throw new ApiError(problem);
}
}
return res.json();
}Validation errors
VALIDATION_FAILED (HTTP 400) carries an errors[] array. Each entry names the field
that failed and a stable per-field code:
{
"type": "https://docs.acreum.io/errors/VALIDATION_FAILED",
"title": "Validation failed",
"status": 400,
"detail": "One or more request fields failed validation. See `errors[]` for details.",
"code": "VALIDATION_FAILED",
"request_id": "…",
"instance": "/v1/documents",
"errors": [
{ "field": "items.0.item_total", "code": "INVALID_VALUE", "message": "must be > 0" },
{ "field": "party_id", "code": "REQUIRED", "message": "required" }
]
}Field paths use dot notation for nested objects and array indexes (items.0.item_total).
Read errors[].field and errors[].code; do not regex detail.
Accounting gates
Many 409 and 422 codes come from the ledger's integrity gates rather than from input
validation. The ones you will meet first:
code | Meaning |
|---|---|
DOCUMENT_ALREADY_POSTED | Posted documents are immutable. Void and recreate, or reissue. |
DOCUMENT_VOID_REQUIRES_MEMO | Voiding a posted document needs a non-empty memo. |
PERIOD_CLOSED / PERIOD_LOCKED | The document date falls in a closed period. Send period_override_reason with the accounting:periods_override scope, or pick an open date. A locked period cannot be overridden. |
DIMENSION_REQUIRED | The organization requires a custom field on this document type and it was not supplied (or not explicitly set to none). |
ACCOUNT_LEGAL_ENTITY_MISMATCH | A line names an account that belongs to a different legal entity. |
DOCUMENT_RECONCILED_CANNOT_VOID | The document is cleared on a completed bank reconciliation. Undo the reconciliation first. |
DOCUMENT_TYPE_NOT_CREATABLE_HERE | This type has its own origin endpoint; the detail names it. |
The full list of 520-plus codes, with the condition that raises each, is in the Error code catalog.
Retry policy
| Status | Retry? |
|---|---|
4xx (except 429) | No. Client mistake. Fix the request. |
429 | Yes, with exponential backoff. See Rate limits. |
500 | Maybe. Retry once with a small delay; if it persists, treat as a bug and contact support with request_id. |
502 / 503 | Yes, with exponential backoff. Cap retries at about five and surface the failure past that. |
For all retries of POST creates and state-changing actions, send the same
Idempotency-Key so a successful retry does not produce a duplicate. See
Idempotency.
Reporting bugs
Include in any support contact:
- The
code. - The
request_id. - The request URL and method (no body required; we have it).
- The approximate UTC timestamp.
Write to support@acreum.io. We can usually resolve a request to
its full server-side trace from request_id alone.