♻️ API & Integration · APIs & Integration
Idempotency
Repeating the same request should not create unintended duplicate effects.
It is especially important when clients retry uncertain requests.
A payment request with the same idempotency key does not charge the customer twice.
💡 Like a light switch set to "on": flip it once or flip it five times, the light is still just on — no extra effect from repeating.
💡 Why it matters
Networks drop responses, so a client often cannot tell whether its request really worked, and it retries. If the operation is idempotent, that retry is harmless. If it is not, retries create duplicate orders, double charges and other painful errors. Idempotency is what makes safe retries possible.
🛠️ How to achieve it
⚠️ Signs of trouble
- •Retries create duplicate orders or records.
- •Customers are charged twice on a flaky connection.
- •There is no key to tell a repeat from a new request.
- •The same action produces different totals each time it reruns.
🎯 Quick check
Score: 0/3Three questions to test the idea.
1. What does idempotency guarantee?
Answer: Repeating a request has the same effect as doing it once
An idempotent operation can be repeated safely — doing it twice has the same effect as doing it once.
2. Why does an idempotency key help with payments?
Answer: A repeated request with the same key does not charge twice
The server recognizes the key as a repeat and returns the first result, so a retried payment charges the customer only once.
3. When is idempotency most important?
Answer: When clients retry requests whose outcome is uncertain
Dropped responses make clients retry without knowing if the first call worked; idempotency keeps those retries harmless.
