REST API Status Code Chooser
Pick the request outcome and this tool suggests the status code a REST API should return.
REST API status code rules
- Use precise 2xx responses instead of returning 200 for every successful request.
- Use 401 for authentication problems and 403 for authorization problems.
- Use 404 when the resource is missing or you do not want to reveal whether it exists.
- Use 409 for state conflicts, 422 for valid requests with invalid domain data, and 429 for rate limits.
- Use 500 only when no more specific 5xx response describes the server-side failure.
Common questions
Should validation errors use 400 or 422?
Use 400 when the request is malformed. Use 422 when the request shape is valid but the submitted domain data cannot be processed.
Should missing authentication use 401 or 403?
Use 401 when the caller is not authenticated. Use 403 when the caller is authenticated but still not allowed.