Idempotency best practices for integrations: retries without duplicates
By Maria Soria, Manager of Customer Success


An operation is idempotent when doing it twice has the same effect as doing it once: extra executions don't change the final state or cause side effects beyond the first successful run. Integrations need that property because every integration that creates something will be asked to create it again.
Webhooks, queues and retries deliver at least once, so a message can arrive more than once. The usual fix is the Idempotent Receiver pattern: the receiving side recognizes a repeat and applies it once. Exactly-once effects come from at-least-once delivery plus an idempotent receiver.
This guide is for the people who build and run integrations: ops and RevOps leads, technical founders and small IT teams. It covers where repeats come from, nine practices that keep each one to a single effect, and how to set each up in Neblex Integration Fabric. It ends with a worked example, a Stripe payment booked into an ERP, and a checklist to run before you raise a retry count.
Why does the same write arrive more than once?
Three different things can resend work, and each needs its own answer.
- A retry (same step, same run). A step times out after the destination has already taken the call, and Retry on failure sends it again.
- A replay (same run, later). Someone opens the failed run the next morning and presses Replay. The failed step runs again with the inputs it had the first time.
- A second delivery (a new run). Stripe keeps trying a webhook for up to three days in live mode, and its docs note an endpoint can receive the same event more than once. Each delivery starts a new run.
The answers line up with those three:
- Retry and replay: a header key that stays the same for the run and step, so the repeat sends the same key. For a bulk step, a chunk checkpoint also lets the repeat pick up at the first unfinished chunk.
- Second delivery: a business ID on the record, so the new run finds the payment the first run wrote.


