Skip to content

By the Octri team · Updated

422 Unprocessable Content

Share

A 422 means the server understood the request and it parsed fine, but the data breaks a rule. Until RFC 9110 renamed it in 2022 it was called Unprocessable Entity, from WebDAV.

All HTTP status codes

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.

APIOperationsDeclare 422How errors are described
GitHub1,288381Per status code
Adyen Checkout2820Per status code
Swagger Petstore193Per status code, plus a default
Box2972Per status code, plus a default
OpenAI4061Per status code
Stripe6120One default error response
Plaid3510One default error response
Asana3020Per status code
Twilio1970No error responses
Slack1740One default error response
SendGrid Mail30Per 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.

yaml
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: string

What 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.

typescript
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.

Share