Unprocessable Entity
4xx Client Error
Last updated:
The request is well-formed but contains semantic errors and cannot be processed.
Description
The best fit for domain-level validation errors: the JSON parsed fine, the required fields are present, but the values violate business rules (e.g. 'age' is negative, or 'end_date' is before 'start_date').
When to use
Return 422 for validation errors instead of 400 to distinguish semantic issues from syntactic issues.
Specification
RFC 9110 §15.5.21
Examples
HTTP response
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json
{"error":"Unprocessable Entity"}Node.js (Express)
res.status(422).json({ error: "Unprocessable Entity" });Go (net/http)
w.WriteHeader(http.StatusUnprocessableEntity)
Python (Flask)
return jsonify({"error": "Unprocessable Entity"}), 422Related status codes
All 4xx codes
400 Bad Request401 Unauthorized403 Forbidden404 Not Found405 Method Not Allowed406 Not Acceptable408 Request Timeout409 Conflict410 Gone411 Length Required412 Precondition Failed413 Payload Too Large414 URI Too Long415 Unsupported Media Type418 I'm a teapot422 Unprocessable Entity425 Too Early428 Precondition Required429 Too Many Requests431 Request Header Fields Too Large451 Unavailable For Legal Reasons