4xx Client errors
HTTP 422 Unprocessable Content
HTTP 422 Unprocessable Content means the request was well-formed but its data failed validation.
What 422 Unprocessable Content means
Where 400 often means "I could not parse this", 422 means "I parsed it, and the values break a rule": an end date before the start date, a price below zero, an email that is valid syntax but not allowed. Many frameworks use 422 for form validation errors.
Common causes
- Business-rule validation failed.
- A schema validator rejected field values in valid JSON.
How to fix or use it
Return 422 with a list of field errors the client can show next to each input. Decide whether your API uses 400 or 422 for validation, document it, and use it everywhere.
Express (Node.js) example
if (req.body.endDate <= req.body.startDate) {
return res.status(422).json({ errors: { endDate: ['Must be after the start date'] } });
}SEO impact
No SEO effect: it is an API and form response.
