Skip to content
Workflow Design

How to Prevent Duplicate Actions in an Automation Workflow

Use stable identifiers, destination checks, and a documented repeat policy to avoid duplicate tasks, posts, or records when a workflow runs twice.

One event, one action. A slow response does not mean nothing happened.
Original explanatory diagram by OptimaFlow AI; not a product screenshot.

A workflow that runs twice should not do the work twice. Retries, duplicate webhooks and a second click after a slow response are normal — the fix is not to stop the second run but to make it harmless. The property has an unfriendly name, idempotency: running a step a second time produces the same result as running it once. Build it in before the step can charge, send or create anything.

Identify the original event

Choose a reference that belongs to the source event, such as an enquiry ID or meeting action ID. A newly generated timestamp on every run does not identify the same event twice. Keep the reference through the workflow so the destination can recognize a repeat.

Define the scope. An enquiry ID may identify the enquiry, while a separate action type identifies a draft response. One source can legitimately produce several different outputs; the reference should distinguish those without treating each retry as a new task.

Check before creating

Look for an existing destination record using the stable reference. If it exists, decide whether to skip, update, or route for review. The correct behavior depends on the task. Updating a draft may be acceptable while resending a customer message may not be.

A search followed by creation can still race when two runs happen simultaneously. Use the destination’s supported uniqueness or idempotency mechanism where available, and inspect its current documentation. Do not claim that a simple lookup guarantees duplicate prevention under every condition.

Treat uncertain outcomes carefully

A timeout means the workflow did not receive a clear response in time. The destination may already have completed the action. Before retrying a create operation, inspect whether the record exists.

Store the returned destination ID when an action succeeds. If the response is lost, use the source reference to reconcile. For high-impact actions, prefer a review queue over guessing. Repetition can be more harmful than a delayed result.

Test repeat scenarios

In an appropriate test environment, submit the same fictional event twice. Test a normal retry and an uncertain response. Confirm which record is kept and what the log reports. Avoid experimenting with repeated real payments or customer messages.

Also test changed input under the same source reference. The workflow may need a version or revision marker to distinguish a legitimate update from a duplicate. Document the policy so another maintainer does not accidentally change it.

Make reconciliation part of operations

Keep enough non-sensitive logging to connect a source event, run, and destination record. Define who resolves conflicts and how corrections are made. A duplicate detection alert is useful only when someone owns the response.

Pair this plan with our retry guide and troubleshooting checklist. Your next step is to write one sentence describing what the workflow does when it sees the same event again.

Example: a timed-out draft creation

A workflow asks WordPress to create a draft and receives no clear response. Before repeating the request, check for the source reference in the intended destination. If a draft already exists, record its ID and route any uncertainty instead of creating another copy.

Now imagine the input text changed after the first run. The repeat policy must distinguish an update from a new article. Use an explicit revision decision, not a new random identifier. This keeps one source event connected to its intended output.

A partial safeguard

A destination lookup can reduce duplicates but may not prevent simultaneous runs from both creating records. Verify the platform’s supported uniqueness mechanism and test the relevant concurrency case.

Which operations are safe to repeat

OperationSafe to repeat?Why
ReadYesReading twice changes nothing
Update a record by its IDUsually yesSetting the same field to the same value leaves the same result
Create / append a rowNoA second run creates a second record
Send an email or messageNoThe recipient gets it twice
Charge a paymentNoThe customer is charged twice
Create an order or ticketNoTwo orders, two tickets, one customer

Reads are safe. Updates to a specific record by its identifier are usually safe. Creates are the dangerous ones — and so is anything that sends, charges or notifies, because those have effects outside your database that you cannot undo by setting a field back. For every step that is not naturally idempotent, you need either a key that lets the receiving system recognise a repeat, or a check that stops you making the call at all. Duplicates are worse than failures, because failures are red and duplicates look like success. When a duplicate slips through anyway, work through the automation troubleshooting checklist.

