The error model (code, detail, source, correlation ID), the HTTP codes the API returns, and partial success (207) on bulk updates.
The Spendesk API follows standard conventions using HTTP response codes.
Error Model
Errors share a consistent model, which provides additional detail, where necessary, to help resolve the error(s):
{
"correlationId": "a3b8e2f1-4c5d-4e6f-9a0b-1c2d3e4f5a6b",
"errors": [
{
"code": "BAD_REQUEST_INCORRECT_OR_MISSING_FIELD",
"detail": "There is a validation error with incorrect field in request body. Please fix and repeat your request.",
"source": "type"
},
{
"code": "BAD_REQUEST_INCORRECT_OR_MISSING_FIELD",
"detail": "There is a validation error with incorrect field in request body. Please fix and repeat your request.",
"source": "bookkeepingStatus"
}
]
}errors- one or more errors, each with a stablecode, a human-readabledetailand, for validation errors, thesourcefield at fault;correlationId- the identifier of your request, also returned in thex-correlation-idresponse header. Include it when you contact support about a failed call.
HTTP Codes
These are the common standard HTTP response codes that will be used when there is an error in your request:
| HTTP Code | code | Description |
|---|---|---|
| 400 | BAD_REQUEST_INCORRECT_OR_MISSING_FIELD | Bad Request - something in the request was not as expected. The response body says which field and, for a value outside a list, the allowed values. |
| 400 | RESPONSE_TOO_LARGE | The answer would exceed 512,000 bytes. Narrow the request: a shorter date range, more filters or a smaller page. Retrying the same request does not help. |
| 401 | AUTHENTICATION_ERROR | Authentication Error - check your access token. When it has expired, the message says so ("The access token has expired. Request a new token."): request a new one. The response carries a WWW-Authenticate: Bearer header. |
| 403 | FORBIDDEN_ERROR | Forbidden - you're trying to access something you don't have the correct privileges for. Try reviewing the scope of your API credentials or access token. |
| 404 | NOT_FOUND | Not Found - the resource you're requesting doesn't exist. List endpoints also return 404 for a page past the last one — see Pagination. |
| 409 | CONFLICT_ERROR | Conflict - the request conflicts with the current state of the resource, or a limit was reached (for example the number of open payable snapshot requests). |
| 413 | LARGE_BODY_ERROR | Payload Too Large - the request body or the uploaded file is too large. |
| 415 | UNSUPPORTED_MEDIA_TYPE | Unsupported Media Type - the type of the uploaded file is not accepted. |
| 415 | UNSUPPORTED_MEDIA_TYPE_ERROR | The body was sent with a Content-Type the API cannot read (for example application/xml, or a malformed header). Send JSON with Content-Type: application/json. |
| 422 | - | Unprocessable - the request is valid but cannot be applied in the resource's current state. The body gives a reason instead of the errors list. |
| 422 | EXPORT_FAILED | A journal export ran but failed. detail gives the reason, for example a payable that cannot be turned into a journal line. |
| 429 | TOO_MANY_REQUESTS | Too Many Requests - you have made too many requests and hit the rate limit. Wait the number of seconds in the Retry-After header, then retry — see Rate Limiting. |
| 500 | INTERNAL_SERVER_ERROR | Internal Server Error - something has gone wrong on our side, best to contact our support with the correlationId. |
| 503 | SERVICE_UNAVAILABLE_ERROR | Service Unavailable - the feature is temporarily unavailable (for example payable snapshots). Retry later. |
Partial success on bulk updates
Bulk updates — Update bookkeeping status of payables and Update state of settlements — return 207 Multi-Status when some items were updated and others were not. Check the outcome of each item: updated, or notUpdated with a reason such as notFound or invalidState.
{
"updatedPayables": [
{ "id": "bc9cef35-401d-4ea4-b384-ed725e6685cf", "outcome": "updated" },
{ "id": "5d1f0a2e-7b6c-4e3d-9f8a-2b1c0d9e8f7a", "outcome": "notUpdated", "reason": "invalidState" }
]
}