Skip to main content
Journal

EngineeringPrimeCode WebWorks6 min readOct 19, 2026

Idempotency keys: one webhook, one side effect

Retries are normal. Store the key with the result and enforce it with a unique constraint so a second delivery cannot create a second row.

APIWebhooksLaravel
Person writing on a printed form

Providers retry. Queues retry. People double-click. If each delivery creates a row, one payment becomes two receipts, or one booking becomes two.

QR Ph payments and digital payments for online stores already say the order update should be webhook-driven, verified, and idempotent. They stop at the word. This is the mechanism. It is not a wallet setup guide.

Queues will run a job more than once. That is normal. The side effect still has to happen once.

The pattern

The caller sends a key for that operation. Stripe’s Idempotency-Key header is the well-known version: the same key returns the stored result instead of performing the operation again.

We store the key with the result. A unique constraint on the key is what makes the second delivery lose. Code that checks and then inserts, without the constraint, still races.

  1. Verify the caller. A signature check comes before any of this. Idempotency does not authenticate anyone.
  2. If the key already has a stored result, return it.
  3. Otherwise do the work in a transaction and store the key with that result.
  4. If the unique insert loses, read the winner’s result and return that.

The key is per operation, not per customer and not per day. Reusing one key for two different payments is a bug in the client.

What this is not

It is not a reason to add a service. A column and a unique index on the existing app is the usual fix. It does not replace the payment articles. Those still cover how GCash, Maya, and QR Ph should update an order. This covers why the second delivery must not create a second one.

Straight next step

If a retry has already created duplicate bookings, receipts, or stock movements, send one example pair. We will put the key on that operation before we talk about a new integration.

Related

More from the journal.

Start

Building something similar?

Tell us what you are planning — a founder or studio lead replies within one business day.