HTTP Status Codes
The first digit tells the story: 2 success · 3 redirect · 4 your fault · 5 their fault.
2xx — Success
200OK — the standard "here's your response"201Created — a new resource was made (check theLocationheader)204No Content — success, deliberately empty body (e.g. DELETE)
3xx — Redirection
301Moved Permanently — update your bookmarks; SEO value transfers302Found — temporary redirect304Not Modified — your cached copy is still fresh (saves bandwidth)
4xx — Client error (your fault)
400Bad Request — malformed syntax or invalid parameters401Unauthorized — missing/invalid credentials (log in first)403Forbidden — authenticated, but not allowed404Not Found — the resource doesn't exist (check the URL)405Method Not Allowed — e.g. POST to a GET-only endpoint409Conflict — clashes with current state (e.g. duplicate key)418I'm a teapot — an April Fools' joke that became tradition422Unprocessable Content — valid syntax, semantically wrong429Too Many Requests — slow down; respectRetry-After
5xx — Server error (their fault)
500Internal Server Error — something broke on their side502Bad Gateway — upstream server gave an invalid response503Service Unavailable — overloaded or down for maintenance504Gateway Timeout — upstream took too long
Frequently asked questions
401 vs 403 — which is which?
401 = "who are you?" (authenticate first). 403 = "I know who you are, and the answer is no." The names are historical and confusing; memorize the distinction, not the words.
301 vs 302?
301 is permanent — browsers and search engines remember it. 302 is temporary. Using 302 for a permanent move silently hurts SEO.
What should my API return for validation errors?
400 for malformed requests, 422 when the JSON parses but the data is semantically invalid. Include a machine-readable error body either way.