Build note · Reliability
Every webhook should be safe to run twice
Form tools, CRMs and payment providers retry. Here is how we make lead intake idempotent so a retry never creates a second lead or sends a second email.
Almost every service that sends webhooks retries when it does not get a fast, clean answer. That is good for reliability and bad for any workflow that assumes each event arrives once. The symptom is familiar: a lead shows up twice, or someone gets the same confirmation email two minutes apart.
The pattern we use
- Answer quickly. A slow response is the most common reason a sender retries.
- Give every event an idempotency key. Use the sender's own event ID when it has one; otherwise derive one from stable fields such as a normalized email, the form and the slot.
- Insert first, act second. Write the key to a table with a unique constraint before doing anything with side effects. If the insert hits the constraint, the event was already handled and the run stops.
- Put side effects last. The email, the alert and the CRM update all come after the key is safely recorded.
Insert-then-act matters more than it looks. Checking whether a key exists and then acting leaves a gap where two parallel runs both pass the check. A unique constraint closes that gap at the database, where it cannot be raced.
Details that bite
- Normalize before comparing. Trim and lowercase emails everywhere, or the same person becomes two leads.
- Check that the key format allows every character your keys can contain. Ours were built from the visitor's email, and the server rejected a plus sign, so plus-addressed visitors saw an error. The format now allows it.
- Answer a repeat with success. A retried request should get a success response, not an error, so the sender stops retrying.
Our website intake works this way: every request from our site's forms carries an idempotency key stored under a unique constraint, so a retried request is acknowledged without creating anything new. The contact form keeps the same key when you press Try Again, and meeting requests use a key built from the email, date and time, so asking twice for the same slot records it once. It is unglamorous work, and it is the difference between automation people trust and automation people double-check.
Work with us
Want this level of care on your own systems?
The free automation audit maps where leads and admin time leak, then gives you a fixed quote.
Book a free automation audit