Log inBook a Demo
BuildMidBackendAuto-graded

Honor an Idempotency-Key so retries don't double-charge

Anticipating that the same request can arrive twice, and charging the customer only once, is the signal here.Clients retry, networks drop the response after the charge has already gone through, and users double-click Pay. The agreed defence is the Idempotency-Key: the client attaches a stable key to each logical request and the server guarantees the side effect happens exactly once per key, with every retry receiving the same response the first call produced. handle(request, idempotency_key, backend) honours none of that. Make it.
30 min
python

You're done when

  • Replaying a request with the same key charges exactly once.
  • The replay returns a response identical to the first one.
  • That response is the stored original, not a freshly recomputed lookalike.
  • Requests for several keys interleaved together still deduplicate correctly, per key.
  • Each key replays its own original response, with no cross-contamination between keys.

What it measures

API designImplementing the idempotency contract as callers actually rely on it — exactly-once effect plus a stable replayed response.
API testingSeparating 'charged once' from 'returned the same answer', which are two distinct promises that fail independently.
Reasoning about retriesTreating redelivery as the normal case and keying state so concurrent, interleaved retries stay correct.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

30 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo