Hello! 😊
This document explains the contents of RFC 9457 in sequential order, structured as comprehensively as possible.
Key quotes are presented as blockquotes, and important keywords are highlighted in bold or code for clarity.
1. Overview and Purpose
RFC 9457 defines the "Problem Details" format for conveying errors that occur in HTTP APIs in a machine-readable standard format. It replaces the previous standard RFC 7807 and supports both JSON and XML formats.
"This document defines 'problem details' as a way to carry machine-readable details of errors in HTTP response content, so that HTTP APIs need not define their own error response formats."
Why Is This Needed?
- HTTP status codes alone are often insufficient to explain the cause of an error.
- A human can read and understand an HTML error page, but programs consuming an API cannot.
- Therefore, structured error information that machines can understand is necessary.
"HTTP status codes are sometimes not sufficient to convey enough information about an error to be helpful. While humans behind Web browsers can be informed about the nature of the problem with an HTML response body, non-human consumers of so-called 'HTTP APIs' are not."
2. Requirements Terminology
Within the document, terms such as MUST, SHOULD, MAY are used with their strict meanings as defined by RFC 2119/8174.
3. The Problem Details JSON Object
3.1 Basic Structure
- A problem details response is fundamentally a JSON object.
- The media type is
application/problem+json. - XML format (
application/problem+xml) is also supported.
Example
{
"type": "https://example.com/probs/out-of-credit",
"title": "You do not have enough credit.",
"detail": "Your current balance is 30, but that costs 50.",
"instance": "/account/12345/msgs/abc",
"balance": 30,
"accounts": ["/account/12345", "/account/67890"]
}
"You do not have enough credit." "Your current balance is 30, but that costs 50."
type: A URI identifying the problem typetitle: A short, human-readable summarydetail: A specific human-readable explanationinstance: A URI uniquely identifying this occurrence of the problembalance,accounts: Extension members (can be added depending on the problem type)
Representing Multiple Errors at Once
{
"type": "https://example.net/validation-error",
"title": "Your request is not valid.",
"errors": [
{
"detail": "must be a positive integer",
"pointer": "#/age"
},
{
"detail": "must be 'green', 'red' or 'blue'",
"pointer": "#/profile/color"
}
]
}
"Your request is not valid." "must be a positive integer" "must be 'green', 'red' or 'blue'"
errors: Provides details for each error as an array
When Multiple Problem Types Occur Simultaneously
- It is recommended to include only the most significant problem in the response.
3.1 Members of a Problem Details Object
3.1.1 type
- A URI identifying the problem type (e.g.,
https://example.com/probs/out-of-credit) - If absent, the default value is
about:blank - Use of absolute URIs is recommended.
"When the 'type' member is not present, its value is assumed to be 'about:blank'."
- If the URI is actually resolvable, it should provide documentation about the problem type.
- Relative URIs can cause confusion — use with care!
3.1.2 status
- The HTTP status code (e.g., 403, 422)
- For reference only; it must match the actual HTTP response status code.
"The 'status' member, if present, is only advisory; it conveys the HTTP status code used for the convenience of the consumer. Generators MUST use the same status code in the actual HTTP response."
3.1.3 title
- A short summary of the problem type (human-readable)
- Does not change from occurrence to occurrence; only localization may differ.
3.1.4 detail
- A specific explanation of this particular occurrence of the problem
- Should focus on information that helps the client correct the problem.
3.1.5 instance
- A URI uniquely identifying this occurrence of the problem
- If resolvable, it can provide additional information about the specific problem.
- Use of absolute URIs is recommended.
3.2 Extension Members
- Additional members can be defined depending on the problem type.
- Examples:
balance,accounts,errors, etc. - Clients must ignore extension members they do not recognize.
"Clients consuming problem details MUST ignore any such extensions that they don't recognize; this allows problem types to evolve and include additional information in the future."
4. Defining New Problem Types
4.1 When Should You Define a New Problem Type?
- Define a new problem type when HTTP status codes alone are not sufficient.
- The purpose is to convey the semantics of the HTTP interface, not to provide debugging information.
- Security caution: Take care not to expose internal implementation details.
"Problem details are not a debugging tool for the underlying implementation; rather, they are a way to expose greater detail about the HTTP interface itself."
- Overly generic problems (e.g., 403 Forbidden) generally do not need a new type defined.
4.2 Problem Type Registry
- Commonly used problem type URIs can be registered with IANA.
- Registration must include the following information:
- Type URI
- Title
- Recommended HTTP Status Code
- Reference document
4.2.1 about:blank
- The default problem type
- Used when the HTTP status code alone conveys sufficient meaning without additional semantics
- In this case,
titleshould use the standard phrase for the status code (e.g., "Not Found" for 404)
"When used with the 'about:blank' type, the title SHOULD be the same as the recommended HTTP status phrase for that code (e.g., 'Not Found' for 404, and so on), although it MAY be localized to suit client preferences."
5. Security Considerations
- Information included in problem details must be carefully reviewed.
- Take care not to expose sensitive information such as stack traces or internal paths!
- If the
statusmember differs from the actual HTTP status code, confusion can arise — always keep them consistent.
"Generators providing links to occurrence information are encouraged to be cautious when generating such URLs, since misuse can lead to privacy and security vulnerabilities."
6. IANA Considerations
- The
application/problem+jsonandapplication/problem+xmlmedia types are updated to reference this document. - The HTTP Problem Types registry is created, with
about:blankregistered as the default.
7. References
- Related standard documents for HTTP, JSON, XML, URI, and others are listed as normative and informative references.
Appendix
A. JSON Schema Example
- An informal JSON Schema for the problem details object is provided.
B. XML Format
- The problem details XML format for XML-based APIs and accompanying examples are provided.
C. Interoperability with Other Formats
- Methods for embedding problem details in other formats such as HTML (e.g., injecting JSON via
<script type="application/problem+json">) are also described.
Key Summary and Usage Tips
- Problem Details is a way to convey errors in HTTP APIs using a standardized structure.
- Core fields:
type,title,status,detail,instance - Extension fields: Can be freely added depending on the problem type
- Supports both JSON and XML; media types are
application/problem+jsonandapplication/problem+xmlrespectively - Caution: Do not expose sensitive information for security reasons!
- Common problem types can be registered and reused via the IANA registry.
Conclusion
That wraps up a structured, sequential overview of the key contents of RFC 9457! By following this standard, you can deliver API error responses in a way that is consistent, machine-understandable, and extensible. Feel free to ask any questions! 🚀
Key Terms:
- Problem Details
- HTTP API
- JSON/XML
- type, title, status, detail, instance
- Extension Members
- about:blank
- Security
- IANA Registry