Part 05 / Topic 5 of 7
Idempotency keys
Retrying a GET is free; retrying a POST can double-charge, double-create, double-ship. APIs that take writes seriously accept an idempotency key — a unique id you generate per logical operation and send as a header:
headers = {"Idempotency-Key": "sync-2025-04-01-S-2001-status"}
If the first attempt actually succeeded but the response was lost, the retried request with the same key returns the original result instead of performing the write twice. If the customer's API supports it, use it for every write; if it does not, design your writes as upserts (Part 7) so retries are safe anyway.
Done here? The practice set for Part 5 — 4 exercises with solutions — is on the part page.