Fixed prices, paid once·Written replies within one working day
CheckoutLoom.

Marketing and retentionWin shoppers back

View all marketing →

Support and order careAnswer faster

View all support →

Product contentBetter listings

View all product content →

Inventory and pricingPrices and suppliers

View all inventory →

Finance and riskMoney and disputes

View all finance →

Shopify and WooStore-specific

View all services →

Dropshipping and EtsyMarketplaces and print

View all services →

Explore everything

Pick a way in. Every page has a fixed price and a delivery window.

All services88 automations for storesAll platformsShopify, WooCommerce and moreAll integrations82 tools we connectRequest a quote →

ShopifyStore platform

View all Shopify →

WooCommerceStore platform

View all WooCommerce →

BigCommerceStore platform

View all BigCommerce →

WixStore platform

View all Wix →

AmazonMarketplace

View all Amazon →

EtsyMarketplace

View all Etsy →

eBayMarketplace

View all eBay →

Your platform

Automation built for the store or marketplace you already sell on.

Store platforms8 platformsMarketplaces11 marketplacesAll who we serve363 pagesRequest a quote →

DropshippersSeller type

View all dropshippers →

DTC brandsSeller type

View all dtc brands →

Handmade sellersSeller type

View all handmade sellers →

Subscription boxesSeller type

View all →

B2B and wholesaleSeller type

View all b2b and wholesale →

AgenciesSeller type

View all agencies →

PrintfulPrint-on-demand

View all Printful →

Your kind of store

Pages written for how each type of seller actually works.

Seller types14 types of sellerPrint-on-demand9 platformsPopular audiences20 moreRequest a quote →

Email and SMSKlaviyo, Mailchimp and more

View all email and sms →

Support and chatGorgias, Zendesk and more

View all →

Payments and accountingStripe, QuickBooks and more

View all →

Shipping and suppliersShipStation, DSers and more

View all →

Reviews, ads and creativeJudge.me, Meta Ads and more

View all →

Automation and dataZapier, Make, Sheets

View all →

Marketplace and feed toolsGoogle Merchant, Helium 10

View all →

Works with your tools

We build inside the apps you already pay for.

All integrations82 toolsEmail and SMSKlaviyo, MailchimpPaymentsStripe, QuickBooksRequest a quote →

How-to guidesStep by step

View all 63 how-to guides →

Templates and checklistsCopy and use

View all 68 templates →

ComparisonsTools and options

View all 44 comparisons →

Cost and ROIWhat it costs

View all 34 cost pages →

GuidesLong reads

View all 14 guides →

Compliance and riskRules in plain words

View all →

Glossary and statisticsTerms and numbers

View all 17 →

Learn before you buy

Guides, templates and honest comparisons, free to use.

Resources hub256+ free resourcesBlogPractical articlesStatisticsSourced numbersRequest a quote →
Checkout Loom blog

Duplicate orders and idempotency: why automations run twice and the one habit that stops it

A plain-English explanation for store owners of why the same action can happen twice, the idempotency key pattern that prevents it and how to test your own automations.

  • 9 minute read
  • Written for store owners
  • Sources named
ConnectedShopifyKlaviyoMake

A customer is charged twice for one order. Two parcels arrive at a customer’s door, and the store pays for both. A supplier receives the same purchase order on Monday and again on Tuesday. A welcome email lands three times in a minute. Each of these stories has a villain in the retelling, a glitchy app or a careless contractor, but the cause is usually the same plain fact: something happened twice, and nothing in the system was designed to notice.

This guide explains why repeats happen and the technique that prevents their damage, called idempotency. It is a technical idea, but it is simple to grasp and it is the single most valuable habit in building automations that move money, stock and messages. We use store examples and avoid code. The concept ties together our guides on Shopify webhooks, API rate limits and order routing, because all of them depend on it.

What idempotent means

