What does HTTP status code 422 mean?
The 422 Unprocessable Entity status code indicates that the server understands the content type and syntax of the request, but cannot process the contained instructions due to semantic validation failures.
When to use it in APIs
The primary status code for input validation failures. Use 422 when required fields are missing, strings fail regex constraints, or numbers fall out of range.
How it compares to other codes
- 400 Bad Request: Use 400 when the JSON is malformed and cannot be parsed. Use 422 when the JSON parses successfully but has validation errors.