422

HTTP 422 Unprocessable Content

4xx Client Error

4xx Client Error RFC 9110, Section 15.5.21

What is HTTP 422 Unprocessable Content?

The 422 (Unprocessable Content) status code indicates that the server understands the content type and syntax of the request body but was unable to process the contained instructions. In REST APIs, this is commonly used for validation errors — the request format is correct but the data is invalid.

Common Use Cases

  • Form validation errors in API
  • Missing required fields in request body
  • Invalid data format or constraints violation

Usage Example

When a user submits a registration form with an invalid email and a password that is too short, return 422 Unprocessable Content with a structured error response listing each failed field and the corresponding validation message. This enables frontend clients to display inline errors next to each form field.

// Laravel - validation errors return 422 automatically
$request->validate([
    'email' => 'required|email',
    'password' => 'required|min:8',
]);

// Returns {"message": "...", "errors": {"email": [...], "password": [...]}} with 422

Common Mistakes

⚠️

Mistake: Returning 400 for validation errors instead of 422

Fix: Use 422 Unprocessable Content for validation errors where the request body is syntactically valid but the data is invalid. Reserve 400 for malformed syntax like invalid JSON.

⚠️

Mistake: Returning 422 with a flat error message instead of per-field errors

Fix: Structure validation error responses as an object with field names as keys and arrays of error messages as values. This enables frontend frameworks to display errors next to specific form fields.

⚠️

Mistake: Including stack traces or debug info in 422 responses in production

Fix: Validation error responses should contain user-friendly messages, not internal debug information. Keep stack traces and internal details out of production API responses.

Last updated: 21 Jun 2026