Which HTTP Error Code Should I Return?
Use this decision tree to select the correct HTTP error status code for your API or web application. Answer a series of yes/no questions about the nature of the request and what went wrong. Covers all common client errors (4xx) and server errors (5xx).
Decision Steps
Is the request itself syntactically malformed or missing required fields?
Does the endpoint require authentication and the request provides no credentials (or clearly invalid ones)?
Are the credentials valid but the user lacks permission to access this resource?
Does the requested resource not exist?
Does the resource exist but the HTTP method (e.g., DELETE, PUT) is not supported on it?
Would the request cause a conflict with the current state of the resource (e.g., duplicate entry, edit conflict)?
Is the request well-formed but contains semantic validation errors (e.g., invalid field values, business rule violations)?
Has the client exceeded a rate limit or quota?
Did an unexpected error occur inside your server (bug, unhandled exception)?