More
More
422 Unprocessable Content
The request is well formed but its data fails validation.
- Code
422- Reason phrase
- Unprocessable Content
- Class
- 4xx Client error
- Defined in
- RFC 9110 section 15.5.21
- Cacheable by default
- No
What it means
Client error: the problem lies with the request. Repeating it unchanged will normally fail again.
When a server should send it. When the request is syntactically fine and of a type the server accepts, but the data inside fails validation: an invalid email address, a negative quantity, a missing required field. List the problems in the body, ideally per field.
Common causes. An invalid email address, a missing required field or a value outside the allowed range in an API call.
What to do. Read the error details in the response body and correct the data.
How clients and crawlers treat it
Browsers and HTTP clients. Browsers show the body. API clients and form libraries map the listed errors back to fields. Some frameworks (Rails, Laravel) use 422 by default for validation errors.
Google Search. Like every 4xx except 429, it tells Google the content does not exist: an indexed URL is removed from the index, and a new one is not processed. Crawl frequency for the URL gradually drops. Source: Google Search Central, How HTTP status codes, and network and DNS errors affect Google Search.
Caching. Not cacheable by default (RFC 9110 section 15.1 does not list it). A cache stores it only when the response says so with Cache-Control or Expires.
Example response
HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json
{"status": 422, "title": "Unprocessable Content"}
How to send 422
location /example {
return 422;
}
RewriteEngine On RewriteRule ^example$ - [R=422,L]
http_response_code(422); echo 'Unprocessable Content'; exit;
res.writeHead(422, { 'Content-Type': 'text/plain' });
res.end('Unprocessable Content');
# in a view function return 'Unprocessable Content', 422
Change the paths to suit. In nginx, add_header needs always to apply to error responses.
Related codes
- 400Bad RequestThe server could not understand the request.
- 409ConflictThe request conflicts with the current state of the resource.
- 415Unsupported Media TypeThe server does not accept the format of the request body.
All status codes · All 4xx codes
Names and numbers from the IANA HTTP Status Code Registry. Google Search behaviour as documented by Google Search Central.