The idempotency key

An idempotency key is a unique label for one intended action. Send it with the request; if the same request arrives again with the same key, the system recognises it as the same operation and returns the previous result instead of repeating the action. Stripe’s API documentation is the clearest explanation of the pattern: it saves the status code and body of the first request made for a given key — whether it succeeded or failed — and a repeat returns that same result, including server errors. The rules that make it work:

RuleWhat it means
One key per intended actionThe key names the action, not the network attempt
Same key across retriesA new key on every attempt defeats the purpose — the server treats each as a new request
New key for a new actionTwo different jobs must never share a key
Random, high-entropy valueA UUID v4 or another random string, up to 255 characters
Never sensitive dataDo not use email addresses or personal identifiers as keys
Store the key before the first attemptSo it survives a crash and the retry reuses it
Keep it at least as long as the retry windowStripe prunes keys after about 24 hours; a one-day store against a three-day retry window will reprocess a stale retry as brand new

If the workflow itself is new to you, start with what is an AI workflow.

When the tool has no idempotency key

Then build the check yourself, on your side, before the call. Compute a deterministic identifier for the thing you are about to create — a form submission ID, a webhook event ID, an enquiry ID — look it up first, and create only if it is absent. The identifier must come from the input, not from the moment: the current time, a random number or the execution ID changes between runs, so every run looks new. Prefer upsert over append: update the matching row if it exists, create it only if it does not. And keep a ‘done’ log for steps you cannot undo: check it before any send, charge or create, and log after the send succeeds, not before — logging first turns a crash into a step that never happens. With a done log in place, retries become safe, because a first attempt that actually went through stops the second one. If the trigger is a webhook, the background you need is in webhook workflow basics.

Stop two runs processing the same job

So far the second run arrives after the first finishes. Worse is when two executions process the same job at the same time — two webhook deliveries, two scheduled runs overlapping. The fix is to make claiming a job a single atomic database operation rather than a separate read followed by a write: whoever claims it first owns it, and the other run sees it as taken and stops. Combine the three safeguards and retries stop being dangerous: an idempotency key where the API supports one, a done log and check-before-create where it does not, and an atomic claim so two runs cannot process the same job. Never retry a send without one of these in place — without idempotency, a retry is a second delivery waiting to happen. For the retry side of the same problem, see safe workflow retries.

Frequently asked questions

Is a timestamp a good duplicate key?

Only if it is a stable source timestamp with suitable uniqueness. Generating a new timestamp for each retry defeats repeat detection.

Should duplicates always be deleted?

Not automatically. Inspect the records and their consequences, preserve useful history, and use the destination’s normal recovery process.

What is an idempotency key?

A unique label for one intended action — a UUID or random string sent with the request. If the same request is retried with the same key, the system returns the previous result instead of repeating the action, so a retry can never charge a customer twice or send an email twice.

What makes a good dedupe key?

A stable value from the source: a form submission ID, a webhook event ID, an enquiry ID. A bad key is anything that changes between runs — the current, a random number, the execution ID. If the key is different every run, every run looks new.

Do I need idempotency for reads?

No. Reads and deletes are idempotent by definition — repeating them changes nothing. Keys are only for POSTs, creates, sends and charges: the actions that should not happen twice.

How long should I keep dedupe keys?

At least as long as the retry window. Stripe retries webhooks up to 36 times over 72 hours and prunes idempotency keys after about 24 hours, so a one-day store against a three-day retry schedule will happily reprocess a stale retry as brand new.

Was this guide helpful?

Your selection stays on this page. To send feedback to the publication, use our contact form.

About this publication

From OptimaFlow AI

Practical guides to AI, automation, and better everyday workflows. We use illustrative examples and original diagrams, with AI-assisted writing and illustrations.

Read our editorial approach →About OptimaFlow AI
How to Prevent Duplicate Actions in an Automation Workflow