⚙️ Backend Engineering · API Design
Make writes safe with idempotency keys
Accept retried mutations gracefully by keying operations so duplicates return the original result.
intermediate~30 minBackend EngineersAPI DevelopersPlatform Engineers
Steps
- 1Require an Idempotency-Key header on POST payments, orders, and signups
- 2Store key + request hash + response in a table with TTL cleanup
- 3On replay with same payload, return stored response with replayed flag
- 4On same key different payload, reject with 422 conflict
- 5Expire keys after 24-48h depending on client retry windows
- 6Load-test double-submit behavior before launch week
Common Pitfalls
- ▲Keying only by user ID, colliding legitimate new requests
- ▲Storing responses forever without TTL or encryption
Commands
Install with skills CLI
$ npx skills add aniruddhaadak80/skills --skill api-design-idempotency-keysInstall globally
$ npx skills add aniruddhaadak80/skills --skill api-design-idempotency-keys -gTags
#reliability#payments#api#backend-engineering#api-design