What a 422 Unprocessable Entity means
422 in APIs and frameworks, and 422 vs 400
RFC 9110, the current HTTP standard, renamed 422 to Unprocessable Content and moved it from the WebDAV spec into core HTTP. Both names mean the same thing, and you will see either in error messages.
Which code you get for bad input depends on the framework behind the API:
- FastAPI returns 422 when the request body, query, or path parameters don't match the declared types. The response lists each failing field under
detail. - Ruby on Rails uses 422 for failed model validations (
:unprocessable_entity, and:unprocessable_contentin newer versions). - Laravel returns 422 with an
errorsobject when validation fails on a JSON request. - Django REST Framework returns 400 for the same kind of validation failure.
If you build the API: use 400 when the request can't be parsed at all (broken JSON, wrong content type) and 422 when it parses but the values break your rules. Return the field name and the reason for each failure so the client can fix it without guessing.
