400
Bad Request
RFC 9110 §15.5.1The server cannot process the request because it is malformed — bad syntax, invalid framing, or otherwise something the client got wrong.
- When to use
- Return when the request itself is invalid at a structural level and the client must change it before retrying.
- How to handle
- Check request syntax, headers, and payload structure; fix the malformed part and resend.
401
Unauthorized
RFC 9110 §15.5.2Unauthenticated — the request lacks valid credentials (the name is misleading; it means authentication is missing or wrong, not authorization). Typically paired with a WWW-Authenticate header describing how to authenticate.
- When to use
- Return when the client must authenticate (or re-authenticate) to proceed; contrast with 403, where valid credentials still are not permitted.
- How to handle
- Send valid credentials (e.g. a correct Authorization header / token) as indicated by the WWW-Authenticate header.
403
Forbidden
RFC 9110 §15.5.4Authenticated (or authentication is irrelevant) but the request is not allowed — the client is identified yet lacks permission. Re-authenticating will not help.
- When to use
- Return when the caller is known but not permitted; contrast with 401, where the fix is to provide credentials.
- How to handle
- Request the required permissions/role, or access a resource you are allowed to; re-sending credentials will not change the outcome.
404
Not Found
RFC 9110 §15.5.5The server has no representation for the target resource and does not disclose whether it ever existed. May be used to hide the existence of a resource from unauthorized clients.
- When to use
- Return when the requested URL does not map to any resource.
- How to handle
- Verify the URL/path is correct and the resource exists; check for typos or a moved resource.
405
Method Not Allowed
RFC 9110 §15.5.6The HTTP method is not supported for this resource. The response must include an Allow header listing the methods that are supported.
- When to use
- Return when the URL exists but the method (e.g. DELETE on a read-only resource) is not allowed.
- How to handle
- Use one of the methods listed in the response Allow header.
409
Conflict
RFC 9110 §15.5.10The request conflicts with the current state of the resource — e.g. an edit against a stale version, or a duplicate that violates a uniqueness constraint.
- When to use
- Return for optimistic-concurrency conflicts or state conflicts the client can resolve and retry.
- How to handle
- Fetch the current state, reconcile the conflict, and resubmit.
410
Gone
RFC 9110 §15.5.11The resource was intentionally and permanently removed and no forwarding address exists. Stronger than 404 — it asserts the resource is gone for good, and search engines should de-index it.
- When to use
- Return when a resource has been deliberately removed permanently and you want caches/crawlers to stop requesting it.
418
I'm a teapot
UnofficialRFC 2324The server refuses to brew coffee because it is, permanently, a teapot. An April Fools' joke from the Hyper Text Coffee Pot Control Protocol — not a real HTTP status, kept alive as an Easter egg.
- When to use
- Not for production use; occasionally returned as a playful placeholder or to reject unwanted requests humorously.
422
Unprocessable Content
RFC 9110 §15.5.21The request was well-formed (syntax is valid) but is semantically invalid — the server understood it but cannot process the contained instructions. RFC 9110 renamed this from 'Unprocessable Entity'.
- When to use
- Return for REST/JSON validation errors — e.g. a syntactically valid body that fails business/field validation.
- How to handle
- Fix the invalid field values described in the error body and resubmit.
429
Too Many Requests
RFC 6585 §4The client has sent too many requests in a given time (rate limiting). The response may include a Retry-After header telling the client when to try again.
- When to use
- Return when a client exceeds a rate limit or quota.
- How to handle
- Slow down and respect the Retry-After header before retrying; add backoff to the client.
451
Unavailable For Legal Reasons
RFC 7725The resource is unavailable because of a legal demand — e.g. a court order or government censorship. The number references Ray Bradbury's Fahrenheit 451.
- When to use
- Return when access is denied for legal reasons; the response should explain the legal demand where possible.