Idempotency Keys: Retrying a Write Safely
Idempotency keys: letting a client retry a payment or an order after a timeout without it happening twice.
A client that sends a payment and hears nothing back faces a choice with no safe answer: retry and risk paying twice, or give up and risk not paying at all. An idempotency key removes the choice. The client labels the write with a unique value, and the server promises to act on that label once, however many times it arrives.
The topic opens on why the same write reaches a server twice. A walkthrough follows one payment through a lost response and a keyed retry, and a rules card covers how long a key lasts, who it belongs to, and how a server answers a key that is misused. A gotcha shows the race that defeats a careless implementation, and an exercise applies the key to a hotel booking.
It builds on safe and idempotent methods from the first topic in this subject, and on the 409 and 422 status codes.
By the end you can say which requests need a key, trace a retried write to a single charge, and choose the response to a key that is misused.
Contents
6 cardsnot started