Status codes · 1xx–5xx
Status code families and error semantics
Success, redirects and errors require different handling.
Understand the concept
1xx indicates interim information, 2xx success, 3xx redirects or conditional-cache outcomes, 4xx request-related problems and 5xx server failure. 201 means creation, 202 accepted but not completed work, and 204 success without content. Acceptance does not guarantee eventual success.
Common distinctions include malformed requests, missing valid authentication, forbidden access, missing resources, state conflicts and unsupported media types. A 401 response should be designed with the authentication challenge contract.
502, 503 and 504 describe different gateway or availability failures. Returning 200 for every error obscures monitoring and client behaviour. Never expose stack traces or secrets in public error bodies.
Build useful client handling and monitoring rules.
Treating 401 and 403 as the same login failure.
One topic. Three levels of depth.
HTTP/1.1 201 Created
Location: /orders/123Identifies the newly created resource.
This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.
Try it yourself first.
Should a 204 response contain a JSON body?
Show the solution and explanation
204 = no response contentNo. Clients should not expect content; use an appropriate other success response for JSON.