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.

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 37 mock REST APIs