Every error response has the same envelope. Branch on error; message is for people and may change.
Some codes add fields next to error and message. They are listed in the Extra fields column. Where it helps, an error also carries hint (what to do, in one sentence) and docs_url — they are not repeated in the tables below. For what to do about each status — retries, backoff, the 402 body — see Errors.
Validation has two codes: validation_error (400) for a request that is malformed, and validation_failed (422) for a well-formed request that cannot be applied. Check the status together with the code.

400 Bad Request

401 Unauthorized

402 Payment Required

403 Forbidden

404 Not Found

409 Conflict

413 Payload Too Large

422 Unprocessable

429 Too Many Requests

500 Internal Server Error

503 Service Unavailable

502, 503 and 504 without a code

A request can also end in 502, 503 or 504 when the API could not be reached or did not answer in time. Such an answer may have no JSON body and no error code. Treat it like a 500: the request was not necessarily carried out, so send it again with backoff — see Errors.

Idempotent replays

A request repeated with the same Idempotency-Key and body returns the stored response of the first attempt with the header Idempotent-Replayed: true. Only successful (2xx) responses are stored: an error is never replayed, and a request rejected with a 4xx frees its key. A request that ended in a 5xx or never finished does not free its key. On POST /v1/messages, POST /v1/billing/topup, POST /v1/events, POST /v1/contacts/{id}/consent and POST /v1/contacts/consent/bulk a retry with the same key runs again and finds what the first attempt did. On every other route the key answers 409 conflict with original_status until it expires after 24 hours — see Idempotency.