422 Unprocessable Content

The request is syntactically valid but semantically wrong, so the server cannot act on it.

Status

HTTP/1.1 422 Unprocessable Content

Details

422 draws the line between parsing and meaning. The JSON parsed, the fields are the right types, and the server still cannot process it: an end date before a start date, a quantity below the minimum, a reference to a record that does not exist.

It began as a WebDAV code and was folded into the core HTTP semantics spec in RFC 9110. It is now the conventional validation-failure code for JSON APIs, and the response body should enumerate the specific failures rather than reporting one at a time.

Note: Use 400 for input that does not parse and 422 for input that parses but fails validation. Mixing the two makes client error handling guesswork.

Common causes

How to fix it

As the client

As the server

Examples

A well-formed body that fails validation

A body that parses cleanly but breaks a validation rule:

HTTP request

POST /api/v2/order HTTP/1.1
Host: api.example.com
Content-Type: application/json

{"product_id":"isp-us","quantity":0}

The server reports the failing field rather than a generic parse error:

HTTP response

HTTP/1.1 422 Unprocessable Content
Content-Type: application/json; charset=utf-8

{"errors":[{"field":"quantity","rule":"min","min":1}]}

Specifications

See also