UUID Use Case

UUID Idempotency Key

Network retries can double-charge a customer. An idempotency key — a UUID you generate once — lets the server deduplicate repeated calls.

Prevents duplicatesClient-generatedv4

Generated locally with the Web Crypto API — nothing leaves your browser.

What Is UUID Idempotency Key?

How to generate

  1. Generate one v4 UUID per user action (e.g. 'submit order').
  2. Send it as the Idempotency-Key header on every retry.
  3. Persist the key→result mapping server-side for the retention window.

Use Cases

Code Examples

JavaScript
fetch('/charge', {
  method: 'POST',
  headers: { 'Idempotency-Key': crypto.randomUUID() },
  body: JSON.stringify(payload)
});

Frequently Asked Questions

Who generates the idempotency key?
The client, once per logical operation. Reusing the same UUID on retries is exactly the point.
How long should the server remember it?
Long enough to cover the retry window — typically 24 hours to a few days.

Related tools