Browser showing a 422 Unprocessable Entity HTTP error
# website errors# troubleshooting

422 Unprocessable Entity: What It Means and How to Fix It

A 422 Unprocessable Entity error means the server received your request, understood the content type, and parsed the syntax correctly — but it can't process the data because of semantic errors. In plain terms: your request is well-formed, but the data inside it doesn't make sense or fails validation.

This is one of the more developer-facing HTTP errors. You'll encounter it most often when working with APIs, form submissions, and data-driven applications.

What Does a 422 Unprocessable Entity Mean?

A 422 sits between two related status codes:

  • 400 Bad Request: The request syntax is malformed. The server can't even parse it (invalid JSON, missing headers, etc.).
  • 422 Unprocessable Entity: The syntax is fine, but the content is semantically invalid (missing required fields, wrong data types, failed validation rules).

For example, sending valid JSON to an API but with an email field that contains "not-an-email" would trigger a 422. The JSON is perfectly valid — the server just can't process data that fails its validation rules.

The 422 status code was originally defined in WebDAV (RFC 4918) but has been widely adopted by REST APIs. Frameworks like Ruby on Rails, Laravel, and FastAPI use it as the standard response for validation failures.

Common Causes of a 422 Error

1. Validation Failures

The most common cause by far. The submitted data fails one or more server-side validation rules.

# Example: missing required fields
curl -X POST https://api.example.com/users \
    -H "Content-Type: application/json" \
    -d '{"name": "Test User"}'

# Response: 422 Unprocessable Entity
# {
#   "errors": {
#     "email": ["The email field is required"],
#     "password": ["The password field is required"]
#   }
# }

2. Invalid Data Types

The field exists but contains the wrong type of data — a string where a number is expected, an array where an object is needed, or an invalid date format.

# Example: wrong data type
curl -X POST https://api.example.com/products \
    -H "Content-Type: application/json" \
    -d '{"name": "Widget", "price": "not-a-number", "quantity": -5}'

# Response: 422
# {
#   "errors": {
#     "price": ["Must be a valid number"],
#     "quantity": ["Must be greater than 0"]
#   }
# }

3. Business Logic Violations

The data is valid in format but violates application rules. For example, trying to set an end date before a start date, booking a time slot that's already taken, or requesting a quantity that exceeds available stock.

4. Invalid Relationships or References

The request references a related resource that doesn't exist or is in an invalid state:

# Example: referencing a non-existent category
curl -X POST https://api.example.com/products \
    -H "Content-Type: application/json" \
    -d '{"name": "Widget", "category_id": 99999}'

# Response: 422
# {"errors": {"category_id": ["Category not found"]}}

5. File Upload Validation Failures

The file was uploaded successfully (the server received it), but it fails validation — wrong file type, too large, corrupted, or contains invalid content.

6. Encoding or Character Set Issues

Data that contains invalid characters for the expected encoding, or special characters that break validation patterns.

How to Fix a 422 Unprocessable Entity

Step 1: Read the Error Response

A well-built API will return detailed validation errors. Always check the response body first:

# Get the full response including body
curl -s -X POST https://api.example.com/endpoint \
    -H "Content-Type: application/json" \
    -d '{"incomplete": "data"}' | jq .

The response typically contains field-level error messages telling you exactly what needs to change.

Step 2: Validate Data Before Sending

Implement client-side validation to catch issues before they reach the server:

# Verify your JSON is valid before sending
echo '{"name": "Test", "email": "[email protected]"}' | jq .

Check for:

  • All required fields are present.
  • Data types match what the API expects.
  • Values are within acceptable ranges.
  • String formats match expected patterns (email, date, URL, etc.).

Step 3: Check the API Documentation

Compare your request against the API documentation. Pay attention to:

  • Required vs optional fields.
  • Expected data types and formats.
  • Enum values (where only specific strings are allowed).
  • Minimum and maximum lengths or values.
# Test with a minimal valid payload first
curl -X POST https://api.example.com/users \
    -H "Content-Type: application/json" \
    -d '{
        "email": "[email protected]",
        "password": "securePassword123",
        "name": "Test User"
    }'

Step 4: Handle Edge Cases in Your Application

If you're the one building the API and receiving reports of unexpected 422s, review your validation rules for edge cases:

# Check application logs for validation failure patterns
grep -i "validation\|422\|unprocessable" /var/log/app/error.log | tail -20

Common issues:

  • Validation rules that are too strict (e.g., rejecting valid international phone numbers).
  • Missing handling for optional fields that arrive as null vs being absent.
  • Locale-sensitive validation (date formats, number separators).

Step 5: Debug with Verbose Output

Use curl's verbose mode to see exactly what's being sent:

curl -v -X POST https://api.example.com/endpoint \
    -H "Content-Type: application/json" \
    -d '{"field": "value"}'

Verify the Content-Type header is correct. Sending form data to an endpoint expecting JSON (or vice versa) can cause parsing issues that manifest as 422s.

422 vs 400: When to Use Which

Use 400 Bad Request when:

  • The JSON/XML is malformed (syntax error).
  • The Content-Type is wrong.
  • Required headers are missing.
  • The request can't be parsed at all.

Use 422 Unprocessable Entity when:

  • The request is syntactically valid.
  • The data fails semantic validation.
  • Business rules prevent processing.
  • Field-level validation errors occur.

How Domain Monitor Can Help

A sudden spike in 422 errors across your API can indicate a broken deployment — perhaps a validation rule was changed, a required field was added without updating clients, or a database migration altered the expected data schema. While individual 422s are normal (users submit bad data), a system-wide increase suggests something broke on the server side.

Domain Monitor monitors your endpoints every minute from multiple locations. If a monitored endpoint that normally returns 200 starts responding with 422 or other error codes, you'll get an immediate alert via email, SMS, or Slack. You can set up downtime alerts for critical API endpoints and use website monitoring to track the health of your application's key flows.

Quick Summary

CauseFix
Missing required fieldsAdd all required fields to the request
Wrong data typesMatch the expected types (string, number, etc.)
Business rule violationCheck the current state and constraints
Invalid referencesVerify referenced resources exist
File validation failureCheck file type, size, and format

A 422 is the server's way of saying "I understand your request, but the data is wrong." Read the error response, fix the data, and try again. If you're building the API, return detailed, field-level error messages so consumers can fix their requests without guessing.

More posts

Wildcard vs SAN vs Single-Domain SSL Certificates: Which Do You Need?

Wildcard, SAN (multi-domain), and single-domain SSL certificates cover different use cases. Here's a clear comparison to help you pick the right type — and avoid paying for coverage you don't need.

Read more
Why DNS Works in One Location but Fails in Another

DNS resolves correctly from your office but fails for users in other countries or on different ISPs. Here's why geographic DNS inconsistency happens and how to diagnose which layer is causing it.

Read more
Registrar Lock vs Transfer Lock: What's the Difference?

Registrar lock and transfer lock are often confused — and disabling the wrong one leaves your domain vulnerable. Here's a clear breakdown of what each does and when to use them.

Read more

Subscribe to our PRO plan.

Looking to monitor your website and domains? Join our platform and start today.