Testing idempotency keys and safe retries

A POST that times out is the hardest case in client design: the request may have succeeded, and you cannot tell. Idempotency keys resolve it by making the retry safe. The APIs below accept an Idempotency-Key header and replay the original response rather than performing the work again.

Idempotency key testing — request and response sequence Sequence diagram for Idempotency key testing: GET /bank/v1/transfers/{id} answers 200 OK. POST /bank/v1/transfers answers 201 Created. POST /webhooks/v1/deliveries/{id}/replay answers 409 Conflict. Your client Fun API Playground GET /bank/v1/transfers/{id} 200 OK The transfer POST /bank/v1/transfers 201 Created Transfer executed POST /webhooks/v1/deliveries/{id}/replay 409 Conflict Max attempts (3) already reached
Real endpoints from the catalog — every request above is served, and every status code shown is one that endpoint actually returns.

How to practise it

  1. Create a resource with an Idempotency-Key, then send the identical request again and confirm you get the original response — same id, same body.
  2. Change the body but keep the key, and see how the API reports the mismatch.
  3. Send the same body with a different key and confirm you get two distinct resources, which is the correct behaviour.
  4. Transfer money on the Bank API with a repeated key and verify the balance moved exactly once.
  5. Combine with the Fault Injection API: inject a timeout, retry with the same key, and check the end state is correct.

APIs to try it on

Status codes involved

Other techniques

Getting started guide · All 39 mock REST APIs

Last updated