tools / HTTP reference / http 422 unprocessable entity (validation errors)
HTTP · RFC 4918 §11.2 (originally WebDAV)

422 Unprocessable Entity

422 means 'I understood the request and the syntax is correct, but the semantics fail validation'. Distinguishes validation errors from malformed requests (400).

intermediate RFC 4918 §11.2 (originally WebDAV)

What the RFC says

The 422 Unprocessable Entity status code means the server understands the content type of the request entity (hence a 415 status code is inappropriate), and the syntax of the request entity is correct (hence a 400 status code is inappropriate) but was unable to process the contained instructions. (RFC 4918 §11.2) — RFC 4918 §11.2 (originally WebDAV)

Example

POST /api/users HTTP/1.1
Content-Type: application/json

{"email": "not-an-email", "age": -5}

HTTP/1.1 422 Unprocessable Entity
Content-Type: application/problem+json

{
  "type": "https://example.com/probs/validation",
  "title": "Validation failed",
  "errors": [
    {"field": "email", "detail": "Invalid email format"},
    {"field": "age", "detail": "Must be >= 0"}
  ]
}

Real-world implementations

Common misuses (don't do this)

Use cases

Get the RFC reference for any HTTP response
httpwut takes a curl response and explains the status code + headers + the RFC sections you should actually read. Built for HTTP debugging that goes deeper than 'lol 500'.
Open httpwut  

Related HTTP topics

content-security-policy (csp) header · content-security-policy (csp) header · content-security-policy (csp) header · content-security-policy (csp) header · ↗ JSON Schema validation patterns