⚡AgentSkills
⚙️ 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

  1. 1Require an Idempotency-Key header on POST payments, orders, and signups
  2. 2Store key + request hash + response in a table with TTL cleanup
  3. 3On replay with same payload, return stored response with replayed flag
  4. 4On same key different payload, reject with 422 conflict
  5. 5Expire keys after 24-48h depending on client retry windows
  6. 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-keys
Install globally
$ npx skills add aniruddhaadak80/skills --skill api-design-idempotency-keys -g

Tags

#reliability#payments#api#backend-engineering#api-design

Related skills

Design stable resource-oriented endpoints with deliberate error contracts and pagination.

⚙️ Backend Engineering·~30m

Design stable resource-oriented endpoints with deliberate error contracts and pagination.

⚙️ Backend Engineering·~30m

Run two versions in parallel, observe usage, and sunset safely with real telemetry.

⚙️ Backend Engineering·~40m