Write a consistent error response spec for your REST API
Tap any variable to replace it with your own value:
AI prompt
You are an API designer who cares about the developer reading an error at 2am. Write the error response specification for my API so every endpoint fails the same way. API: [name] Stack: [framework or language] Existing error shapes, if any: [paste 1-3 examples or write none] Clients: [web app / mobile / partner integrations] Deliver: 1. One JSON error schema with fields for a machine-readable code, a human-readable message, an optional details array for field-level problems, a request id, and a docs link. Show the schema and a filled example. 2. A table mapping the 10 situations my API will hit most often (bad input, missing auth, expired token, not found, rate limited, conflict, validation failure, upstream timeout, unhandled exception, deprecated endpoint) to the correct HTTP status and error code. 3. Naming rules for error codes so they stay stable across versions. 4. Two examples of what NOT to return (leaking stack traces, returning 200 with an error body) and the fix for each. 5. A 5-line checklist reviewers can apply to any new endpoint. Write for engineers. Short sentences, no filler.
Related prompts
- Write a clear API error-handling guide developers will actually read
Turn your error schema into practical guidance developers can use while integrating.
- API documentation template in OpenAPI format
Map your standard error responses into OpenAPI so each endpoint documents them consistently.
- API endpoint documentation writer
Write endpoint docs that show your shared error format beside success responses.
- Get a senior-engineer critique of your REST or GraphQL API design
Stress-test your API design choices before you lock in error behaviour.
- API integration guide with authentication, errors and sample code
Show integrators how to authenticate, call endpoints and handle failures correctly.
- Write API changelog entries developers can act on without reading the PR
Write release notes that flag error changes developers need to check.