TECHHAWKS

Software · Glossary

Idempotency

Idempotency is the property of an operation that produces the same result whether it is performed once or repeated several times with the same input.

Definition

Idempotency is the property of an operation whereby performing it more than once has the same effect as performing it once. Setting a booking's status to cancelled is idempotent: repeating it leaves the booking cancelled. Adding a charge to an account is not idempotent unless designed to be, because each repetition adds another charge.

Idempotency matters because networks are unreliable. A request can succeed on the server while the response is lost, so the client cannot tell whether to retry. Webhook senders and message queues also commonly deliver the same message more than once. In HTTP, GET, PUT and DELETE are defined as idempotent, while POST is not. To make operations such as payments safe to retry, APIs often accept an idempotency key: a unique value the client sends with the request. The server stores the result against that key and, if the same key arrives again, returns the original result instead of repeating the action. Event handlers achieve the same effect by recording which event identifiers they have already processed.

Example

A hypothetical guest portal sends a payment request for a deposit, but the mobile connection drops before the confirmation arrives. The app retries with the same idempotency key. The payment provider recognises the key, does not charge the card again, and returns the result of the first attempt.

Why it matters

Without idempotency, ordinary network problems turn into duplicate charges, double bookings, repeated emails and inflated figures. These errors are often discovered only when a customer complains or a reconciliation fails. Designing integrations and automations so that every retry is safe is one of the less visible but most important parts of building systems that move money or update records. Logging every retry and its outcome also makes problems far quicker to trace.

Tell us what needs building.

Thirty minutes with the engineers who would build it. Free, no commitment.

Book a call