Error codes
Every failure the API can return, with its stable code and HTTP status. Errors are part of the contract, not an afterthought.
The envelope
Success and failure share one shape. On success data carries the payload and error is null; on failure data is null and error carries a stable code plus a human-readable message.
Error envelope
{
"data": null,
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests. Retry after 30 seconds."
}
}The HTTP status mirrors the error: you can read it from the status line, but branch on the code. Statuses can shift as the API evolves; codes do not.
Error codes
| Code | HTTP | Meaning |
|---|---|---|
RATE_LIMITED | 429 | Too many requests in the current window. Retry after the interval in the Retry-After header. |
CSRF_ORIGIN_MISMATCH | 403 | A browser request arrived from an origin that is not allowlisted for the caller. Server-to-server calls are not affected. |
UNAUTHENTICATED | 401 | No token was sent, or the token is missing, malformed or expired. Re-authenticate before retrying; retrying as-is will never succeed. |
FORBIDDEN | 403 | The token is valid, but the caller's role does not permit the operation. Retry with an account that has the required role. |
VALIDATION_ERROR | 422 | The request body or query parameters failed validation. The message names the field that was rejected. |
NOT_FOUND | 404 | The resource does not exist, or it exists in a workspace the caller cannot see. The API does not distinguish the two. |
BUDGET_EXCEEDED | 402 | The workspace has exhausted its AI generation budget for the billing period. Generation resumes when the budget resets or is raised. |
PAID_AI_DISABLED | 503 | AI generation is temporarily disabled. The platform is up; generation specifically is not. Retry later. |
INTERNAL | 500 | An unexpected server error. Safe to retry once; if it persists, report it with the request time and route. |
Using codes in practice
UNAUTHENTICATEDmeans re-authenticate;FORBIDDENmeans stop retrying with these credentials. Confusing the two turns a clean failure into a retry storm.RATE_LIMITEDis the only error that comes with a server-specified wait; honorRetry-Afterinstead of guessing.BUDGET_EXCEEDEDandPAID_AI_DISABLEDboth mean “not now” for generation, but only the first is under your control — the second is a platform condition.NOT_FOUNDnever reveals whether a resource exists outside your reach, which is the intended behavior. Treat a surprising 404 as a permissions question first.