Status and Signal: Maintaining Semantic Integrity in REST APIs
HTTP status codes are the metadata of the web. They tell the browser, the proxy, and the load balancer how to handle a response without reading the payload.
The Great Classes
- 2xx (Success): Transaction completed.
- 3xx (Redirection): The resource has moved.
- 4xx (Client Error): You sent a bad request (e.g., 401 Unauthorized, 429 Too Many Requests).
- 5xx (Server Error): We have a problem (e.g., 502 Bad Gateway).
The Sin of Generic 200s
Returning an error message inside a "200 OK" response is a violation of the protocol. It breaks automatic retry logic and prevents CDNs from caching appropriate responses.
The 418 Teapot Ritual
Understanding even the obscure codes (like 422 Unprocessable Entity) allows you to build APIs that are self-documenting. Use our Status Code Reference to audit your API designs and ensure your signals match your data.