Why idempotency matters
When you build an API, retries are inevitable. Clients lose connections, timeouts happen, and users double-click buttons. Without idempotency, a retried request can create duplicate orders, charge a credit card twice, or send two emails. Idempotency ensures that the same request, applied multiple times, has the same effect as applying it once.
What is idempotency?
An operation is idempotent if performing it once or multiple times produces the same result. In HTTP, GET, PUT, DELETE are naturally idempotent. POST is not, because it creates new resources. But we can make POST idempotent by using an idempotency key.
The idempotency key pattern






