Design Standardized REST API Error Contracts Using RFC 7807
Generate a comprehensive, machine-readable API error schema that follows the RFC 7807 Problem Details standard for consistent, client-side error handling.
Prompt
You are a Senior Backend Architect. Your job is to design a standardized REST API error contract based on RFC 7807. Before generating the schema, ask these 3 questions: 1. What is the base URL or domain for your API? 2. What specific programming language or framework are you using? 3. Do you need to include internal tracking IDs or custom extension fields in the error response? After I answer, provide the design. Rules: 1. Every error response must include type, title, status, detail, and instance fields. 2. Define a custom error code system that maps to these HTTP status codes: 400, 401, 404, 409, and 422. 3. Provide a JSON Schema specification for the error object. 4. Provide one example JSON response for each of the 5 status codes. Output format: 1. Overview of the error strategy. 2. JSON Schema block. 3. Examples table with columns: HTTP Status, Error Code, Example JSON. This is for technical reference only; verify all security implications with your security team.Example output
Tips and common edits
Why this works
- Forces adherence to the RFC 7807 standard for industry-wide compatibility.
- Requires specific JSON schema and table-based examples for developer clarity.
- Uses a mandatory question phase to customize the output to your stack.
Use this prompt when building new APIs to ensure consistent error handling across your microservices. Works perfectly in ChatGPT, Claude, or Gemini to generate documentation for your developers.
Common edits
- Add a 'traceId' field to the schema to help with debugging production logs.
- Adjust the error codes to match your existing domain-specific naming conventions.
Make it repeatable
Keep using this prompt without pasting it in every time.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
Turn a Feature Description into a REST API Endpoint Spec
Paste a feature description and get a REST API spec with a route table, request and response fields, status codes, exact validation rules, and open questions on auth and pagination.
Create safe user error messages with correlation IDs
Turn internal backend exceptions into secure, user-facing error payloads paired with traceable request correlation IDs. Use it to build clean API error contracts.
Design a Scalable API Rate Limiting Architecture
Get a complete technical blueprint for implementing API rate limiting using Redis, including data structures, tiered limit logic, and standard response headers.
Design Cursor-Based Pagination Logic for High-Volume APIs
Get a complete implementation plan for cursor-based pagination including SQL queries, cursor encoding logic, and strategies for handling record deletions.
Generate complete API documentation from route code
Generate clear request, response, and error documentation directly from backend handler code. Use it to prepare API docs for frontend developers.
Design a Scalable Append-Only Audit Logging System
Get a structured, immutable schema design for tracking sensitive data changes, including field-level diffs and compliance-ready partitioning strategies.
- Design a Normalized Database Schema from a Plain Feature Description
- Add Docstrings and Why-Focused Comments to Your Pasted Code
- Write a Safe Automation Script with Dry Run and Error Handling
- Convert raw error logs into a clean bug report
- Find the failing line in a stack trace
- Refactor nested legacy loops into flat readable helper functions