Choosing the Right HTTP Status Code
Selecting the right status code improves client behavior, caching efficiency, SEO, and observability. Pick the status class flowchart TD A[Request handled successfully] A -->|Yes| S[2xx] A -->|No| Q{Client problem} Q -->|Yes| C[4xx] Q -->|No| E[5xx] 2xx: the server accepted and completed the request. 4xx: the request is invalid or not allowed. 5xx: the server or an upstream failed to process a valid request. Success details: 200 vs 201 vs 202 vs 204 flowchart TD S[2xx] --> K{Created new resource} K -->|Yes| C201[201 Created] K -->|No| P{Processing deferred} P -->|Yes| C202[202 Accepted] P -->|No| B{Response body present} B -->|Yes| C200[200 OK] B -->|No| C204[204 No Content] 201 Created: the request created one or more resources. Location can identify the primary resource; otherwise, the target URI identifies it. 202 Accepted: processing has not finished and might not occur. Describe the current status and provide a status monitor when available. 200 OK: the request succeeded. The meaning of its content depends on the request method, and the content can have zero length. 204 No Content: the action succeeded and there is no additional content or trailers to send. The flowchart is a starting point, not a complete account of method semantics. A successful response with no content is not automatically a 204. ...