This template is for anyone running n8n workflows that receive webhooks and perform side effects such as payments, emails, database inserts, or API calls.
Webhook providers commonly use at-least-once delivery. If a webhook request times out or fails, the provider retries the same event. From n8n’s perspective this appears as a new trigger, which can cause the workflow to execute twice.
This workflow adds an idempotency check before any side effect runs.
When the first event arrives, the workflow records its idempotency key and proceeds normally. If the same event arrives again within 24 hours, the gate returns a BLOCK decision and the workflow stops before any side effects execute.
The webhook responds immediately with a 200 OK response., so providers do not retry due to workflow execution time. The idempotency gate then decides whether the workflow should proceed or stop.
This prevents duplicate executions such as:
Setup usually takes about 2 minutes.
X-API-KeyDetailed instructions are included in the sticky notes inside the workflow.
You may need to adjust the idempotency_key depending on your webhook payload.
Examples:
The key should uniquely identify the event so duplicates can be detected reliably.