You hit "Pay" and the browser spins. Network timeout. Did the charge go through? You retry — and get charged twice.

Idempotency keys solve this. They're one of the most important API patterns you can implement, and they're still missing from most homegrown APIs.

What Is an Idempotency Key?

An idempotency key is a unique client-generated token attached to a request. If the server receives the same key twice, it returns the same result as the first request without re-executing the operation.

Stripe pioneered this pattern for payments. The concept is now widespread across financial, messaging, and any API where duplicate side effects are dangerous.