Workflow automation · 4 min read

How to keep a retried form submission from creating two rows in n8n

Use a stable submission ID and a parameterized insert to keep webhook retries from creating duplicate records.

Illustration of routing a new record and a repeated submission by submission ID.

Have the form provider reuse the original submission ID on retries and make it a unique key in PostgreSQL. A webhook can arrive twice when the sender times out, even if the first write succeeded. Use n8n's Postgres node to run a parameterized insert so both deliveries follow the same database rule.

n8n · View product details

Let the insert decide whether the record is new

In a test table, use a text primary key called submission_id. Pass the ID and name as Query Parameters in the order used by $1 and $2. If multiple form providers can issue the same ID, key the row on the source and ID together. An email address can belong to two valid submissions. Route missing IDs to a rejection branch before attempting the write.

WITH inserted AS (
  INSERT INTO form_entries (submission_id, submission_name)
  VALUES ($1, $2)
  ON CONFLICT (submission_id) DO NOTHING
  RETURNING submission_id
)
SELECT EXISTS (SELECT 1 FROM inserted) AS created;

A new row returns created = true. A replay returns false. A separate read before the insert can miss a row another execution is about to write. The unique key resolves that race at insertion time.

Illustration of routing a new record and a repeated submission by submission ID.
Illustration of routing a new record and a repeated submission by submission ID.

Verify the row and the confirmation separately

Submit demo-42 twice and a fresh demo-43 once. Repeat the duplicate case with overlapping requests. Expect two rows, with demo-42 appearing once. Also try a missing ID and reuse one ID across two sources if you accept multiple providers.

Send a confirmation only for a newly created row. The workflow can still fail between committing that row and sending the email. If missing a confirmation is unacceptable, record a pending send in the same transaction and process it separately with retries. Verify delivery independently of row deduplication.

Visit official website

View product details

Official references