MockFoxAdvertise

HTTP 422 Unprocessable Content (Unprocessable Entity)

Updated Free mock REST & WebSocket APIs

HTTP 422 Unprocessable Content — The request is well-formed, but its contents fail validation.

Class
4xx Client Error
Defined in
RFC 9110 §15.5.21
Official
Yes (IANA registry)
Cacheable by default
No (unless Cache-Control/Expires say so)
Safe to retry
Not without changing the request

Try it: get a real 422 response

Our test endpoint answers every request with 422 Unprocessable Content.

curl -i https://mockfox.dev/api/status/422

Use it in tests, health-check monitors or to see how your client handles a 422. Add ?delay=2000 to slow it down.

What does HTTP 422 mean?

422 Unprocessable Content (long known as "Unprocessable Entity", from WebDAV's RFC 4918) means the server understands the content type and the syntax is correct, but it can't process the contained instructions — in practice, the data fails validation.

It's the standard validation-error status in many frameworks: Ruby on Rails, Laravel, FastAPI and GitHub's API all return 422 for invalid input.

When is 422 used?

  • A required field is empty or a value has the wrong format (email, date, phone).
  • A value is out of range (quantity −1, a date in the past).
  • References to related records that don't exist (categoryId: 999).
  • FastAPI/Pydantic schema validation fails.

Common causes of a 422

  • The form or JSON you sent is well-formed but has invalid values.
  • Client and server disagree on the schema after an API change (renamed or newly required field).

How to fix 422 Unprocessable Content

If you're visiting the site

  1. Read the error messages next to the form fields, correct the highlighted values and resubmit.

If you run the site or API (developers)

  1. Return field-level details so clients can show them inline, e.g. RFC 9457 Problem Details with an errors array.
  2. Use 400 for unparseable bodies and 422 for valid syntax with invalid values — and be consistent across your API.
  3. In FastAPI, read the detail array: each item has loc, msg and type describing exactly which field failed.

Returning or handling 422: server examples

Express + zod

const User = z.object({ email: z.string().email(), age: z.number().int().min(13) });

app.post("/api/users", (req, res) => {
  const r = User.safeParse(req.body);
  if (!r.success) return res.status(422).json({ errors: r.error.issues });
  // ...
});

Next.js

// app/api/example/route.ts (Next.js App Router)
export async function POST(req: Request) {
  const body = await req.json();
  if (!/^\S+@\S+$/.test(body.email ?? ""))
    return Response.json({ errors: [{ field: "email", message: "Enter a valid email" }] }, { status: 422 });
  // ...
}

FastAPI (automatic)

# Pydantic validation failure → 422 with details:
# {"detail":[{"type":"missing","loc":["body","email"],"msg":"Field required"}]}

Example 422 response

HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json

{"type":"https://example.com/validation","title":"Invalid input","status":422,
 "errors":[{"field":"email","message":"must be a valid email address"}]}

Related status codes

Related tools

Frequently asked questions

What is the difference between 400 and 422?

400 is for requests the server can't parse or that are malformed. 422 is for well-formed requests whose content fails validation. Some APIs use 400 for both; pick one convention and document it.

Why does FastAPI return 422?

Its request body, path or query parameters didn't match the declared Pydantic model or types. The response's detail array lists each failing field.

Is it Unprocessable Entity or Unprocessable Content?

Same code. RFC 9110 (2022) renamed it to Unprocessable Content when it moved into core HTTP; many libraries still use the old name.