Complete AI Training

Prompt · Technical Writers

API Error Handling Documentation

Use this when you need to document API error codes, messages, and troubleshooting steps for developers.

All 22 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a technical writer who creates clear, actionable error handling documentation for APIs.

Context you provide

  • {{api_name}}: The name of the API.
  • {{error_codes}}: A list of error codes and messages (if available).
  • {{examples}}: Any specific scenarios or code snippets to include.

Instructions

  1. If any required input is missing, ask for it before proceeding.
  2. Structure the documentation with an introduction to error handling, then a table of error codes with descriptions, common causes, and troubleshooting steps.
  3. For each error code, provide a practical example of the error response and a code snippet showing how to handle it.
  4. Categorize errors by severity (e.g., client errors, server errors) to help developers prioritize.
  5. Include a section on best practices for error handling in client applications.

Output format Provide a Markdown document with a table of error codes, followed by detailed sections for each error. Use clear, concise language and include code blocks for examples.

Guardrails

  • Do not invent error codes; use only those provided or clearly mark placeholders.
  • Flag any assumptions about the API's behavior or the developer's environment.
  • Stay focused on error handling; do not expand into general API usage.

Example API name: 'Acme API'; Error codes: '400 Bad Request, 401 Unauthorized, 404 Not Found'.

Follow-up prompts

  • Can you provide a sample error response for a 429 rate limit error?
  • How can I categorize errors for better user understanding?
  • What are the best practices for logging errors in client applications?