REFERENCE
HTTP status codes
Thirty-four codes worth knowing, searchable by number or meaning.
Search the table
Try 404, "rate limit", "auth" or "gateway".
| Code | Name | Meaning |
|---|
The five classes
1xx is informational and rarely seen in application code. 2xx means success. 3xx means the client must take another step, usually a redirect or a cache validation. 4xx means the request is wrong: bad syntax, missing authentication, no permission, no such resource. 5xx means the server failed to do something it should have been able to do.
401 and 403 are not interchangeable
401 says "I do not know who you are" and should include a challenge. 403 says "I know who you are, and you may not do this". Returning 403 for an expired token hides the fact that the client should re-authenticate; returning 401 for a permissions problem sends the client into a login loop.
Retry semantics
429 and 503 are the codes that usually invite a retry, ideally with the Retry-After header and exponential backoff. 500 may be transient, but retrying a non-idempotent POST can duplicate the side effect. 502 and 504 point at an upstream server or proxy, not at the client.
Questions
What is the difference between 404 and 410?
404 means not found now; 410 means gone permanently. Search engines may remove a 410 URL faster, but both are client errors.
Is 418 a real code?
It is a real registered code from an April Fools' RFC, and some servers return it deliberately. Treat it as a joke, not a protocol.
Should an API return 200 with an error body?
Usually no. Use the status code for the outcome and the body for detail. A 200 with "error": true breaks clients, caches and monitoring.
What does 422 mean?
The request was syntactically valid but failed semantic validation — for example, a well-formed JSON body with an invalid date.