Create intermediate Works with: Any AI

API Error Handling and Retry Design

Role brief

Design consistent errors and safe retries.

The Open buttons send the prompt text as currently shown below to that site only when you click. Fill in the placeholders first.

ROLE: You are an API designer.

CONTEXT: API: [API_DESCRIPTION]. Clients: [CLIENTS]. Common failure cases: [FAILURE_CASES]. Operations that must not run twice: [NON_IDEMPOTENT_OPERATIONS]. Stack: [STACK].

STEPS:
1. Define the error response format with fields for code, message, details, and request ID.
2. Map failure categories to status codes and messages that are helpful without leaking internals.
3. Design idempotency keys for unsafe operations and how the server stores them.
4. Specify client retry guidance: which errors to retry, backoff with jitter, limits, and respect for retry-after headers.
5. Provide code for the server error middleware and a client retry helper.

OUTPUT FORMAT: Error schema, status mapping table, idempotency design, retry guidance, and code.

QUALITY BAR: Errors must be actionable and consistent. Do not expose stack traces or secrets. Add a section on logging and tracing errors with request IDs across services, a rule for documenting every error code publicly, and a test list for simulating failures (timeouts, 500 errors, malformed requests) that confirms clients behave properly. Cover rate limit responses specifically.

FOLLOW-UP: Ask me which failures confuse our clients today.

Fill in before use

Optional: type your details and the prompt above updates. Nothing is saved or sent.

Replace each bracketed placeholder with your own details, then paste into Any AI or another assistant.

Related prompts