Blog

HTTP Problem Details: Stop Inventing A New Error Shape Per Endpoint

stable failures are part of the contract
Different API failures normalized into one precise problem-details envelope

One endpoint returns error, another returns message, and a third sends a Java stack trace inside details. This is not flexibility. It is forcing every client to learn your internal history.

HTTP Problem Details gives error responses a common vocabulary.

The Useful Core

RFC 9457 defines application/problem+json and members such as type, title, status, detail, and instance.

{
  "type": "https://api.example.com/problems/insufficient-funds",
  "title": "Insufficient funds",
  "status": 409,
  "detail": "The account cannot cover this transfer.",
  "instance": "/problems/01J...",
  "availableMinorUnits": 4200
}

type identifies the problem class. Keep it stable and document it. detail describes this occurrence for a human; clients should use structured fields instead of parsing prose.

Status Still Lives In HTTP

The body does not rescue a wrong status code. The RFC treats the optional status member as advisory and requires it to match the actual response generated by the origin server.

Do not return 200 with a problem body because one client library dislikes errors.

An Instance Is Not A Stack Trace

instance can identify one occurrence and connect support work to internal telemetry. It should not expose a database key, host path, or secret. Problem details describe the HTTP interface, not debugger internals.

Define a small extension vocabulary, test it like any response schema, and evolve additively. One consistent failure language makes clients simpler and incident evidence better.