You order a flat white, the card machine hangs, and you are not sure it went through. Pay again and you might pay twice. An idempotency key is the receipt number you can show the barista: if this order has already been made, make it no more.
The rule
Every write to Ledgerly carries a key the caller chooses. The first request with that key does the work and we store its answer. Any later request with the same key gets the same answer back, without doing the work again.
curl https://api.ledgerly.example/v1/transactions \ -H "Idempotency-Key: order-58213-capture" \ -d amount=12000 -d currency=gbpUnder load
Two requests with the same key can arrive in the same millisecond. The first takes a lock on the key; the second waits for the answer instead of starting the work. It is the same fixed-order locking we use for balances, applied to keys.