An action is idempotent if performing it several times has the same effect as performing it once. Setting a thermostat to twenty degrees is idempotent: do it ten times and the room is still at twenty. Adding one degree is not: do it ten times and the room is ten degrees hotter. Many store actions are naturally the second kind, such as sending an email, creating a supplier order, issuing a refund or adding one to a stock count. They only behave safely when repeated if you make them idempotent on purpose.

ActionNaturally idempotent?WhySafe way to repeat
Set a tag on an orderYesThe tag is either there or notNothing special
Set stock to a numberYes, but riskySame result, but may overwrite other changesPrefer adjustments with keys
Add one to stockNoEach repeat adds againUse a key so the add happens once
Send an emailNoEach repeat sends anotherRecord that it was sent for this order and message
Create a supplier orderNoEach repeat creates anotherKey on the store order and line
Issue a refundNoEach repeat pays againKey and check refunded amount first
Charge a cardNoEach repeat charges againUse the payment provider’s idempotency keys

Why repeats happen

  • Retries after timeouts. A webhook receiver is slow, the sender assumes failure and sends again, although the first one eventually succeeded.
  • At-least-once delivery. Many systems promise that an event will be delivered at least once, which means it may be delivered more than once. Shopify’s documentation, for example, says duplicates are minimised but can still occur.
  • Double clicks and refreshes. A customer taps the pay button twice, or a team member presses run twice.
  • Overlapping schedules. A job that runs every five minutes starts again while the previous run is still going.
  • Recovery and replays. After an outage, you replay the missed events, some of which had in fact been processed.
  • Workflow tools that retry failed steps. The step that failed may have partly succeeded before it failed.
  • Two paths to the same effect. A flow and an app both react to the same order.

Because repeats cannot be eliminated, the sensible response is not to try to make the world deliver everything exactly once, which no practical system can guarantee, but to make the receiving side safe. Delivery that may repeat, combined with actions that tolerate repeats, behaves as if everything happened once.

The idempotency key pattern

The standard technique has four steps. Build a key that uniquely identifies the intended action. Check whether that key has been used. If not, do the action. Record the key and, ideally, the result. A repeat of the same request arrives with the same key, finds it recorded and does nothing, or returns the original result.

StepWhat happensExample
1. Build the keyCombine stable facts that identify the actionsupplier-order:shopify-order-10482:line-2
2. CheckLook the key up in a record of completed actionsHas this key been recorded?
3. ActPerform the action only if the key is newCreate the supplier order
4. RecordStore the key and the resultSave the supplier’s order number against the key
5. Repeat safelyA repeat finds the key and returns the saved resultThe second event creates nothing

Choosing a good key

  • Stable. The same logical action must always produce the same key. A timestamp or a random number would defeat the purpose, unless the client generates it once and reuses it on retries.
  • Specific. Include the order, the line and the action, so that different actions on one order do not collide.
  • Free of sensitive data. Payment providers advise against using personal information such as email addresses in keys.
  • Long enough to avoid collisions. Random identifiers generated once per request, such as UUIDs, are a standard choice when the client creates the key.

Payment providers build the pattern into their APIs. Stripe’s documentation, for instance, describes an idempotency key header on create and update requests: the provider saves the result of the first request made with a key and returns the same result to retries, and it compares the parameters of a retry with the original and errors if they differ. It notes that keys can be removed automatically after at least twenty-four hours, so a key reused much later is treated as a new request. Check your provider’s current documentation for the details; the lesson is that the best defence uses both your own record and the provider’s support.

The race condition trap

There is a subtle way to get this wrong. If your system first checks whether the key exists and then, in a separate step, creates the order, two runs arriving at the same instant can both pass the check before either has recorded the key. Both then act, and you have a duplicate despite your careful design. The fix is to make the check and the record a single, atomic step: attempt to insert the key, and treat a failure because it already exists as the signal to stop. Databases support this with unique constraints, and some workflow tools offer a built-in way to claim a key.

DesignWhat can happenVerdict
Check, then act, then recordTwo runs both pass the check and both actUnsafe under simultaneous events
Record first, then actIf the action fails after recording, it never happensSafe from duplicates, needs a retry path for failures
Atomic claim of the key, then act, then mark doneSecond run cannot claim the key; an unfinished claim can be retried after a timeoutRecommended