1. Map each kind of repeat to its own control
No single setting covers every repeat. Decide which repeats your flow can see, then turn on the matching control. A flow that charges or books money needs the key and the business ID. A bulk load needs chunks as well.
| What happens again | What keeps the effect to one |
|---|---|
| A retry or resume of this step, in this run | Idempotency key on the connector or HTTP step. The key is stable for the run and the step, so the same header goes out again. |
| Replay, or an automatic re-run, from the step that failed | Completed steps keep their results. The failed step runs again, so it still needs the key or an upsert. |
| A bulk step that failed after some records landed | Process in chunks. Each finished chunk is recorded, and the next attempt continues from the first unfinished chunk. |
| The same read, called twice in one run | Remember results within this run, keyed by something like {{customer_id}}. |
| A second run for the same business event | The write matches on a business ID: a Stripe invoice ID, a NetSuite external ID, a Salesforce external-ID field. |
| A partner calling a Neblex API twice | The caller sends Idempotency-Key, and that request starts its run once. |
| A queue or stream handing over the same message twice | A stream trigger starts one run per message ID, offset or sequence number. |
| Two runs for the same customer overlapping | Runs at once, one at a time per key, for example {{customer_id}}. |
In Neblex, Idempotency key, Process in chunks and Remember results sit on the step, under Advanced settings. Runs at once is a flow limit. The step settings guide describes each one.
2. Send an idempotency key on every creating call
An idempotency key is a unique value sent with a request so the server can recognize a repeat and return the first result instead of applying the change again. Send one on every call that creates or changes something, and keep it the same across retries of that call.
In Neblex, turn on Idempotency key on the connector step or HTTP request and set the Key header. The default is Idempotency-Key, the header Stripe documents. If the API uses a different name, put that name in the Key header.
Neblex chooses the value. Each record gets its own key, and the key stays the same for that run and step, so a retry or a resume sends it again. On Stripe, a repeated key returns the original result.
Without a built-in key, teams build one by hand: map the run's execution ID into the header, add the item index so each record gets its own value, and remember that a manual rerun gets a new ID. Others put a lookup table or a queue in front of every write. Both work, but they are extra steps to build and keep correct on every write.
A few limits are worth knowing while you set the step up:
- The setting is on connector steps and HTTP requests. Remember results and Retry on failure also cover Run another flow, but the header key does not.
- Stripe saves an API v1 result only after the endpoint starts executing, and it rejects a retry whose parameters differ from the original. Keep the retried body the same. Replay continues from the inputs recorded on the run.
- In Stripe API v1,
GETandDELETErequests are idempotent by definition, so a key has no effect. Put the key on the calls that create or change something.
3. Carry a business ID the destination can upsert on
The step key belongs to one run. A redelivered event starts a new run with a new key, so the write itself has to recognize the record. Match every creating write on a stable ID from the source system.
Key windows are also shorter than a long outage. On Stripe API v1, Stripe can remove a key once it is at least 24 hours old, and a reused key then starts a new request. On API v2, a matching key is a replay for 30 days when it hits the same API in the same account. A payment upserted on the invoice ID still matches after either window.
Some systems never honor Idempotency-Key. For those, the ID on the write is the only protection against a second run:
- NetSuite: an upsert by external ID, including a batch upsert of up to 100 records of one type. The NetSuite connector creates the row or updates the one that already has that external ID.
- Salesforce: Upsert by external ID on the object, matched on an external-ID field. The Salesforce connector lists it next to create and update.
- An ERP payment booked from Stripe: key the payment on the Stripe invoice ID. Stripe notes that the same change can arrive as two separate events with different event IDs, so the object ID is the safer match.
When an API offers neither an upsert nor a field it keeps unique, a lookup before the write is the last resort. Search on the business ID, create only when nothing matches, and update when something does. Look up by an exact ID stored on the record, not by name or email, and let one run at a time handle that ID (practice 6) so two runs can't both find nothing.
Search can lag behind writes: HubSpot notes that new or updated records may take a few moments to appear in search results, so a redelivery seconds later can miss the first record. To close that gap, write the new record's ID back as soon as it is created, to the source record or a cross-reference table you control, and check there before you search the destination.
Use an ID the source system already has. The invoice ID, order number, and payout ID are still there when a new run starts tomorrow. Pick the ID of the record being written: a payment for an invoice keys on the invoice ID, while a refund or dispute on that invoice is a different record with its own ID, so it isn't mistaken for a duplicate.
An upsert is only as safe as the uniqueness rule behind it. Make sure the destination enforces the ID as unique: a unique constraint in a database, or an external-ID field marked unique. Then two writes arriving at the same moment still can't create two records.
The header makes the automatic retry safe. The business ID makes tomorrow's new run safe.
4. Retry only the failures that are safe to repeat
A timeout or a rate limit is worth another attempt. A conflict or validation error means the destination has given its final answer, and repeating it only adds noise or risk.
In Neblex, Retry on failure is available on connector steps, HTTP request and Run another flow. Max attempts defaults to 3, counting the first try, and can go up to 100. Backoff defaults to 1,000 ms, the multiplier to 2 and the cap to 30,000 ms.
Narrow it further with Retry only some failures, a condition on the error such as error.retryable equals true or error.kind equals timeout. Anything else fails the step at once. The error kinds are connectivity, timeout, auth, permission, policy, rate_limited, invalid, not_found, conflict, unavailable, crypto, entitlement, internal and unknown.
The platform adds guards of its own on every step:
- Retries stop immediately when the system may have already applied a change that isn't safe to repeat.
- A failure with an uncertain outcome stops the run.
- When a destination refuses before anything was delivered (the connection is refused, the service is unavailable or busy, or it asks the caller to slow down), the step waits and tries again. The first pause is 5 seconds, and each pause doubles up to 5 minutes. The run shows as Waiting and holds nothing. A call that may have already landed is never retried this way.
Those guards don't cover a timeout after the destination has accepted the write. That case still needs the key.
5. Resume from the failed step, not from the start
Starting a failed run over re-sends every write that already succeeded. Resuming from the failure re-sends only the step that broke.
In Neblex, Replay on Runs (or Retry on the failure banner) continues the same run from the failed step with the current saved flow. Earlier steps keep their results. The failed step really runs again, which is why the key and the upsert have to be in place before you raise Max attempts. The runs guide is the operator view of that button.
For bulk loads, set Process in chunks of to 0 for automatic, or a size from 10 to 100,000. Automatic uses the largest chunk the connector can commit safely, and a database takes 1,000 records per transaction. Each finished chunk is recorded as it lands, so a retry or failure in the middle continues from the first unfinished chunk.
For a migration or nightly sync, 500 to 5,000 is a sound starting size; our on-prem to cloud warehouse load measured batch sizes on a million rows. Replay from the failed step, not from record one explains why the checkpoint exists.
Re-runs are the same continuation on a timer. With three re-runs, a first wait of 300 seconds and a factor of 2, the waits are 5 minutes, then 10, then 20. Only retryable failures qualify, and completed steps are not repeated.
6. Let one run at a time touch the same record
Two runs for the same customer can both read "no payment yet," and both write one. A per-key concurrency limit prevents that race.
In Neblex, Runs at once sets a cap for the whole flow, or a cap per key from the trigger record, such as one run at a time per {{customer_id}}. A run past the cap waits, shown as Waiting, and runs start in the order they were started. None are dropped.
Pair it with the header key: the cap stops the race, and the key stops a retry inside the run that won it.
7. Cache reads within a run, and never cache writes
Calling the same lookup twice in one run wastes API quota and can return two different answers. Cache reads for the life of the run; protect writes with keys and upserts instead.
In Neblex, Remember results within this run works on connector steps, HTTP requests, and Run another flow when the step waits for it. Set Remember by to a mapping such as {{customer_id}}, and records that share the key make one call and share the result.
Only reading calls qualify: a GET, a SELECT or a flow the step waits for. Nothing is kept after the run or shared with another run.
8. Decide between undo and replay before something fails
Compensation and replay answer different questions. Compensation undoes earlier writes because a later step failed. Replay keeps them and finishes the run.
In Neblex, set an Undo operation on a connector step and, when you need it, an Undo input built from that step's output, such as the ID it just created. If a later step fails the run, the undo operations of completed steps run in reverse, like a saga. A closed-won deal that created the ERP customer and then fails at provisioning is the pattern our workflows page describes: cancel the order, deactivate the customer and record the cause.
After compensation, start a fresh run once you fix the cause. Write each undo so a second call is harmless: cancel by the ID the step created, or delete in a way that accepts an already-removed record.
9. Ask the systems calling you to send keys too
Idempotency runs in both directions. Inbound calls and messages need their own keys.
- A flow published as an API starts once for a given
Idempotency-Keyon the request. Callers that might time out and send the POST again should send that header. The API guide is the contract. - A result callback carries
X-Neblex-Delivery, and the value is the same on every attempt so that the receiver can take each callback once. If a callback isn't answered with success, it's sent again later. - A stream trigger identifies each message by its ID, offset or sequence number, and a message delivered twice starts one run. Offset-based sources such as Kafka resume from the stored position.
- A Webhook trigger takes a repeated delivery once: an unsigned request that repeats a delivery header such as
Idempotency-KeyorX-Request-Id, or a signed request sent again exactly as before. The repeat gets HTTP 200 with aduplicatestatus and starts no run.
Without one of those, a Webhook trigger can't tell a redelivery from a new event. The same body sent twice without a delivery header will start two runs, and so will a Stripe redelivery, which repeats the event in the body with a new signature. For those senders, the flow must be safe to run twice on the same event.
Worked example: a Stripe invoice booked once in the ERP
This is the flow finance teams usually turn on first, with the idempotency settings written in. The business steps match the Stripe worked example: invoice.paid becomes one customer payment in the ERP, fees are split out, and anything unmatched goes to a person.
- Trigger. A Webhook trigger with Auto Register With Stripe for
invoice.paid. The run starts with the invoice, its customer andamount_paid. The rest of the flow treats a second delivery as the same payment. - One at a time per customer. Set Runs at once to one run per Stripe customer ID. A burst of invoices for the same customer waits, in order.
- Identify. Read
customer.metadata.erp_customer_idandinvoice.metadata.erp_invoice_id, written there by the billing flow. If either is missing, a Wait for form step sends the invoice to the billing team with the Stripe link, and nothing is written. - Fees. Get the balance transaction for the invoice's charge and read
feeandnet. If a later branch could ask for the same charge twice, turn on Remember results for that read, remembered by the charge ID. - Write. Upsert the customer payment in the ERP, keyed on the Stripe invoice ID, with the net amount on the payment and the fee on the bank-fee line. Turn on Idempotency key on that step. The upsert joins a second run to the first payment. The header joins a retry to the first call.
- Retry what is still safe. On the write, keep Retry on failure at the defaults and limit retries to
error.retryableequalstrue. A timeout or rate limit retries with the same key. A conflict or a rejected body fails the step, and the run shows the cause. - Replay from the failed step. If the ERP was down, the run stops on that write. Fix the cause and press Replay. For a payout file, turn on Process in chunks.
What a failure looks like
At 2 a.m. the ERP is slow during maintenance. Stripe delivers invoice.paid, the run reads the customer and the balance transaction, and the upsert times out.
Retry on failure spends its three attempts within a few seconds, each with the same Idempotency-Key, so if the first call had landed before the connection dropped, a retry would have returned the original result. The run stops on the write with the cause: timeout.
In the morning you check the ERP and press Replay. The read steps keep their results, and the upsert runs again with the inputs recorded on the run.
That afternoon Stripe delivers the same change again. The delivery starts a new run with its own step key, so the header can't help. The upsert can: it matches on the invoice ID and updates the payment the replay created.
If your ERP ignores the header, the upsert on the invoice ID is the only thing between that afternoon run and a duplicate payment. That is why the example uses both.
Had the run failed in the middle of a payout file instead, Process in chunks would have done the work: a run that stopped at chunk 96 resumes at chunk 96, and chunks 1 through 95 are never posted again. Had the ERP refused the connection outright, the step would have waited and tried again on its own, with the run shown as Waiting. Either way, the billing team sees one payment and one payout.
What can go wrong
- The key is per run. A redelivered webhook or a manually restarted flow sends a new key, so a flow with only the header key still double-writes on a second run.
- The sender has no delivery key. A Webhook trigger skips a repeat only when the request repeats a delivery header or is the exact same signed request. Senders that put the event ID in the body, as Stripe does, start a new run per delivery.
- The retried body changes. Stripe rejects a repeated key with different parameters. Map amounts and IDs from the trigger, not from values that change between attempts, such as the current time.
- A lookup misses a record that isn't indexed yet. Lookup before create can miss a record created seconds earlier, because search lags behind writes. Where there is no upsert, run one run at a time per ID and check the IDs you have already written back before you search.
- The business ID isn't unique. An upsert on an email address or a name merges records that should stay apart. Use an ID the source system issues.
- Compensation and Replay both run. Undoing the earlier writes and then replaying the run leaves the later steps without the records they expect. After compensation, start a fresh run.
- Retries are raised before the write is safe. More attempts on a call with no key and no upsert mean more chances to write twice.
Idempotency best practices checklist: before you raise the retry count
Walk the creating steps once, in this order.
- Name the business ID: invoice ID, order ID, payout ID or external ID. Every creating write uses it, through an upsert or an external-ID field.
- Turn on Idempotency key on each connector or HTTP step that creates or changes something, and set the Key header to the name that API documents.
- Limit retries to
error.retryableequalstrueon those writes. Leave Max attempts at 3 until you have watched a real failure. - For a bulk load, set Process in chunks: 500 to 5,000, or 0 for the connector's safe size.
- If two runs for the same customer could race, set Runs at once to one per that ID.
- If a later failure should undo earlier writes, set Undo on those steps and plan a fresh run afterward. If the earlier writes should stay, leave compensation off and use Replay.
- For a flow you publish as an API or a webhook, tell callers to send
Idempotency-Keyon any POST they might retry. - Test it twice: replay a failed run, and deliver the same test event again. You should see one charge, one payment and one order.
The takeaway
Following idempotency best practices for integrations means layering controls, because no single one covers every repeat. The key makes a retry safe, the business ID makes a new run safe, chunks make a bulk resume safe, and Runs at once stops two runs from racing. Turn them on before you raise the retry count, then prove it by sending the same event twice.
Sources
- Idempotent requests, Stripe API reference
- Low-level error handling: idempotency, Stripe Docs
- API v2 overview, Stripe Docs
- Receive Stripe events in your webhook endpoint, Stripe Docs (retries, duplicate events)
- Search the CRM, HubSpot Developers
- Idempotent Receiver, Gregor Hohpe and Bobby Woolf, Enterprise Integration Patterns
Last checked: December 3, 2026.
Frequently asked questions
Does an idempotency key stop a second webhook from creating a second charge?
Not on its own. In Neblex, the step key covers retries of a single step within one run. A redelivered Stripe event starts a new run, which sends its own key. Upsert the ERP payment or the order on a business ID, such as the Stripe invoice ID, so the second run finds the first result. Keep the step key on as well, so a timeout inside either run returns the original result.
What if the destination API ignores the Idempotency-Key header?
The step still sends it, but the destination applies the change each time the call arrives. Use an upsert on a unique field instead, such as a NetSuite external ID or a Salesforce external-ID field, and turn on Process in chunks for bulk loads so finished chunks are not posted again.
Will Replay send completed writes again?
No. Completed steps keep their results, and only the failed step runs again, with the inputs recorded on the run. To process fresh source data, start a new run and let the business ID make it safe.
Can an integration platform guarantee exactly-once delivery?
Not on its own. Webhooks, queues and retries deliver at least once, so the same message can arrive twice. Exactly-once effects come from at-least-once delivery plus an idempotent receiver: an idempotency key the destination honors, an upsert on a business ID, or both. A platform can resume from the failed step and keep the same key on retries, but the write still has to recognize a repeat.
Which idempotency header name should we send?
The one the destination documents. Idempotency-Key is the Neblex step default and the Stripe header. Callers of an API you publish from Neblex, or of a Webhook trigger, send Idempotency-Key, and that request starts its run once. Callbacks Neblex sends to you carry X-Neblex-Delivery, which stays the same across attempts.
Bring us the product or the integration that hurts most
We will build it with you, on your data, with the run log open.