Glossary
Idempotency key: making retries safe
An idempotency key is a unique value that lets a server recognize a repeated request and avoid doing the work twice. How it works and where to use it.
Updated 2026-11-23
An idempotency key is a unique value that a client sends with a request so that the server can detect repeats. If the same key shows up again, the server does not perform the action a second time. It returns the outcome it saved for the first attempt. The goal is safe retries.
How it works
Networks fail in the middle. A client sends a request, the server does the work, the response is lost and the client does not know whether it succeeded. Retrying risks doing the work twice. Idempotency makes the retry harmless.
HTTP already defines which methods are idempotent (RFC 9110): GET, HEAD, PUT, DELETE, OPTIONS and TRACE. POST is not, and that is where keys come in.
The pattern:
| Step | Detail |
|---|---|
| 1 | The client generates a unique value, such as a random UUID, per logical operation |
| 2 | It sends it in a header, commonly named Idempotency-Key |
| 3 | The server stores the key with the result of the first request |
| 4 | A repeat with the same key returns the stored result and does nothing else |
Rules that make it work:
- One key per operation, not per attempt. Reuse the same key on every retry of the same request.
- Bind the key to the request. If the same key arrives with a different body, reject it: it is a client bug.
- Expire keys. Servers keep them for a limited time, such as a day.
- Store the result atomically with the action. A crash between the two defeats the purpose.
The same idea applies on the receiving side of messages. A webhook can be delivered more than once, so the receiver keeps the id of each event it has handled and ignores repeats. In Qelka's webhooks the event id starts with evt_ and stays the same when the event is delivered again.
Why it matters for validation
Validation calls are mostly reads. A repeated lookup returns the same kind of answer, so retries are safe without keys: look at the errors guide for which failures to retry, and the rate limits page for how to back off. Results are cached for 7 days, and fresh: true skips the cache, as the caching page explains.
Idempotency matters around validation:
- Handling webhooks such as
bulk.completed: deduplicate on the eventid. - Sending codes after a phone check: key the send by user and purpose, so a retry does not text twice or cost twice. This also helps against SMS pumping.
- Creating accounts after a verified email: a retry must not create a second account.
- Granting rewards once: a double submit should not pay twice.
Combine keys with rate limiting for sensitive actions.
Related
Frequently asked questions
What is an idempotency key?
Which HTTP methods are idempotent?
Does the Qelka API need an idempotency key?
id, which stays the same when an event is redelivered, to skip events you have already handled.Put this check in your product
Get an API key in under a minute. 100 free credits every month, no card required.
- 100 free credits a month
- No card
- Test keys spend nothing
- Cancel any time