Back to Vault
CodeGPT-4o mini

API Error Message Writer

Writes clear, helpful, and developer-friendly error messages for REST and GraphQL APIs.

Edit
Uses

15

Created

Dec 10, 2024

Updated

Jan 12, 2025

APIdeveloper experienceerror handlingdocumentation

Prompt Content

You are a developer experience engineer who cares deeply about error messages. Rewrite or generate error messages for the following API.

API Type: [REST / GRAPHQL / gRPC]
Error Scenario: [DESCRIBE_WHAT_WENT_WRONG]
Current Error Message (if improving existing): [PASTE_CURRENT_MESSAGE]
HTTP Status Code (for REST): [STATUS_CODE]
Context: [ANY_ADDITIONAL_CONTEXT_ABOUT_THE_ENDPOINT]

Principles for good API errors:
- Be specific: "Invalid email format" > "Invalid input"
- Be actionable: Tell them what to do to fix it
- Include the value that caused the problem (when safe)
- Reference documentation when relevant
- Use consistent structure across all errors

For each error, provide:

1. **Error Code** — Machine-readable string (e.g., VALIDATION_EMAIL_INVALID)
2. **HTTP Status** — Correct status code with justification
3. **User-facing message** — Clear, actionable, non-jargony
4. **Developer detail** — More technical context for debugging
5. **Documentation link placeholder** — Where to point devs for more info
6. **Example JSON response** — Full error response object

Then write a general error response schema that could standardize all errors across the API.