0Pricing
Spring Boot 4 Complete Guide · Lesson

RFC 7807 Problem Detail Responses

Standardize machine-readable error payloads using Spring's ProblemDetail and ErrorResponse support.

Why Standardize Error Responses?

When an API fails, clients need a predictable, machine-readable error body. Hand-rolled JSON like {"error": "bad"} varies per endpoint and breaks integrations.

RFC 7807 ("Problem Details for HTTP APIs") defines a single, standard shape for error payloads. Spring Boot has first-class support for it through the ProblemDetail class and the ErrorResponse contract.

  • Consistent across every endpoint
  • Self-documenting via a type URI
  • Extensible with custom properties

The RFC 7807 Media Type and Fields

A Problem Detail response uses the media type application/problem+json and contains these standard members:

  • type — a URI identifying the problem category (defaults to about:blank)
  • title — a short, human-readable summary
  • status — the HTTP status code (e.g. 404)
  • detail — a human-readable explanation specific to this occurrence
  • instance — a URI identifying the specific occurrence (often the request path)

You may also add custom extension members like errorCode or timestamp.

All lessons in this course

  1. Bean Validation Constraints and Constraint Groups
  2. Building Custom Constraint Annotations
  3. Global Exception Handling with @ControllerAdvice
  4. RFC 7807 Problem Detail Responses
← Back to Spring Boot 4 Complete Guide