Skip to content

Errors

One error envelope, stable codes, and what to do about each.

Every failing API response uses the same shape. Branch on code, which is stable, rather than on message, which is written for humans and may change.

Error response
{
  "error": {
    "code": "validation_error",
    "message": "Validation failed",
    "details": { "messages": ["Array must contain at least 1 element(s)"] }
  }
}

Codes

CodeStatusWhat to do
bad_request400The request was malformed, for example invalid JSON. Fix and retry.
unauthorized401Authenticate. Check the key was not revoked.
forbidden403The credential is valid but not allowed to do this.
not_found404No such resource in this workspace.
conflict409The write collided with an existing record, such as a duplicate email.
validation_error422Read details for the offending fields.
rate_limited429Back off and retry; the message says for how long.
unavailable503A dependency is down. Retry with backoff.
internal_error500Something broke on our side. Safe to retry once.

Errors mid-stream

A request that has already returned 200 cannot change its status. If generation fails after the stream opens, an error event arrives inside the stream, followed by done with finishReason: "error".