422 Unprocessable Entity Error
Learn what 422 Unprocessable Entity means for API validation errors, how it differs from 400, and how to fix validation failures.
What Does This Error Mean?
The 422 Unprocessable Entity status code means the server understands the request syntax but cannot process it due to semantic errors — the request is well-formed but contains invalid data that fails business logic or validation rules.
Common Causes
Required field is missing from the request body
Field value fails format validation (email, phone, URL)
Business rule violation (e.g., duplicate username)
Referenced resource does not exist (foreign key violation)
Date range is invalid (end before start)
Enum value is not in the allowed list
How to Fix It
Read the error response body
422 responses typically include detailed field-level validation errors in the response body.
fetch("/api/users", {
method: "POST",
body: JSON.stringify({ email: "invalid" })
}).then(async res => {
if (res.status === 422) {
const errors = await res.json()
// { errors: { email: ["Invalid email format"] } }
console.log(errors)
}
})Validate on the client first
Validate form data before sending to reduce 422 responses.
function validateUser(data) {
const errors = {}
if (!data.email?.includes("@")) errors.email = "Invalid email"
if (!data.name?.trim()) errors.name = "Name is required"
if (data.age < 0 || data.age > 150) errors.age = "Invalid age"
return Object.keys(errors).length ? errors : null
}Check field formats and constraints
Verify each field matches the expected format, length, and type.
// Common validation patterns
{ "email": "user@example.com" } // ✅ Valid format
{ "email": "not-an-email" } // ❌ 422
{ "age": 25 } // ✅ Valid
{ "age": -5 } // ❌ 422 (out of range)Before & After Examples
POST /api/users
{"email":"bad","name":"John"}POST /api/users
{"email":"john@example.com","name":"John"}Related Tools
Use these tools to debug and fix this error:
REST API Client
Send HTTP requests (GET, POST, PUT, DELETE) and inspect responses from your browser.
JSON Validator
Validate JSON data and detect syntax errors with detailed error messages and line numbers.
HTTP Status Code Reference
Searchable reference of all HTTP status codes with descriptions and use cases.
Related Errors
Other common errors in this category:
401 Unauthorized Error
Learn what a 401 Unauthorized error means, common causes, and how to fix authentication failures in your web applications.
403 Forbidden Error
Learn what 403 Forbidden means, how it differs from 401, and how to fix access denied errors in your applications.
404 Not Found Error
Learn what 404 Not Found means, common causes, and how to fix broken links and missing resources on your website or API.
429 Too Many Requests Error
Learn what 429 Too Many Requests means, how rate limiting works, and how to handle or avoid hitting API rate limits.