Back to httpstatuses.net

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

HTTP status codes and JSON error bodies

Use the HTTP status code for the generic result that clients, proxies, logs, caches, and monitoring tools can understand. Use the response body for your application-specific details.

For example, a duplicate email should usually be a 409 Conflict or 422 Unprocessable Entity response with a JSON body that explains the field error. Returning 200 OK with {"status":"error"} makes generic HTTP tooling treat the request as a success.

When the API needs a standard error format, follow the RFC 9457 Problem Details guide and return application/problem+json.

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 needs valid authentication. Use 403 when the caller is authenticated and lacks permission.

Should an API return 200 with a status field for errors?

No. Return the most accurate HTTP status code first. Then include a response body with the error code, field details, or problem information your client needs.


HTTP status code lookup
REST API status code chooser
cURL command generator
By Ping Now, a website/API/service uptime monitor
Data from Wikipedia