API Error Handling: RFC 7807 Problem Details and Resilient Responses
Implement standardized REST API error formats using IETF RFC 7807 Problem Details for HTTP APIs. Prevent client confusion with structured error objects.
Nothing frustrates frontend developers more than an API returning a generic 500 Server Error with a blank body or HTML stack trace. RFC 7807 establishes a battle-tested standard for error reporting in http api systems.
RFC 7807 Example Payload
HTTP/1.1 403 Forbidden
Content-Type: application/problem+json
{
"type": "https://example.com/errors/insufficient-funds",
"title": "Insufficient Account Balance",
"status": 403,
"detail": "Your balance of $12.50 is insufficient for this $45.00 transaction.",
"instance": "/v1/transfers/txn_89124a",
"invalidParams": [
{ "name": "amount", "reason": "Exceeds current available balance" }
]
}