Most teams find this problem the hard way. A customer gets two welcome emails. A payment gets written twice. A Slack alert fires three times. A CRM contact splits into two records with slightly different timestamps. The automation worked, but it worked too many times. This is not a bug in your webhook provider. It is a built-in part of distributed systems, and every webhook automation needs to handle it on purpose.
This guide explains why duplicate webhook events happen, the pattern that prevents them, how to use it in code or no-code tools, and how to watch it once it is live.
Why webhooks are duplicated by design
Webhook providers such as Stripe, HubSpot, Shopify, GitHub, and most CRMs use at-least-once delivery, not exactly-once delivery. That is deliberate. If a provider is not sure you got an event, it is safer to send it again than to drop it. Missing a payment event is worse than sending it twice.
If your system does not return a fast, clear success response, usually an HTTP 2xx within a few seconds, the provider assumes delivery failed and retries. That means every webhook can arrive more than once. It can also arrive out of order. It can also arrive late enough that a duplicate looks like a new event.
If you ignore that rule, duplicates do not go away. They just show up at random, usually under load, usually at the worst time, and usually in a way that is hard to repeat while debugging.
The four common sources of duplicates
Provider retries
A slow database write, a brief network blip, a cold start, or a platform timeout can make the provider resend the same payload. That can happen seconds later or hours later, depending on its retry schedule. This is the most common source, but it is rarely the only one.
Two systems reacting to the same event
A CRM update may trigger your webhook automation and also trigger a separate internal workflow, such as a native CRM rule, a Zapier zap, or a database trigger. Both paths can write the same record. Each path may be correct on its own, but together they create duplicate database records.
Race conditions in webhooks
If two related deliveries arrive within milliseconds, and your workflow checks then writes without locking, both runs can pass the same existence check before either one writes anything. Both see no record. Both insert. You get two rows for one real event. Testing often misses this, because test traffic is usually too slow to trigger it. Production traffic is not.
Manual replays
Most webhook dashboards have a resend button. Teams use it all the time during debugging. If deduplication is off in staging or another non-prod environment, replayed events can create fake data bugs that waste hours later.
Idempotency keys: the real fix
An idempotency key is a unique ID for the event itself, not for the HTTP request. Two delivery attempts of the same event should use the same key. That is what makes event deduplication work.
Most reliable providers already give you one. Stripe gives you an event ID. HubSpot combines a subscription ID, an object ID, and a time value. GitHub gives you a delivery ID. Your job is to use it every time the webhook is processed.
The same idea shows up in an idempotent API: the second try should not change the result.
The pattern, step by step
Extract the provider event ID from the payload or header.
Before any business logic, check a dedicated event log table for that ID.
If the ID already exists, stop at once and return a success response. Do not run the side effect again.
If the ID does not exist, run the business logic and store the event ID in the same database transaction.
That last step is the one many teams miss. If you check first, do the work second, and write the ID last, you still have a race window. Two near-simultaneous events can both pass the check before either one writes the row.
The safe fix is to let the database enforce the rule.
CREATE TABLE processed_events (
event_id TEXT PRIMARY KEY,
processed_at TIMESTAMPTZ DEFAULT now()
);
Then, inside one transaction:
BEGIN;
INSERT INTO processed_events (event_id) VALUES ($1);
-- If this insert fails with a unique violation,
-- stop, roll back, and return success.
-- If it succeeds, run the rest of the work here.
COMMIT;
Because the unique rule lives in the database, two inserts for the same event ID cannot both win. One succeeds. One fails. That is always true, even when the requests arrive at the same time.
Deduplication windows for systems without event IDs
Some older tools and internal systems do not provide a stable event ID. In that case, use a fallback key built from stable payload fields. A common choice is contact_email + event_type + rounded time.
Store that key with a TTL, often 24 to 72 hours, based on the provider's retry window. Check the provider docs, because retry windows vary a lot.
This is a fallback, not the first choice. A composite key can create false matches. A person may submit the same form twice on purpose, and your webhook deduplication may treat the second action as a duplicate. If a true event ID exists, use it.
Webhook deduplication in no-code and low-code tools
If you build in Make.com, n8n, or Zapier, you do not get real database transactions. So the single-step check-and-write pattern has to be copied as closely as the tool allows.
A practical setup:
Use the platform data store, or an external store like Redis or Postgres, as your event log table.
Add a filter or router step right after the trigger, before any CRM update, email send, or other side effect.
If the platform offers an
ignore duplicate executionsordeduplicatesetting, turn it on. Treat it as a first layer, not the only layer.Remember that many built-in settings compare request hashes, not business event IDs. They can miss two different requests that still point to the same real event.
Be aware that most no-code platforms do not give you true single-step safety here. Under high load, there is still a small race window.
For low-risk work, like form submits or light CRM updates, that may be good enough. For payments or high-frequency events, custom code with real database transactions is safer.
Test your webhook processing before it matters
Webhook bugs are often intermittent. One test event proves very little. Before you call the system ready:
Replay the same event two or three times in a row and confirm that only one record is created.
Send two requests with the same event ID within milliseconds of each other to test race conditions in webhooks.
Make sure a duplicate still returns a success response. If you skip the work but return an error, the provider may keep retrying forever.
What to monitor after launch
A deduplication system that fails quietly is worse than no dedup system at all. It gives false confidence. Track these signals in production:
Duplicate-event rejections per day. A spike often means the provider is retrying more than usual.
The time gap between repeated deliveries of the same event ID. This helps you size the deduplication window.
Events that arrive after the TTL has expired but are still real duplicates. That is a sign the window is too short.
Unique constraint violations in the database. These should be handled in code, but they are useful ops context and a sign of upstream retry pressure.
The broader rule
This is one case of a bigger rule for distributed systems idempotency: any system that receives events from outside should assume delivery is flaky by default. Design for repeats, gaps, and out-of-order arrival from day one. Do not patch them in later.
The cost of building this early is small. It may be a table, a unique rule, and one extra workflow step. The cost of skipping it shows up later as duplicate database records and data quality problems that are hard to trace back to the source.
Need help building or fixing a reliable webhook automation? Saesoft can help you design webhook idempotency flows, add duplicate detection, and connect your systems safely.
FAQ
Question: Why should a duplicate webhook still return a success response?
Short answer: Because webhook providers retry when they think delivery failed. If your system sees a duplicate but returns an error, timeout, or unexpected status, the provider may send the same event again. The right move is to skip all side effects and still return a fast HTTP 2xx response.
Question: Is checking whether a record already exists enough to prevent duplicates?
Short answer: No. A simple read-then-write check can still fail under concurrency. Two runs can both check, both see nothing, and both insert a duplicate. A database-level unique rule plus one transaction is safer because the database enforces the rule at once.
Question: When should a composite deduplication key be used instead of a provider event ID?
Short answer: Use it only when the provider does not give you a stable event ID. Build the key from stable fields such as contact_email, event_type, and a rounded time. Keep the TTL short enough to limit false matches, since this method can by mistake treat a real repeat as a duplicate.
Question: Are no-code deduplication settings enough on their own?
Short answer: Usually not. Built-in dedup settings can help, but they often compare raw request signatures or payload hashes, not the real business event. They can miss cases where two different systems send slightly different requests for the same event. For higher-risk flows, a backend with real transactions is safer.
Question: What should teams monitor after adding deduplication?
Short answer: Monitor duplicate-event rejection counts, the time gap between repeated deliveries, TTL misses, and handled unique-constraint violations. These numbers show whether webhook retries are rising, whether the deduplication window is sized well, and whether duplicates are slipping through.
