# Idempotency in plain words: why a retry must not charge twice

> An operation is idempotent when doing it twice has the same effect as doing it once. What that means for payments and retries, and how an idempotency key works.

Source: https://hintvo.com/blog/idempotency-in-plain-words | Last updated: November 20, 2026 | Reviewed: 2026-11-20

An operation is idempotent when doing it twice has the same effect as doing it once. It matters because networks fail in the middle of things: a request can succeed while its reply gets lost, and the only safe response to a lost reply is to try again.

## The one-sentence version

Pressing the button for a lift is idempotent: press it five times and one lift comes. Placing an order is not, unless someone designed it to be.

## Why it comes up

A client sends a payment request and the connection drops before the answer arrives. Did the charge happen? The client cannot know. If it does nothing, a customer may not be charged. If it tries again and the first attempt did go through, the customer is charged twice. Idempotency is what makes trying again safe.

## How an idempotency key works

1. The client creates a unique key for the thing it wants done, for example one key per order, and sends it with the request.
2. The first time the server sees the key, it does the work and stores the key together with the result.
3. When the same key arrives again, the server does not repeat the work. It returns the stored result.

```http
POST /charges
Idempotency-Key: order-8841

{ "order": 8841, "amount": 4900 }
```

The key belongs to the intent, not to the attempt. Every retry for the same order sends the same key. A new order gets a new key.

## What is idempotent already

- Reading something.
- Setting a value to a fixed number. Setting the stock to 5 twice still gives 5.
- Deleting by id. Deleted twice is still deleted.

Not idempotent without help: adding 1 to a counter, creating a record, sending an email, charging a card.

## Questions you will hear in a meeting

- What happens if this job runs twice?
- Who creates the key, the client or the server?
- Where is the key stored, and for how long?
- What do we return on the second attempt: the first result, or an error?

## In an interview

It appears in system design whenever a queue, a retry or a payment does. A strong answer names the failure, which is the lost reply, says where the key is stored, and adds that checking the key and writing the result must happen together. Otherwise two requests arriving at the same moment can both pass the check.

> **Where Hintvo fits:** when a term like this comes up in a call, the In plain words card explains it in one sentence, in the context of your project. When someone asks how your own code handles it, the answer names the file and line. The sample meeting on the [home page](https://hintvo.com/#replay) is about exactly this: retries for failed payments, and the idempotency key they need first.

## Related

- [Retries and backoff in plain words](https://hintvo.com/blog/retries-and-backoff-in-plain-words.md): What are retries and exponential backoff, in plain words?
- [Race conditions in plain words](https://hintvo.com/blog/race-conditions-in-plain-words.md): What is a race condition, in plain words?
- [How to explain a technical term in plain words](https://hintvo.com/blog/explain-technical-terms-in-plain-words.md): How do I explain a technical term to people who are not engineers?