Idempotency in no-code workflows

Workflow tools such as Zapier, Make and n8n rarely have idempotency built in, but you can add the pattern. Keep a small table, in a spreadsheet, a database or the tool’s own data store, with one row per key. At the start of the workflow, search for the key; if found, stop. If not found, write the key, then proceed. For the race condition, rely on a store that supports atomic writes where simultaneous runs are likely. Our comparison of Zapier, Make and n8n notes how each tool handles retries and duplicates.

  • Add a Do I already have this? step right after the trigger.
  • Use the event’s own ID when the platform provides one, such as a webhook ID.
  • Write the key before the risky action, and mark it complete after.
  • Alert on keys that stay unfinished beyond a timeout.
  • Clean old keys after a retention period, longer than any retry window.

Idempotent design beyond keys

  • Prefer set to add. Where possible, record the desired state rather than a change, so that repeats converge on the same state.
  • Use state machines. An order moves from created to routed to confirmed to shipped; an event that does not fit the current state is ignored.
  • Reconcile. A scheduled check compares what should exist with what does, and fixes both missing and duplicate items.
  • Make side effects visible. Log every action with its key so that a duplicate can be found and explained.
  • Guard money with limits. A cap on refunds per order stops a repeat from paying out twice.

How to test for it

Automations are usually tested by running them once and watching them work. Idempotency problems appear only when things go wrong, so test the wrong paths on purpose.

  1. Replay the same event three times and check that only one action results.
  2. Send two identical events at the same moment to test the race condition.
  3. Interrupt a run halfway, for example by failing the second step, then retry and check for a half-done or doubled result.
  4. Click the button twice on any customer-facing action.
  5. Change a parameter on retry and check that the system rejects or handles the mismatch sensibly.
  6. Replay a day of events after a simulated outage and compare the result with the original.

A worked example

A store routes orders to a supplier through a workflow triggered by an order webhook. During a flash sale the supplier’s API is slow, so the workflow takes eight seconds to respond, and the platform records a timeout and resends 40 of the events. Without idempotency, 40 orders produce 80 supplier orders. At an average cost of $22 per order, that is $880 of unwanted stock, plus the cost of returning or absorbing it and the time to find out. With a key built from the store order and line, checked and claimed atomically, the second events find the key and do nothing. The extra cost of the design is perhaps an hour of build time, which is why it belongs in every workflow that creates things. It is built into our order routing to suppliers and ecommerce workflow automation services, and our Shopify order automation service applies it to tags, holds and notifications.

Sources and further reading

Figures and rules in this guide come from the primary pages below. Platform limits and prices change, so open the page before you build on a number.

Questions

8 questions readers ask about this topic

What does idempotent mean?

An action is idempotent if doing it several times has the same effect as doing it once, such as setting a value rather than adding to it.

Why does my automation run twice?

Common causes are webhook retries after timeouts, at-least-once delivery, double clicks, overlapping schedules, replays after outages and tools that retry steps that partly succeeded.

What is an idempotency key?

A unique key that identifies an intended action. The system checks it before acting and ignores repeats with the same key.

Can I get exactly-once delivery?

Not reliably in practice. Use at-least-once delivery with idempotent actions to get the same effect.

How do I add idempotency in Zapier or Make?

Store keys in a spreadsheet or data store, search for the key at the start, stop if found and write it before the risky action.

What is the race condition problem?

If two runs check for a key at the same instant before either records it, both act. Make the claim atomic, for example with a unique constraint.

Do payment providers support idempotency?

Yes. For example Stripe lets you send an idempotency key with create and update requests and returns the saved result to retries; check current documentation for details.

How do I test for duplicates?

Replay events, send identical ones simultaneously, interrupt runs midway and click twice, then check for single results.

Automations that are safe to run twice

Keys, atomic claims, queues and reconciliation built into every workflow we deliver.

  • Fixed price, paid once
  • Built inside your tools
  • Thirty days of fixes