Generate consistent API error responses in RFC 9457 problem details or your own envelope, with status codes mapped to the cases people most often get wrong.
422 Unprocessable Content
RFC 9457 (formerly RFC 7807) · application/problem+json
About this shape
The only error format with a specification behind it, so libraries and gateways already understand it. The flat shape means your own fields sit beside the standard ones — deliberate, and it does mean choosing names that will not clash later.
HTTP/1.1 422 Unprocessable ContentContent-Type: application/problem+jsonX-Request-Id: req_8f14e45fea2b4f1c{
"type": "https://example.com/probs/validation-failed",
"title": "The request body did not pass validation.",
"status": 422,
"instance": "/v1/orders",
"code": "validation_failed",
"errors": [
{
"detail": "Must be at least 1.",
"pointer": "/items/0/quantity",
"code": "too_small"
},
{
"detail": "Must be a valid email address.",
"pointer": "/customer/email",
"code": "invalid_format"
}
],
"requestId": "req_8f14e45fea2b4f1c"
}`type` is a URI that identifies the error kind. It does not have to resolve, and `about:blank` is the specification's placeholder for 'no more detail than the status code'.
Extension members like `code` and `errors` go at the top level rather than nested, which is what the specification intends.
Returning the request id in both a header and the body means it is available whether or not the client parsed the body — which matters most when the body is what went wrong.
API Error Response Generator runs entirely on your device — nothing is uploaded or stored.
You’re on the Free plan. Compare plans
Error responses drift. One endpoint returns `{error: "..."}`, another `{message: "..."}`, a third an array, and clients end up with a branch for each. This generates one shape and applies it consistently.
RFC 9457 problem details is offered because it is the only standard answer, and it is a genuinely good one: `type`, `title`, `status`, `detail` and `instance`, with room for your own fields. Its `Content-Type` is `application/problem+json`, which is the part people omit and the part that lets a client recognise the shape.
Custom envelopes are supported without pretending there is a universal convention, because there is not. You choose the field names and whether errors come back as one object or a list; the tool keeps them consistent across every status you generate.
Validation errors get particular attention, because they are the case a single string cannot carry. A client needs to know which field failed and why, which means a list of per-field entries rather than a sentence — and the generator's output is shaped for that.
Status code choices come with the distinctions that matter: 400 against 422, 401 against 403, 404 against 403 when hiding existence is deliberate. Each is explained where you pick it rather than left to a reference page.
The standard shape for HTTP error responses — `type`, `title`, `status`, `detail`, `instance`, plus your own fields. It replaced RFC 7807 with the same model. Sending it as `application/problem+json` is what lets a client recognise it generically.
400 means the request was malformed — broken JSON, a missing required header. 422 means it parsed fine and the contents failed your rules. The distinction tells the client whether to fix its encoding or its data.
401 means the request was not authenticated — no credentials, or bad ones — and it must carry a `WWW-Authenticate` header. 403 means authenticated and not permitted. Sending 403 for a missing token is the most common mix-up.
Both are defensible, and this lets you pick. A list handles validation failures across several fields without a second shape; a single object is simpler everywhere else. What matters is that it is the same on every endpoint.
No. RFC 9457 is offered because it is standard, not because it is required, and the custom envelope lets you name the fields yourself.