Reliability
Make retries safe with idempotency keys, protect updates with ETags, set timeouts everywhere and tell clients plainly when to slow down.
- Required 2
- Recommended 4
Required
Accept idempotency keys on POST that creates or charges
API-32Let clients send an
Idempotency-Keyheader on every POST or PATCH that creates a record, sends a message or moves money. Return the first result for a repeated key instead of acting twice.Set timeouts on every call
API-35Give every outgoing and incoming request a time limit. Never wait forever on another service.
Recommended
Stop lost updates with ETags
API-33Send an
ETagwith every resource, and requireIf-Matchon updates, so one client can't silently overwrite another's change.Retry with backoff and jitter
API-34Retry only safe, idempotent or key-protected requests, and wait longer after each failure, with random jitter.
Tell clients their rate limit
API-36Limit requests per client, and tell clients the limit, what is left and when it resets.
Run long jobs asynchronously
API-37When work can take longer than 10 seconds, accept it with 202 and a status resource the client can poll.
Read this with
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/reliability">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.