idempotency_key_in_use 🔌 API

API Error: Idempotency key reused with different parameters (idempotency_key_in_use)

An Idempotency-Key header was sent again with a different request body, or while the first request with that key was still running.

Seen on: REST API

Meaning

Idempotency keys let you safely retry a POST (charge, order, transfer) — the server stores the first result and replays it for the same key. To be safe, the server also checks that the retry is the same request. Stripe returns “Keys for idempotent requests can only be used with the same parameters they were first used with”, and idempotency_key_in_use (409) when the original request hasn’t finished yet.

Common causes

  • The same key reused for a genuinely new operation (key not unique per operation)
  • Retry changed the body (new timestamp, different amount, reordered fields)
  • Two concurrent retries with the same key
  • Key derived from something non-unique (user ID, date)

⚡ Quick fix

  1. Generate a new UUID per logical operation and store it with the pending operation
  2. Reuse the key only for exact retries of the same body
  3. Wait and retry after a short delay if the original is still in progress

Detailed fix by platform

Node.js

  1. javascript
    import { randomUUID } from 'node:crypto';
    const key = order.idempotencyKey ??= randomUUID();   // persist with the order
    await stripe.paymentIntents.create(params, { idempotencyKey: key });

Python

  1. stripe.PaymentIntent.create(**params, idempotency_key=order.idempotency_key) # same key ONLY for identical retries

How to diagnose

  1. Key — Where is it generated and how unique is it?
  2. Body — Diff the first and the retried request
  3. Timing — Was the first request still running?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.