REST API Error Handling: RFC 7807 Implementation Guide (2026)

Design clean, machine-readable HTTP error objects using RFC 7807 Problem Details format. Includes OpenAPI schemas and code samples across languages.

Inconsistent error payloads frustrate API developers and increase client-side error handling boilerplate. Standardizing error structures using RFC 7807 (Problem Details for HTTP APIs) ensures every error response is machine-parsable and self-describing.

1. Core RFC 7807 Attributes

RFC 7807 establishes five standard top-level JSON fields for all API error responses:

  • type (string - URI): A absolute URI reference identifying the specific error condition type.
  • title (string): A short, human-readable summary of the problem type (should not change between occurrences of the error).
  • status (integer): The HTTP status code generated by the origin server (matches response header).
  • detail (string): A human-readable explanation specific to this occurrence of the problem.
  • instance (string - URI): A relative or absolute URI reference identifying the specific request attempt (e.g. request ID or log trace path).

2. Production RFC 7807 Response Example

problem-details-response.json
{
  "type": "https://api.example.com/errors/invalid-credit-card",
  "title": "Credit Card Charging Failed",
  "status": 422,
  "detail": "The expiration date provided (08/2024) is in the past.",
  "instance": "/v1/charges/req_92837410293",
  "invalidParams": [
    {
      "name": "expMonth",
      "reason": "Month must be equal to or greater than current calendar month."
    }
  ]
}

Validate Your Error Response Schemas

Check if your OpenAPI specification declares explicit error status codes (400, 401, 403, 404, 500) and adheres to RFC 7807 schemas.

Audit Error Schemas โ†’

Ready to score and validate your API?

Paste any OpenAPI specification URL or YAML file into APIForge for instant 0-100 quality scoring, schema linting, and zero-CORS proxy testing.

Try APIForge Workbench โ†’
Share:๐• Postin Share

Frequently Asked Questions

What Content-Type header should be used for RFC 7807 errors?
Use Content-Type: application/problem+json for JSON error responses, or application/problem+xml for XML representations.
Can I add custom fields to an RFC 7807 error object?
Yes! RFC 7807 explicitly allows extending the base schema with domain-specific properties such as invalidParams, traceId, or retryAfterSeconds.

Related Resources