HTTP status codes

A status code is the server's summary of the outcome of a request, in a form a program can act on without reading the body. The first digit is the class: 2xx succeeded, 3xx means look elsewhere, 4xx means the request was wrong, 5xx means the server failed. The remaining digits refine the meaning within that class.

How it works

Clients branch on the class first and the exact code second: a 2xx is processed, a 3xx is followed, a 4xx is reported back to whoever built the request, and a 5xx may be retried if the request was idempotent. Specific codes then carry specific instructions — 401 means authenticate, 429 means slow down, 412 means re-read before writing.

The misconception

That the body is the real answer and the code is decoration. Caches, proxies, retry logic, monitoring and browsers all act on the status line without reading the body; an API that returns 200 with {"error": …} is invisible to every one of them, and so is its failure rate.

Try it here

The status code index links one page per code this playground returns, each with endpoints that produce it. GET /faults/v1/status/{code} returns any code from 200 to 599 on request.

Sources

Other terms

All glossary terms · Testing techniques · All 39 mock REST APIs

Last updated