What's the difference?
400vs422
Both are sent by the app. Watch how far the request gets before it is turned away.
- 400The body cannot be parsed. The app stops at once and nothing else is asked.
- 422The body parses. The app checks its contents against the database, and only then says no.
How to tell them apart in 10 seconds
| Clue | 400 | 422 |
|---|---|---|
| What failed | Reading the request: syntax or framing | Judging its contents: values or rules |
| Example | A missing bracket in the JSON | An end date before the start date |
| Who can send it | The app, or a proxy or CDN | Typically only the app |
| What the body says | Often a general parse error | Usually a list of fields and what is wrong with each |
| Retry? | After fixing the request's format | After fixing the values it lists |
What failed
- 400
- Reading the request: syntax or framing
- 422
- Judging its contents: values or rules
Example
- 400
- A missing bracket in the JSON
- 422
- An end date before the start date
Who can send it
- 400
- The app, or a proxy or CDN
- 422
- Typically only the app
What the body says
- 400
- Often a general parse error
- 422
- Usually a list of fields and what is wrong with each
Retry?
- 400
- After fixing the request's format
- 422
- After fixing the values it lists
In short
400 vs 422: the difference
400: the server could not read the request. 422: it read it fine, and the contents are not acceptable.
Both codes say the request is at fault and must be changed before it can succeed. The difference is how far the server got. A 400 Bad Request means it could not make sense of the request as sent: the JSON does not parse, a required part is missing, the framing is broken. A 422 Unprocessable Content means the request was read without trouble and understood, and what it asks for cannot be done: a field has an invalid value, a referenced item does not exist, a rule is broken. Parsing fails with 400; validation fails with 422. That is the line in the standard. In practice many APIs use 400 for both, and that is acceptable as long as the response explains what to fix. A proxy can send 400; a 422 only comes from the application.
Your turn
Which one is this?
Which one is this? A sign-up request arrives as valid JSON. The email field contains “not-an-email”. The API follows the standard closely.
Each code in depth
Questions
- What is the difference between 400 and 422?
- A 400 means the server could not understand the request: it is malformed. A 422 means the request was well formed and understood, but its contents are invalid.
- Should validation errors return 400 or 422?
- Following the standard, 422. Many widely used APIs return 400 instead. Either works if you are consistent and the response body lists what to fix.
- Can a proxy send a 422?
- Typically not. A 422 needs knowledge of what the values mean, which only the application has. Proxies reject malformed requests with 400.
Sources: RFC 9110: 400 Bad Request (section 15.5.1) ↗ · RFC 9110: 422 Unprocessable Content (section 15.5.21) ↗ · Report a problem
Diagrams are our own simulations. All wording is original and paraphrases the linked sources.
Practise this in the DNS / HTTP track
Two-minute animated lessons, then boss fights from real outages. Free, no account needed.