Skip to main content

Payments glossary Payment infrastructure

What Is an Idempotency Key?

Definition

An idempotency key is a unique value a client sends with an API request so the server can recognize retries of the same request. If a payment call is repeated with the same key, the server returns the original result instead of running it again, which prevents duplicate charges when a network error interrupts the first attempt.

Also called: Idempotency-Key header, idempotent request

How it works and why it matters

In Stripe's API the client sends the key in an Idempotency-Key header. Stripe recommends V4 UUIDs or another random string with enough entropy, allows keys up to 255 characters, and advises against using sensitive data such as email addresses. For API v1, Stripe saves the status code and body of the first request once endpoint execution begins and returns that saved response, including 500 errors, to any retry with the same key. It compares incoming parameters with the original and returns an error if they differ.

Keys can be pruned once they are at least 24 hours old, after which a reused key starts a new request. All POST requests accept keys; GET and DELETE requests are idempotent by definition, so sending a key has no effect.

Recurring billing is where idempotency matters most. Renewal jobs often run in batches, crash midway or time out, and a job that retries without idempotency keys can charge the same subscriber twice. Deriving the key from the invoice ID and attempt number keeps intentional retries distinct from accidental duplicates.

Example

A billing worker creates a charge for invoice 8812 with the key inv_8812_attempt_1, but the connection drops before the response arrives. The worker resends with the same key and receives the original successful response, so the customer is charged once.

Frequently asked questions

What is an Idempotency Key?

An idempotency key is a unique value a client sends with an API request so the server can recognize retries of the same request. If a payment call is repeated with the same key, the server returns the original result instead of running it again, which prevents duplicate charges when a network error interrupts the first attempt.

Should a payment retry after a decline reuse the idempotency key?

No. A deliberate retry after a decline is a new payment attempt and needs a new key; reusing the old one would just return the saved decline. Reuse a key only when resending a request whose outcome was never received.

Related terms

Related tools and guides

Sources

Sources checked November 2026. Card network and scheme rules change; confirm current rules with your payment provider.

More payment infrastructure terms

Losing subscription revenue to failed payments?

Slicker recovers failed recurring payments with smart retries driven by decline codes and Merchant Advice Codes, plus hyper-personalized emails when the customer has to act. It runs on your existing billing platform, and you only pay when it outperforms your current setup in a 50/50 test.

Cookie preferences

Your privacy matters

We use analytics to understand how you use our site and improve your experience. Privacy Policy