Every API seems to invent its own error JSON. One uses message, one uses error, one nests it two levels deep. RFC 9457 has a standard shape for this, and it is smaller than you’d expect.
HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json
{
"type": "https://example.net/validation-error",
"title": "Your request is not valid.",
"status": 422,
"detail": "age must be a positive integer"
}
The media type is application/problem+json. The RFC defines five members:
type: a URI that identifies the problem type. If it is missing, it counts asabout:blank. Absolute URIs are recommended.status: the HTTP status code. It is advisory, and the real response must use the same code.title: a short summary of the problem type. It should not change between occurrences, except for localisation.detail: an explanation specific to this occurrence.instance: a URI that identifies this particular occurrence.
You can add your own members. The RFC’s validation example adds an errors array with a detail and a pointer per field.
A small Python test server returning the body above made curl 8.5.0 show the application/problem+json content type on a 422 response.
One caveat: consumers should not parse detail for information, since it is for humans. Put anything a client needs to act on in its own extension member.
Further reading: RFC 9457: Problem Details for HTTP APIs