Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

The Webhook Arrived Twice: Deduplicating Webhook Deliveries in n8n

Description and use

Webhook providers may deliver the same event multiple times, causing duplicate downstream actions. Fast acknowledgment, atomic insert with a unique event key, signature verification, and idempotent downstream processing prevent duplication.

Problem

Webhook providers may deliver the same event multiple times, causing duplicate downstream actions such as duplicate emails or records.

Outcome

Implementing fast acknowledgment, atomic deduplication on provider event ID, signature verification, and downstream idempotency prevents duplicate processing and ensures reliable webhook handling.

Workflow

  • 1. Receive webhook request in n8n.
  • 2. Verify provider signature on raw body; if invalid, log and return 200.
  • 3. Extract provider event ID (or build natural key).
  • 4. Attempt atomic insert into deduplication table with unique constraint; if insert fails, return 200 and exit.
  • 5. Record event metadata and return 200 to acknowledge receipt.
  • 6. Trigger a second workflow or later stage to perform heavy processing (LLM calls, writes, email).
  • 7. Ensure downstream actions are idempotent (upserts, deterministic message IDs).

Evidence

A workflow I ran for months listened for a provider webhook: a payment event, a form submission, a status change. One day a customer got two confirmation emails, and a downstream record was created twice.

Source

The first mistake is doing slow work inside the webhook handler. The provider waits for your response; if your workflow takes thirty seconds to call an LLM, write to three systems, and send an email, the provider's timeout fires first and it redelivers — creating the very duplicate you were trying to avoid.

Source

Rule 2: dedup on the provider's event id, never on arrival time

Source

Rule 3: verify the signature before you trust the payload

Source

Rule 4: make the downstream work safe to run twice anyway

Source

The checklist I actually use ... Webhook handler validates, records, and returns 200 fast; slow work runs in a second stage.

Source

  • Record date: 2026-11-01T03:43:50.772Z