Prevent Duplicate Webhooks with Postgres in n8n Automation
Prevent Duplicate Webhooks with Postgres in n8n Automation
Couldn't load pickup availability
Prevent Duplicate Webhooks with Postgres in n8n Automation
Eliminate duplicate webhook processing headaches with this robust n8n automation that uses PostgreSQL to intelligently detect and prevent duplicate POST requests from overwhelming your business logic.
What this workflow does
This powerful deduplication workflow acts as a smart gateway for your webhook endpoints. When a POST webhook arrives at your configured endpoint, the workflow generates a SHA-256 hash of the complete JSON payload and cross-references it against a PostgreSQL deduplication table. Only unique requests within the last 24 hours trigger your business logic, while duplicates are gracefully skipped with clear status responses.
The workflow adds correlation IDs and timestamps to track each request, then queries your Postgres webhook_dedup table to identify previously processed payloads. New webhooks receive a "processed" status with correlation ID, while duplicates return "duplicate_skipped" status with the dedup hash for complete transparency.
Use cases
- Payment processing: Prevent duplicate payment webhooks from Stripe, PayPal, or other payment providers from creating multiple charges
- Order management: Stop duplicate order notifications from e-commerce platforms from triggering multiple fulfillment processes
- API integrations: Protect your n8n workflows from unreliable third-party systems that might resend the same webhook multiple times
- Event-driven automation: Ensure CRM updates, inventory adjustments, or notification triggers only fire once per unique event
Technical details
This n8n automation workflow leverages four core node types:
- Webhook node: Receives POST requests at your custom endpoint
- Code node: Generates SHA-256 payload hashes and correlation IDs
- PostgreSQL nodes: Query and insert deduplication records with 24-hour lookups
- IF node: Routes workflow logic based on duplicate detection results
Setup requires a PostgreSQL database with a webhook_dedup table containing payload_hash, correlation_id, received_at, and created_at columns. Compatible with n8n version 1.0 and later.
