- Class
- 4xx client error
- Defined in
- RFC 9110, section 15.5.21
- Retry
- No, fix the data
- Earlier name
- Unprocessable Entity
- Cacheable by default
- No
When your API should return 422
Return 422 when the body is well formed and semantically wrong, like an end date before a start date, a currency your API doesn’t support, or a quantity above the stock you have. List every field that failed and why, so a form can show all the errors at once.
If the JSON doesn’t parse or a required field is missing, many APIs return 400 and keep 422 for rule violations. If the rule depends on other state, like an email that’s taken, 409 is the usual choice.
How public APIs declare 422 in their OpenAPI specs
Five of the eleven public specs we score declare a 422, as they were on 4 December 2026. GitHub does on 381 operations, three times as many as declare 400.
Adyen declares 422 on 20 of its 28 operations. OpenAI, Box and Petstore name it on three operations or fewer.
| API | Operations | Declare 422 | How errors are described |
|---|---|---|---|
| GitHub | 1,288 | 381 | Per status code |
| Adyen Checkout | 28 | 20 | Per status code |
| Swagger Petstore | 19 | 3 | Per status code, plus a default |
| Box | 297 | 2 | Per status code, plus a default |
| OpenAI | 406 | 1 | Per status code |
| Stripe | 612 | 0 | One default error response |
| Plaid | 351 | 0 | One default error response |
| Asana | 302 | 0 | Per status code |
| Twilio | 197 | 0 | No error responses |
| Slack | 174 | 0 | One default error response |
| SendGrid Mail | 3 | 0 | Per status code |
Counted per operation from each vendor’s public OpenAPI document on 4 December 2026.
Declare 422 in your OpenAPI spec
Declare 422 with a schema that lists the failed fields, so docs and SDKs can show the shape of a validation error.
paths:
/bookings:
post:
operationId: createBooking
responses:
"201":
$ref: "#/components/responses/BookingCreated"
"422":
$ref: "#/components/responses/ValidationFailed"
components:
responses:
ValidationFailed:
description: The request parsed and breaks a rule. Each failed field is listed.
content:
application/json:
schema:
$ref: "#/components/schemas/ValidationError"
schemas:
ValidationError:
type: object
required: [errors]
properties:
errors:
type: array
items:
type: object
required: [field, code]
properties:
field:
type: string
code:
type: string
message:
type: stringWhat an Octri SDK does with a 422
An Octri SDK raises SdkUnprocessableEntityError for a 422 in TypeScript, Python, Java, Kotlin, PHP and Ruby, and doesn’t retry it.
In TypeScript and Python, the error’s data holds the body decoded into the model your spec declares for 422, so a form can map each failed field to its input without parsing JSON by hand.
import { Acme, SdkUnprocessableEntityError } from "acme-sdk";
const acme = new Acme({ apiKey: process.env.ACME_API_KEY });
try {
await acme.bookings.create({ start: "2027-03-10", end: "2027-03-08" });
} catch (err) {
if (err instanceof SdkUnprocessableEntityError) {
// Typed from the ValidationError schema your spec declares for 422.
console.log(err.data);
}
throw err;
}More on retries and typed errors in SDK error handling.
HTTP 422 questions
Is 422 only for WebDAV?
No. It started in WebDAV’s RFC 4918, and RFC 9110 moved it into core HTTP in 2022, so any API can use it.
Is 400 wrong for validation errors?
No. Both are allowed, and Stripe returns 400 for invalid parameters. What matters is that your API uses one consistently and your spec says which.
Does Rails return 422?
Yes. Rails scaffolds return 422 when a model fails validation, which is one reason so many APIs use it.