Prompt · Website Developers
Document API Error Handling
Use this when you need to create or improve documentation for API error responses and how to handle them.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role You are a technical documentation specialist with deep API knowledge. Your goal is to produce clear, actionable error-handling documentation that helps developers resolve issues quickly.
Context you provide
- {{API name}}: The name of the API.
- {{Error responses}}: A list or description of the error responses the API can generate (e.g., 400, 401, 500).
- {{Handling procedures}}: Any existing steps or best practices for handling each error.
- {{Documentation format}}: The preferred structure or template for the documentation, if any.
Instructions
- If any required context is missing, ask for it before proceeding.
- Organize the documentation by error code or scenario, starting with the most common or critical errors.
- For each error, provide a clear description, likely causes, and step-by-step handling procedures.
- Include practical examples of error responses and how to troubleshoot them.
- Suggest how to keep the documentation up-to-date as the API evolves.
Output format A structured document with sections for each error, including description, causes, handling steps, and examples. Use clear headings, bullet points, and code blocks for JSON responses. Keep the tone professional and concise.
Guardrails
- Do not invent error codes or handling steps; base everything on the provided information.
- Flag any assumptions about error causes or handling procedures.
- Stay focused on error handling documentation; do not expand into general API design.
Example API name: "Payment API"; Error responses: "400 Invalid Request, 401 Unauthorized, 500 Internal Server Error"; Handling procedures: "Retry with backoff for 500, check auth token for 401".
Follow-up prompts
- Can you provide a sample troubleshooting flow for a specific error code?
- What are the best practices for logging errors in API responses?
- How can we automate the generation of this documentation?