Idempotent describes an action or operation that produces the same result regardless of whether it is performed once or multiple times. Applying the action a second, third, or hundredth time causes no further change to the system or value
The term is widely used across mathematics, computer science, and everyday logic
Everyday Examples
- Pressing an elevator button: Pressing the "open door" button once opens the door. Pressing it five more times has no additional effect; the door simply stays open.
- Flipping a light switch: If the light is on, flipping the "on" switch repeatedly leaves the light on
Computer Science & APIs
In programming, idempotency is crucial for building reliable software and APIs. It ensures that if a system encounters an error and retries a request, it won't cause unintended duplicates or server damage
- Safe / Idempotent (e.g., GET, PUT, DELETE): Requesting a user's profile 10 times is safe, and deleting a file 10 times results in the file being gone, not deleted 10 times
- Not Idempotent (e.g., POST): Charging a credit card via a POST request usually creates a new transaction every time you send it. Sending the request twice might charge you twice
Mathematics
In abstract algebra, an idempotent element is one that remains unchanged when it is multiplied by itself
- For example, multiplying 1 × 1 = 1, or 0 × 0 = 0. Both 1 and 0 are idempotent numbers.
Origin
Coined in the 1870s by American mathematician Benjamin Peirce, the word literally means having "the same power" (from the Latin idem, meaning "the same", and potentem, meaning "powerful")