# 422 Unprocessable Content

> https://http-status.org/docs/422

**Family:** 4xx Client Error

## Rationale

The request content is well-formed and understood, but the server cannot process the contained instructions.

## In Plain Terms

Your request looks right, but the data doesn't make sense according to our business rules. Fix the data and try again.

## Description

The HTTP 422 Unprocessable Content status code indicates that the server understands the content type of the request content and the syntax is correct, but it cannot process the contained instructions. In practice, this is commonly used for semantic validation failures in otherwise well-formed requests.

## Server Perspective

### Usage
- Return 422 for validation failures, domain-rule violations, and semantically invalid content
- Use it when the client can fix the submitted content without changing the target resource state
- Validation errors on request data
- Business rule violations
- Invalid field values (e.g., negative age)
- Failed schema validation
- Semantic errors in well-formed requests

### Implementation
- Return field-level or rule-level validation details when possible
- Keep 422 distinct from 400 syntax problems and 409 state conflicts

### Common Headers
- No status-specific header is required; still send normal HTTP metadata such as Content-Type, caching, or tracing headers when they help the client.

### Body
- Include actionable validation details such as field names, rule failures, or machine-readable error codes

### Pitfalls
- Use 400 when the request could not be parsed or understood structurally
- Use 409 when the problem is a conflict with current server state rather than bad submitted content
- Syntax errors (use 400 Bad Request)
- State conflicts (use 409 Conflict)
- Authentication issues (use 401 Unauthorized)

## Client Perspective

### Pitfalls
- Do not keep resubmitting the same invalid content

## Examples

### Invalid field value

Age cannot be negative, violates business rules

**Request:**
```
POST https://api.example.test/api/users

{
  "age": -5
}
```

**Response:**
```
422 Unprocessable Content
Content-Type: application/json

{
  "error": "unprocessable_content"
}
```

## Related Codes

- [409 Conflict](/docs/409.md)
- [400 Bad Request](/docs/400.md)

