{"product_id":"idempotent-lead-webhook-workflow-w-postgres-http-apis","title":"Idempotent Lead Webhook Workflow w\/ Postgres \u0026 HTTP APIs","description":"\u003ch3\u003ePrevent duplicate lead processing with an Idempotent Webhook + PostgreSQL\u003c\/h3\u003e\n\u003cp\u003eThis n8n automation receives lead submissions via a webhook and guarantees that the same \u003cstrong\u003eIdempotency-Key\u003c\/strong\u003e is processed \u003cem\u003eat most once\u003c\/em\u003e. If a request is retried, it automatically \u003cstrong\u003ereplays the stored response\u003c\/strong\u003e—so your enrichment, CRM updates, and notifications never run twice for the same lead attempt.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eReceives a POST webhook\u003c\/strong\u003e containing an \u003cstrong\u003eIdempotency-Key\u003c\/strong\u003e (and optional \u003cstrong\u003eX-Client-Id\u003c\/strong\u003e) plus a JSON lead payload.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eEnsures PostgreSQL idempotency support\u003c\/strong\u003e by creating the \u003ccode\u003eidempotency_keys\u003c\/code\u003e table and required indexes (if needed), then validates the request.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eBuilds a canonical payload fingerprint\u003c\/strong\u003e to detect mismatched retries.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAtomically claims or replays\u003c\/strong\u003e:\n    \u003cul\u003e\n      \u003cli\u003eIf the Idempotency-Key is new, it claims it with a lease.\u003c\/li\u003e\n      \u003cli\u003eIf the key already exists, it either replays the stored completed response or returns an error for in-progress\/mismatched payload\/store-unavailable scenarios.\u003c\/li\u003e\n    \u003c\/ul\u003e\n  \u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eOn first-time processing\u003c\/strong\u003e:\n    \u003cul\u003e\n      \u003cli\u003eCalls an external \u003cstrong\u003eenrichment API\u003c\/strong\u003e.\u003c\/li\u003e\n      \u003cli\u003eComputes a deterministic \u003cstrong\u003elead score\u003c\/strong\u003e and \u003cstrong\u003etier\u003c\/strong\u003e.\u003c\/li\u003e\n      \u003cli\u003eCreates\/updates the lead in a \u003cstrong\u003eCRM API\u003c\/strong\u003e.\u003c\/li\u003e\n      \u003cli\u003eSends a \u003cstrong\u003enotification\u003c\/strong\u003e via a third \u003cstrong\u003eHTTP endpoint\u003c\/strong\u003e.\u003c\/li\u003e\n    \u003c\/ul\u003e\n  \u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eStores the final outcome\u003c\/strong\u003e (HTTP status + response body) in PostgreSQL and replies to the webhook with \u003cstrong\u003eIdempotency-Key\u003c\/strong\u003e and an \u003cstrong\u003eIdempotent-Replayed\u003c\/strong\u003e flag.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eRetry-safe lead intake for SaaS forms, ensuring duplicate webhooks don’t double-enrich or overwrite CRM data.\u003c\/li\u003e\n  \u003cli\u003eIdempotent inbound processing for partner integrations where clients may resend payloads on timeouts.\u003c\/li\u003e\n  \u003cli\u003eReliable lead routing when enrichment\/CRM calls are occasionally slow or transiently unavailable.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003ePostgreSQL\u003c\/strong\u003e idempotency using \u003ccode\u003eidempotency_keys\u003c\/code\u003e with a lease and stored response replay.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eHTTP APIs\u003c\/strong\u003e for enrichment, CRM updates, and notifications.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8n nodes\u003c\/strong\u003e: if, code, wait, webhook, postgres, sticky note.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003cp\u003e\u003cstrong\u003eSetup note:\u003c\/strong\u003e Configure PostgreSQL credentials so the database user can create tables\/indexes and read\/write the \u003ccode\u003eidempotency_keys\u003c\/code\u003e table.\u003c\/p\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46190249476275,"sku":"N8N-20541","price":71.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/HjXcd81eecCDja0OPtDIb_sRyFjgnJ.png?v=1791451352","url":"https:\/\/buyflowscripts.com\/products\/idempotent-lead-webhook-workflow-w-postgres-http-apis","provider":"N8N Commerce","version":"1.0","type":"link"}