# Idempotency

> Idempotency is the property of an operation that produces the same result whether it runs once or several times, so a retried or duplicated request does not create a second invoice, email or record.

Also called: idempotent, idempotency key, exactly-once processing, deduplication. Category: Delivery and quality. Source: https://aibuildindex.com/glossary/idempotency

## In the index

- Webhooks: median $1,500, middle half $400 to $6,160, 427 priced briefs (https://aibuildindex.com/skills/webhooks)
- API integration: median $2,500, middle half $500 to $7,680, 11,407 priced briefs (https://aibuildindex.com/skills/api-integration)

In real systems the same request often arrives twice. A webhook is redelivered because the first response was slow, a user double-clicks a button, a [scheduled job](https://aibuildindex.com/glossary/scheduled-job) is rerun after a crash. Idempotency means designing each step so that repeating it is harmless. It is an unglamorous engineering term, but the absence of it is what produces duplicate charges, double emails to customers and inflated reports, which is why buyers of automation work should know the word.

## How it works

The usual technique is to give each piece of work a unique identifier and check it before acting. A payment request carries an idempotency key; if the payment service has already seen that key, it returns the original result instead of charging again. A sync job that creates contacts in a CRM looks up the contact by email first and updates it rather than creating a duplicate. A [webhook](https://aibuildindex.com/glossary/webhook) handler records the event ID of everything it has processed and ignores repeats.

Some operations are idempotent by nature. Setting a field to a value is safe to repeat; adding to a running total is not. Good builders prefer the first kind where they can, so "set the order status to shipped" rather than "move the order to the next status".

An example: an automation sends a welcome email when a new customer signs up. The sign-up webhook is delivered twice. Without idempotency, the customer gets two emails and two CRM records. With it, the second delivery is recognised by its event ID and skipped.

## What it means for cost

Idempotency adds a modest amount of design and testing time, usually a lookup table or a key on each request. It is far cheaper to build in from the start than to retrofit after duplicate data has spread across several systems and needs cleaning. It is also what makes [error handling](https://aibuildindex.com/glossary/error-handling) safe, since retries are only harmless when repeated steps do no damage.

Ask a builder what happens if a webhook arrives twice, if a run is restarted halfway through, or if a user submits the same form twice. A clear answer about keys, lookups or deduplication is a good sign.

## Common questions

### Is idempotency the same as exactly-once delivery?

Not quite. Most messaging systems guarantee that a message arrives at least once, which allows duplicates. Idempotent processing turns at-least-once delivery into an exactly-once effect, because handling a repeat has no further consequence.

### Do no-code automation tools handle idempotency?

Partly. Some triggers deduplicate items they have already seen, but actions that create records usually do not check for duplicates on their own. In n8n, Zapier or Make, a builder normally adds a "find or create" step or a lookup to make the flow safe to rerun.

## Related terms

- [Error handling and retries](https://aibuildindex.com/glossary/error-handling): Error handling and retries are the parts of an automation or AI system that detect failed steps, try them again where that is safe, and report or park the work that still fails, so problems are noticed rather than silently lost.
- [Webhook](https://aibuildindex.com/glossary/webhook): A webhook is an automatic message one system sends to another over the web when an event happens, such as a payment succeeding or a form being submitted, so the receiving system can react immediately without repeatedly checking for changes.
- [Message queue](https://aibuildindex.com/glossary/message-queue): A message queue is a component that holds tasks or events in order until a worker is ready to process them, so systems can hand off work without waiting, absorb spikes in volume and retry failures safely.
- [Event-driven architecture](https://aibuildindex.com/glossary/event-driven-architecture): Event-driven architecture is a way of designing software in which components react to events, such as a new order or a signed contract, as they happen, rather than checking for changes on a timetable or calling each other directly.
- [API](https://aibuildindex.com/glossary/api): An API, or application programming interface, is a defined way for one piece of software to request data or actions from another, such as fetching a customer record, sending a message or calling an AI model, without a person using a screen.
- [Scheduled job (cron)](https://aibuildindex.com/glossary/scheduled-job): A scheduled job is a task that a system runs automatically at set times or intervals, such as every hour or each weekday at six, often defined with a cron expression; it is the simplest way to start an automation without a person.
