error.code, and branch on it. The
human message is for display and logging only — never parse it, because the
wording can change.
The error object
Request IDs
Every response — success or error — includes anX-Request-Id header (for example
req_4f3c…). On errors it’s also in the body as error.request_id. Log it on your
side, and include it when you contact support so we can find the exact request fast.
Catch errors
Check for a non-2xx status, readerror.code, and decide what to do.
Error types
type groups errors by what generally went wrong, so you can pick a broad response
without listing every code. For the specific reason, use code.
Handle rate limits
When you getrate_limit_exceeded (429), wait and retry. Prefer the Retry-After
header when it’s present; otherwise back off exponentially.
Handle transient errors
internal_error (500) and UPSTREAM_PROVIDER_ERROR (502) are usually temporary and
not a problem with your request. Retry with exponential backoff. For writes, retry
the same request rather than creating a new one, so you don’t duplicate work.
For anything in the invalid_request_error family, do not blindly retry — the
request needs to change first. Use code and param to fix it.
Next steps
See the full Error codes reference for everycode, what it means, and
how to resolve it. Each error’s doc_url links straight to its entry there.