System Design
10. API Design and ManagementAnimated
API Idempotency
Safe retries of API calls.
The idea
Clients send an idempotency key so repeated requests have one effect.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- current message
- earlier
- failure or attack
The client attaches a unique key to a risky request.
- step:
- 1/6
- from:
- Client
- to:
- API
1/6
Time runs downward. Solid arrows are requests, dashed arrows are replies.
Step by step
- 1Client generates a key
- 2Server stores the result by key
- 3A retry returns the stored result
- 4No duplicate action
Where it is used
Payments and orders.
Watch out for
Store keys long enough to cover retries.