API Error Response Standard
Define a consistent error response format across all API endpoints
Design a standardized error response format for this API: **API style:** [STYLE — e.g., "REST", "GraphQL", "tRPC"] **Consumers:** [CONSUMERS — e.g., "React frontend, mobile app, third-party developers"] Generate: 1. **Error envelope** — consistent JSON structure for all error responses 2. **Error codes** — application-specific error codes with descriptions 3. **HTTP status mapping** — which errors map to 400, 401, 403, 404, 409, 422, 429, 500 4. **Validation errors** — field-level error details for form validation 5. **Error factory** — utility functions to create errors consistently 6. **Client-side handling** — TypeScript types and error parsing utilities 7. **Localization** — support for error messages in multiple languages 8. **Documentation** — error code reference table for API docs Include the error classes, middleware, and client-side utilities.
How to Use This Prompt
- 1Copy the prompt template above
- 2Paste into Claude, ChatGPT, or Cursor
- 3Replace [bracketed placeholders] with your specific project details
- 4Iterate on the AI output to refine and customize the results
More API Design Prompts
Related api design templates from the vault
Pagination Design Pattern Chooser
Use this prompt to pagination design pattern chooser with AI assistance
API Rate Limiting with Token Bucket and Quotas
Design and implement a multi-tier rate limiting system with token bucket algorithm, per-user quotas, and clear error responses
REST API Naming Convention Guide
Use this prompt to rest api naming convention guide with AI assistance
API Versioning Strategy
Design and implement an API versioning strategy for backward compatibility
You Might Also Like
Prompts from other categories that share similar tags
Try-Catch to Result Pattern
Use this prompt to try-catch to result pattern with AI assistance
API Documentation from Code
Generate comprehensive API documentation from existing endpoint code
Code Documentation with JSDoc
Add comprehensive JSDoc documentation to existing code
Legacy Code Modernization
Modernize legacy JavaScript/TypeScript code to current best practices
Keep Exploring the Vault