Errors
Every failure answers with a JSON object holding adetail field:
detail is a string on almost every route, and is written to be shown to a person as
it stands. A few routes answer with an object instead, carrying a machine-readable code
alongside the sentence: OAuth, parts of style, and
the compile refusals below. Each documents its own codes. A client that prints detail
should expect either, and the key carrying the code is not the same on all of them:
“erroron some,error_code` on the compile refusals.
The reference code
Adetail ending in Reference <12 hex characters> means we logged that exact
request against that code, together with the real exception and its traceback.
Quote the reference when you report a failure.
It is a label, not a token. There is nothing to look up with it, it is not something
to retry with, and the same request sent twice produces two different references.
Status codes
404 where you might expect 403
A face, group or API key that exists but that you cannot read answers 404, not 403. These routes give the same answer for “never existed” and
“not yours”, so a 404 is not evidence that something has been deleted.
A document or thread route whose path holds something that is not an id at all is a
404 too, and says so:
403, where you get one, names a restriction on your credentials rather than a
missing thing: a plan limit, an admin-only route, a key confined to particular faces
and models, or a face you may not act on.
A wrong current password on PATCH /auth/me or /auth/change-password is also a
403.
422: a model in an old form
Every endpoint takes one model: the upstream model (a face and its maestro), and on chat and
decisions the downstream model after a /. A plain model, face@model, a bare face,
owner:alias, view, style and the other removed forms are each a 422 whose detail shows
the form to use, and nothing is charged:
POST /v1/causes is removed and always answers
422.
Rate limits
Every route that runs a model or a compile counts against one per-account, per-minute limit set by plan:/v1/choices, the chat endpoints, /v1/decisions, /v1/systemone,
and both compile /make routes. All of
an account’s keys share the count. Read the limits from
GET /v1/rates limits.requests_per_minute rather
than hard-coding them. Billing routes have their own, smaller limits.
Over the limit is a 429 with a Retry-After header, in seconds:
Closed accounts
Once an account is closed (DELETE /v1/account), its JWTs answer 401 on every route,
/auth/refresh included:
401 as any revoked key does.
422, not 500, for a value a field cannot hold
A value too long or too large for the field it lands in is a bad request, and is
answered as one. Where the limit is declared on the request, the message names the
field and the number:
→, and a request with more than one
problem reports all of them in the same string, separated by ; .
Where it is not declared, the answer is still a 422, but it can only say which kind
of value was at fault:
422 as
final.
A 400 that names the rule
POST /v1/compile/documents/{id}/make and its thread twin refuse a source that cannot
be compiled, and the refusal carries a short stable code:
compile_blocked_reason. The
codes, and what to do about each, are in
Can this be compiled at all?.
Treat a code you do not recognise as “cannot be compiled”; the set will grow.
503 is the retry
A 503 names what was busy and asks you to try again (the database on a data route,
the payment service on a billing one).
The other 5xx codes mean the opposite. A 500 is worth one attempt and then a report, not a loop.