Skip to main content

The error envelope

string
required
What went wrong, as a fixed word your code can branch on. Codes are part of v1 and do not change.
string
required
A sentence for a person, saying what to change. Log it and show it; do not parse it, except where this page says so.
string
On some validation errors, the parameter or body field that caused it. A request that fails the basic checks on its shape (a value too long or of the wrong type, an unknown parameter or body key, a limit over the maximum) is also 400 validation, but carries no field: the message names what to fix.
object
On a conflict or a plan_limit, the facts behind the refusal: the existing prompt’s id, the limit and how much of it is used, and so on. Its keys are snake_case.

Codes

A path under /v1/ that is not a route at all is also 404, with the code error. A refusal never tells you more than you could already see: an id in someone else’s workspace is 404, exactly like an id that does not exist, never 403.

Errors worth handling by name

A report over its budget. A report request whose window is too long for the project is 400 validation with field set to from, and a message that starts report_budget: and says the most days this project allows without date as a dimension. Add date to dimensions and page, or shorten the window. A week or month interval too big for one page also starts report_budget:, with field set to interval: use interval=day. A window longer than the most a report may cover even with date starts window_too_large:. See Reports. A cursor from a different query. 400 validation with field set to cursor: the parameters changed between pages. Request the first page again. See Pagination. format where CSV is not offered. Leave format out on those routes: any value there, json included, is 400 validation with field set to format, and the message lists the routes that offer CSV. See CSV output. A duplicate prompt. 409 conflict with detail.existing_prompt_id, when you add a prompt or re-word one: the exact text is already one of your prompts, possibly one you archived or re-worded. Check that prompt’s status before treating it as live. When adding, or re-wording an archived prompt, at the prompt limit the limit is checked first, so the same text is 402 instead. See Writes. A prompt at the plan’s limit. 402 plan_limit with detail.used and detail.limit, and detail.actions naming the two ways out, upgrade and archive.

Rate limits

Budgets, Retry-After, and busy.

Reports

What a report’s budget is, and how to page past it.

Writes

Conflicts, plan limits and retrying safely.

Authentication

Why a key gets 401 or 403.