Idempotency key
Definition
An idempotency key is a client-generated unique value sent with a non-idempotent request; the server stores it with the outcome and returns the stored outcome when the same key arrives again.
In practice
A timed-out call may have succeeded, so a client cannot safely retry a charge or an order without a way to say "this is the same request". The key, often sent as an Idempotency-Key header, turns the retry into a lookup. Payment systems store it before calling the provider and pass it on, so retries are safe end to end.
The key must be generated once per logical operation, not per attempt, and saved in the same transaction as the side effect, or a crash between the two leaves you guessing. Reject a reused key with a different request body, decide how long keys are kept, and handle concurrent requests with the same key, for example with a unique constraint.
Example
Checkout sends POST /payments with Idempotency-Key: 9b1e-4c2a; the first attempt times out, the retry finds the stored 201 and the card is charged once.