Docs / Errors
Errors
Every status the API answers, the exact body it carries, and the two shapes an error body can take.
One rule
Branch on the HTTP status code, not on the body text. There are only two body shapes and both put everything under detail.
The envelope
{"detail": "limit must be between 1 and 200"}{"detail": {"error": "quota_exceeded", "detail": "...", "quota": 1, "used": 2, "resets_at": "..."}}Statuses documented in the contract
| Status | Documented causes |
|---|---|
400 | 14 |
401 | 1 |
404 | 5 |
405 | 1 |
409 | 1 |
410 | 1 |
429 | 1 |
501 | 1 |
503 | 3 |
Counted from the table in docs/API.md §8 on every build, so a status added to the contract appears here.
Every status, with its cause and body
Source: docs/API.md §8.
Success bodies vary by route. Error bodies have two shapes, both under detail:
{"detail": "limit must be between 1 and 200"}{"detail": {"error": "quota_exceeded", "detail": "...", "quota": 1, "used": 2, "resets_at": "..."}}The second shape occurs only for 429. Branch on the HTTP status code, not on the text: detail strings are stable in wording but written for humans and logs.
| Status | Cause | Verified detail |
|---|---|---|
400 | limit out of range (items) | limit must be between 1 and 200 |
400 | limit below range (related) | limit must be between 1 and 50 |
400 | limit not an integer | limit must be an integer |
400 | bad category | category must be one of: markets, macro, commodities, fx, crypto, central_banks, corporate, energy |
400 | malformed locale tag | locale is not a well-formed locale tag |
400 | bad since / until | since is not a valid RFC3339 timestamp: 'bad' |
400 | inverted range | since must not be later than until |
400 | bad min_importance | min_importance must be <= 1.0 (and >= 0.0, must be a number, must be a finite number) |
400 | bad cursor | cursor is not valid base64url JSON |
400 | stale/reused search cursor | cursor was issued for a different query / cursor is stale: the index changed since it was issued; start from the first page |
400 | search q too short | q must be at least 2 characters |
400 | search q too long | q must be at most 256 characters |
400 | edition day shape | day must be a UTC date in YYYY-MM-DD form, got '11-11-04' |
400 | bad month | month must be a YYYY-MM string |
401 | auth (see §3.5) | invalid or missing bearer token / invalid admin token |
404 | unknown item or a withheld one | item not found |
410 | an id a duplicate migration retired (see §8b) | object shape {"error": "duplicate_superseded", "survivor_id": …, "survivor_url": …} |
404 | unknown image key | image not found |
404 | unknown run id | run not found |
404 | edition day with no publishable items | no digest for locale 'en' on 1999-01-01 |
404 | locale that has never published | no digest for locale 'de': no published items |
405 | HEAD on a GET-only route; a bare OPTIONS with no Access-Control-Request-Method (a real preflight on /v1/site/* answers 200, §5a) | {"detail":"Method Not Allowed"} |
409 | refresh already running | a refresh is already running |
429 | quota exhausted | object shape above |
501 | /v1/usage, /v1/usage/history on a non-database key | usage reporting requires a database-issued key; ... |
503 | store unreadable (/v1/health only) | body is the degraded health object, not a detail |
503 | SQLite build without FTS5 (/v1/search only) | keyword search is unavailable: this SQLite build has no FTS5 support |
503 | admin token not configured | refresh is disabled: NEWS_ADMIN_TOKEN is not configured / admin usage is disabled: ... / operator routes are disabled: NEWS_ADMIN_TOKEN is not configured |
Note the 405: a HEAD /v1/feed/en is rejected (measured). An OPTIONS request is also 405 unless CORS is configured and the request carries an allowed Origin. Use GET even for a reachability probe; /v1/health is the cheapest one and needs no auth.