Error codes
Every status the API returns and what to do about it.
| Status | Body | Action |
|---|---|---|
200 | Image bytes | None |
400 | bad json | Fix the request body |
401 | unauthorized | Check the bearer token |
402 | payment_required + buy_url | No live plan and no credits: buy from the link |
403 | forbidden | Account suspended — contact support |
404 | unknown jurisdiction | Use a 2-letter US state or DC |
422 | validation failed + details | Read details, fix each |
429 | rate limited | Back off per Retry-After |
500 | internal | Retry once, then report |
503 | busy + Retry-After: 1 | Database busy: retry with backoff. The write lock is held by another request |
422 detail format
Validation returns every failure at once so a form can highlight all of them in one pass.
{
"error": "validation failed",
"details": [
"DAK does not match ^[0-9]{5}([0-9]{4})?$",
"DBC must be one of ['1', '2', '9']"
]
}Why 422 is not a 400
A 400 means the request could not be read: malformed JSON, wrong content type, an empty
body. A 422 means the request was read and the values did not satisfy the rules. The
distinction matters because the fixes are different. Re-sending a 400 with the same body
is pointless, and re-sending a 422 without changing a field is equally pointless, but a
422 tells you exactly which field to change in details.
Unknown element IDs are also 422. Sending dl instead of DAQ is
read as an unknown element, not as a synonym, because the element registry is closed.
That strictness is deliberate: silently dropping an unrecognised key would produce a
symbol missing a value the caller believed was included.
Retry policy
Retry 500 and 503 with exponential backoff starting at 1s, capped at 30s, three attempts. A 402 is not retryable: it means no live plan and no credits, so retrying will not help until the account is topped up. The same applies to every other 4xx — the request will fail identically.
Retry-After exactly. Hammering through a 429 extends the window.
Reporting
Send the request ID from the X-Request-Id response header to @VALIDPDF417. Without it the incident cannot be traced.
Include the state, the error correction level and the decoded payload. Those three let the request be reproduced without the original key, which is what makes an incident fixable rather than merely reportable. Never paste a full key into the message: the prefix is enough to identify it.