HTTP Status Codes

The first digit tells the story: 2 success · 3 redirect · 4 your fault · 5 their fault.

2xx — Success

200  OK — the standard "here's your response"
201  Created — a new resource was made (check the Location header)
204  No Content — success, deliberately empty body (e.g. DELETE)

3xx — Redirection

301  Moved Permanently — update your bookmarks; SEO value transfers
302  Found — temporary redirect
304  Not Modified — your cached copy is still fresh (saves bandwidth)

4xx — Client error (your fault)

400  Bad Request — malformed syntax or invalid parameters
401  Unauthorized — missing/invalid credentials (log in first)
403  Forbidden — authenticated, but not allowed
404  Not Found — the resource doesn't exist (check the URL)
405  Method Not Allowed — e.g. POST to a GET-only endpoint
409  Conflict — clashes with current state (e.g. duplicate key)
418  I'm a teapot — an April Fools' joke that became tradition
422  Unprocessable Content — valid syntax, semantically wrong
429  Too Many Requests — slow down; respect Retry-After

5xx — Server error (their fault)

500  Internal Server Error — something broke on their side
502  Bad Gateway — upstream server gave an invalid response
503  Service Unavailable — overloaded or down for maintenance
504  Gateway 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.