Error Codes
When a request fails, the Chainabit API returns an error inside the standard response envelope. This page lists the error format, the codes that apply across endpoints, and a recorded example for each common HTTP status. Individual endpoint pages document any additional, more specific codes that endpoint returns.
Error Response Format
{
"error": {
"code": "bad_request",
"message": "Human-readable description of the error",
"details": {}
},
"meta": {
"requestId": "fce07573-311d-4be3-8846-1156877a6022"
}
}error.codeis a stable, machine-readable string. Branch oncode(and the HTTP status), never onmessage: messages are for people and can be localized.error.messageis a human-readable description.error.detailsis optional. It appears only when the endpoint attaches structured context (for examplefeatureKeyon a plan refusal, orretryAfterSecondson a rate limit). Do not rely on it being present otherwise.meta.requestIdmatches theX-Request-Idresponse header. A request rejected before it is assigned a request ID (a missing or invalid bearer token, a malformed JSON body, an unknown route, an authorization policy refusal, a rate limit hit before authentication) has an emptymetaobject and noX-Request-Idheader. There is no timing field in the body.
Error Codes
Codes by HTTP status
When an endpoint does not declare a more specific code, code is a lowercase snake_case value derived from the HTTP status:
| Code | HTTP Status | Description |
|---|---|---|
bad_request | 400 | The request failed validation: an invalid or unknown field, a malformed identifier, or a body that is not valid JSON. message joins every violation with ; . |
unauthorized | 401 | The bearer token is missing, malformed, expired, or has an invalid signature. |
forbidden | 403 | The caller is authenticated but not allowed to perform the action. |
not_found | 404 | The resource does not exist, is not accessible to the caller, or the route does not exist. |
request_timeout | 408 | The request did not complete within the server's request timeout. |
conflict | 409 | The request conflicts with the current state of the resource. |
payload_too_large | 413 | The request body is larger than the API accepts. Nothing was created; send a smaller body. |
unprocessable_entity | 422 | The request was well-formed but could not be processed. |
rate_limited | 429 | Generic rate-limit refusal from a domain service (see RATE_LIMITED below for the global limiter). |
bad_gateway | 502 | An upstream service returned an invalid response. |
service_unavailable | 503 | The service is temporarily unavailable. |
gateway_timeout | 504 | An upstream service did not respond in time. |
internal_server_error | 500 | An unexpected error occurred. The message is always Internal Server Error; use meta.requestId when contacting support. |
Codes that apply across endpoints
| Code | HTTP Status | Description |
|---|---|---|
RATE_LIMITED | 429 | The endpoint's rate limit was exceeded. error.details.retryAfterSeconds and the Retry-After header give the wait. |
auth_insufficient_permissions | 403 | The account's plan or role does not grant the permission the endpoint requires. error.details.missingPermissions lists the missing permission keys. |
entitlement_required | 403 | The current plan does not include the requested feature. error.details.featureKey names it. |
feature_limit_reached | 403 | The current plan's limit for the feature is used up. error.details carries featureKey, limit and used when known. |
enterprise_insufficient_workspace_role | 403 | The user's workspace role does not permit this action. |
enterprise_insufficient_account_role | 403 | The user's account role does not permit this action, for example an admin calling a billing route that only owner and billing may use. See Business billing. |
billing_seat_charge_authority_required | 403 | A seat change that adds a paid seat can only be approved by the account owner or a billing member. |
enterprise_organization_name_invalid | 400 | An organisation legalName contains control or invisible format characters, or is empty after trimming. See Accounts. |
STEP_UP_REQUIRED | 403 | The action needs a recent identity re-verification. error.details.challenge describes what to complete. See Sessions. |
missing_idempotency_key | 428 | A mutating request was sent without the required Idempotency-Key header. See Idempotency. |
invalid_idempotency_key | 400 | The Idempotency-Key is not 8-128 characters from A-Z a-z 0-9 : _ - .. |
idempotency_key_reused_with_different_payload | 409 | The Idempotency-Key was already used with a different request. |
idempotency_in_progress | 409 | A request with this Idempotency-Key is still being processed. Retry after the Retry-After header. |
Codes keep the casing the API emits: most are lowercase snake_case, but a few (RATE_LIMITED, STEP_UP_REQUIRED) are uppercase. Match them exactly.
Developer token codes
These codes are returned when a developer token (a personal API key) is created or used. See Developer access for the rules behind them and Restrict API keys for recovery steps.
| Code | HTTP Status | Description |
|---|---|---|
developer_token_ip_denied | 401 | The token is restricted to a list of networks and the request came from another address. The token is still valid: do not discard it. Send the request from an allowed network, or create a replacement token with the right networks and revoke the old one. The response never reveals the allowed networks. Refreshing a session obtained from such a token through the compatibility exchange is refused the same way. |
developer_token_lifetime_exceeded | 422, 403 | The token's lifetime is longer than the maximum credential lifetime of the Organization. 422 when creating a token: choose a shorter expiry. 403 when using an existing token in that Organization, including a token created before the limit was set: it keeps working in other accounts; replace it with a shorter-lived token. error.details.maxCredentialLifetimeDays gives the limit. |
developer_token_non_expiring_unavailable | 422 | The create request asked for "expiry": "none". Tokens without an expiry are not supported; choose a preset. |
developer_token_expiry_conflict | 400 | The create request sent both expiry and expiresInDays. Send only one. |
developer_token_expiry_invalid | 400 | expiry is not one of the presets 1d, 7d, 30d, 90d or 1y. Request validation usually refuses such a value first, with bad_request. |
developer_token_networks_invalid | 400 | At least one allowedNetworks entry is not a valid IPv4 or IPv6 address or CIDR range. error.details.errors lists each invalid entry as index (its position in your list, from 0) and code: network_invalid_address, network_invalid_prefix or network_invalid_mapped_prefix. No token is created; fix the entries and retry. An empty list or more than 100 entries is refused as bad_request. |
developer_token_catalog_stale | 409 | The catalogVersion sent with the create request no longer matches the permission catalog. error.details.catalogVersion holds the current version. Read the catalog again, review the permissions, and retry. |
developer_token_network_broad is not an error. It appears in the warnings array of a successful create response when an allowed network covers every address (0.0.0.0/0 or ::/0), which makes the restriction ineffective.
Other refusals of a developer token use the general codes. An expired, revoked or unknown token returns 401 and unauthorized (Invalid or expired developer token). A token used on a route it may not call returns 403 and forbidden; when the token lacks a permission, the message names it. If an Organization's policy cannot be read while a token is checked, the request is refused with 503 and SSO_POLICY_UNAVAILABLE; retry later.
An invalid allowedNetworks list returns:
{
"error": {
"code": "developer_token_networks_invalid",
"message": "One or more allowed networks are invalid",
"details": {
"errors": [{ "index": 1, "code": "network_invalid_address" }]
}
}
}The meta object is omitted here.
Examples
The examples below are responses recorded from a running API. Request IDs are shortened where noted.
bad_request (400)
Returned when the request body fails validation. POST /api/v1/auth/register with an unknown field, an invalid email and a short password:
{
"error": {
"code": "bad_request",
"message": "property unknown should not exist; email must be an email; password must be longer than or equal to 8 characters"
},
"meta": {
"requestId": "d7a9420c-9213-4ff2-b600-294044410928"
}
}There is no per-field breakdown: split message on ; if you need the individual violations.
unauthorized (401)
Returned when no token is provided:
{
"error": {
"code": "unauthorized",
"message": "Missing authentication token"
},
"meta": {}
}An invalid or expired token returns the same code with a different message (for example Invalid token signature or claims). Refresh the token and retry, see Authentication.
Plan and permission refusals (403)
A request for a feature the caller's plan does not include can return:
{
"error": {
"code": "entitlement_required",
"message": "Feature not included in plan: ai.knowledge.query",
"details": {
"featureKey": "ai.knowledge.query"
}
},
"meta": {
"requestId": "87f35d0a-92ee-4fcc-be0d-779e0df0e032"
}
}Endpoints guarded by a permission check refuse earlier, with auth_insufficient_permissions:
{
"error": {
"code": "auth_insufficient_permissions",
"message": "Insufficient permissions",
"details": {
"missingPermissions": ["ai.knowledge.query"],
"requiredPermissions": ["ai.knowledge.query"],
"roleContext": {
"appRole": "user",
"requiredRoles": []
}
}
},
"meta": {}
}not_found (404)
GET /api/v1/chains/{id} for a chain that does not exist or is not visible to the caller:
{
"error": {
"code": "not_found",
"message": "Chain not found"
},
"meta": {
"requestId": "fce07573-311d-4be3-8846-1156877a6022"
}
}An unknown route returns not_found; the message identifies the unrecognized request path.
payload_too_large (413)
Returned when the request body is larger than the API accepts, for example a very long chat message sent to POST /api/v1/ai/sessions/{id}/messages. The request is refused before it is parsed, so it has no request ID: meta is empty and there is no X-Request-Id header, and nothing is created.
{
"error": {
"code": "payload_too_large",
"message": "Request body is too large"
},
"meta": {}
}Shorten the body and send it again. For chat messages, see Long messages and model capacity.
Run failures are not HTTP errors
An AI run starts after its request has been accepted, so a run that cannot continue fails later and not as an HTTP error. The POST returned 201; the failure arrives as the terminal stream event run.failed and as errorCode on the assistant message in the message list. Branch on that code.
| Code | Where you read it | Meaning |
|---|---|---|
financial_execution_input_exceeds_capacity | run.failed payload.code; errorCode on the failed assistant message | The message is larger than the context window of the model chosen for it. payload.capacity holds requiredInputTokens, contextWindowTokens and modelId. See Long messages and model capacity. |
RATE_LIMITED (429)
Returned when the endpoint's limit is exceeded. See Rate Limiting for the limits. The response carries the wait both in the body and in the Retry-After, X-RateLimit-Limit and X-RateLimit-Remaining headers:
{
"error": {
"code": "RATE_LIMITED",
"message": "Too many attempts. Please wait before trying again.",
"details": {
"retryAfterSeconds": 300
}
},
"meta": {}
}The message varies by endpoint (for example Rate limit exceeded); rely on code and Retry-After.
Idempotency errors (428, 409)
A mutating request without an Idempotency-Key:
{
"error": {
"code": "missing_idempotency_key",
"message": "Missing Idempotency-Key header"
},
"meta": {
"requestId": "5a118343-0bd8-49cb-85b4-963be4eeca2c"
}
}The same key reused with a different request body returns 409:
{
"error": {
"code": "idempotency_key_reused_with_different_payload",
"message": "Idempotency key already used with a different request payload"
},
"meta": {
"requestId": "c8e0468b-2877-4478-baf5-0de923d203a7"
}
}internal_server_error (500)
Returned when an unexpected server error occurs. In production the message is always Internal Server Error and no details are returned:
{
"error": {
"code": "internal_server_error",
"message": "Internal Server Error"
},
"meta": {
"requestId": "<request id>"
}
}When reporting an internal error, include the requestId from meta (or the X-Request-Id header) -- it helps the support team locate the relevant logs.