An idempotency key is a client-generated UUID attached to an operation and every retry. The receiver uses it to recognize duplicates and return a consistent result. section 4.5
The key makes a normally non-idempotent operation, such as charging a credit card, behave consistently when messages are duplicated. Reliable deduplication requires recording the key transactionally with the side effect and enforcing uniqueness. section 4.5
Retrying an airline booking
If checkout times out, the app retries with the same reservation number as the key. A payment API can save the first status and response, then return that same result for later requests, including failures. section 4.6
Listing 4.1 Transactional recording and processing
requests := { }
on message request do
if request in received then
return response
end
begin transaction #1
process(request) #2
received = received + request #2
commit transaction
return response
end
Follow the transactional flow: check whether the request was received, process it, record it, commit both together, and return the response. section 4.5

