422 Unprocessable Content

Free

The syntax is fine but the content is semantically wrong.

What it means

The right code for a validation failure on a well-formed request: valid JSON, correct types, but the email is already taken or the end date precedes the start. 400 says 'I could not read this'; 422 says 'I read it and it is wrong'.

Class
4xx Client error
Defined in
RFC 9110 §15.5.21
Cached by default
No

When you receive a 422

  • The server read your request fine and rejected a value in it. The body should list the fields and the reasons.
  • Fix the values, not the format - sending the same data again fails the same way.
  • Older documentation calls it 422 Unprocessable Entity. It is the same code.

When you send a 422

  • For validation failures on a request that parsed correctly.
  • Return every failing field at once, not just the first, so the client can fix them in one round trip.
  • Use 400 when you could not parse the request at all.

On the wire

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

{"title": "Validation failed", "errors": [{"field": "endDate", "detail": "must be after startDate"}]}

Often confused with