# Idempotency

> When doing something twice has the same result as doing it once.

**Field:** Software Development  
**Category:** APIs  
**Also known as:** Idempotent, Idempotency Key, Idempotent Request

## Think of it like

Think of it like a lift button. Pressing it five times calls the lift once.

## Definition

An action is idempotent when doing it twice gives the same result as doing it once. In HTTP, GET, PUT and DELETE are meant to work this way, and POST is not. This matters when a network drops and a client cannot tell if a request arrived. If the action is safe to repeat, the client can just send it again. Payment APIs add a special key to each POST, so a retry never charges twice.

## Example

Emma's app sends a payment with an idempotency key. The network drops, the app sends it again, and the card is charged only once.

## Example code

```http
POST /payments HTTP/1.1
Idempotency-Key: 8f2c-41a7

{"amount": 2500}
```

The same key on a retry tells the server it has seen this payment.

## Why it matters

Networks fail all the time. Idempotent actions turn a scary retry into a safe one.

## Common mistake

Sending a POST again with no key to mark it. One lost answer becomes two orders.

## Three principles

- **Twice equals once.** Same end result.
- **GET, PUT, DELETE.** Meant to be idempotent.
- **Keys for POST.** Make retries safe.

## Related terms

- [POST Request](https://learn.benibix.com/term/infrastructure/post-request)
- [PUT Request](https://learn.benibix.com/term/infrastructure/put-request)
- [Rate Limiting](https://learn.benibix.com/term/development/rate-limiting)
- [Application Programming Interface (API)](https://learn.benibix.com/term/development/api)
- [Background Job](https://learn.benibix.com/term/development/background-job)

---

Source: https://learn.benibix.com/term/development/idempotency
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
