The five classes

ClassMeaningTypical use
1xxInformationalProtocol switching, early hints, continue
2xxSuccessThe request was understood and accepted
3xxRedirectionThe client must take further action
4xxClient errorThe request is invalid, unauthorized or impossible
5xxServer errorThe server failed to fulfill a valid request

Codes people actually use

Most APIs live on a small set: 200, 201, 204, 301, 304, 400, 401, 403, 404, 409, 422, 429, 500, 502, 503. The rest exist for specific protocol features and are rarely seen outside them.

  • 409 Conflict — uniqueness or state conflict, common in REST APIs.
  • 422 Unprocessable Content — valid syntax, invalid semantics (popularized by Rails).
  • 428 Precondition Required — forces conditional requests to avoid lost updates.
  • 451 Unavailable For Legal Reasons — blocked by legal demand, not by the server.

Rules of thumb

  • Use the most specific code that still tells the client what to do next.
  • Do not return 200 with {"error": ...}; it breaks monitoring and client libraries.
  • 4xx means the client should change the request; 5xx means retrying may help (with backoff).
  • Include a machine-readable error body, ideally application/problem+json (RFC 9457).