How we make sure a retry never creates a second invoice
October 9, 2026 · Updated November 9, 2026
Every integration that talks to another system over the internet will, sooner or later, have a call fail halfway. The network drops. The other side is briefly unavailable. A rate limit says "slow down". The only sensible response is to try again. The question is what "again" means.
For an accounting sync, the worst possible answer is "start the order from the beginning". If the first attempt created the invoice and then failed while recording the payment, starting over creates a second invoice. Now the customer appears to owe you twice, your sales are overstated, and someone has to find and void the duplicate by hand.
This post explains how LedgerStitch is designed to make retries safe. It is not available yet; this is how we are building it, and why.
The word for it: idempotent
An operation is idempotent if doing it twice has the same effect as doing it once. Pressing an elevator call button is idempotent; pressing it five times does not call five elevators. Creating an invoice is not idempotent by default; calling "create invoice" twice creates two.
The goal is to make the whole "post this order" job idempotent, even though the individual calls to Zoho Books are not.
Step 1: break each order into fixed steps
Posting an order to Zoho Books is several separate calls. LedgerStitch will treat each order as a small state machine that moves through fixed steps:
RECEIVED → CUSTOMER_OK → ITEMS_OK → DOCUMENT_OK → PAYMENT_OK → DONE
↘ NEEDS_REVIEW- Received: the order has arrived from the store.
- Customer OK: a Zoho Books customer has been found or created.
- Items OK: every line has a Zoho Books item.
- Document OK: the invoice or sales receipt exists.
- Payment OK: the payment is recorded (for invoices).
- Done, or Needs review if something needs a person, such as a tax rate nobody has mapped.
Step 2: save each step before starting the next
After each step succeeds, LedgerStitch will save two things before doing anything else: that the step is done, and the ID of what Zoho Books created. For example, "order 1042, document step done, Zoho Books invoice ID 98765".
That record is keyed by your organization, the store, the order and the step. It can only be written once. A second attempt to record the same step for the same order is rejected.
So when a retry comes, it does not start from the top. It reads the record, sees that the customer and the document are done, and resumes at the payment. The invoice is never created twice, because the step that creates it has already been recorded as done, with its ID.
Step 3: what if the failure happens in the gap?
There is one awkward moment: Zoho Books has created the invoice, but the response never arrived, so LedgerStitch did not get to record it. On retry, the record says "document not done", but the invoice exists.
The design handles this with a second check. LedgerStitch will write the store's order number onto each Zoho Books document as a reference. Before creating a document, it will look for an existing document with that reference. If it finds one, it records that ID and moves on instead of creating another. We are confirming exactly which Zoho Books field supports this kind of search against Zoho's API documentation before we build it.
Step 4: one order at a time per organization
Retries are not the only source of duplicates. Two orders for the same new customer arriving at once can create two customers (we wrote about that race separately). LedgerStitch will process the orders for one Zoho Books organization one at a time, in order, which removes that race and keeps the load on your organization's API allowance gentle.
Step 5: back off politely
Zoho Books limits how many API calls an organization can make: 100 a minute, and a daily total that depends on your Zoho Books plan (Zoho Books API documentation, checked October 6, 2026). Those limits are shared with every other integration you run. When Zoho Books says "too many requests", LedgerStitch will wait, a little longer each time and with some randomness, and then retry from the saved step. It will also, by default, use at most half your daily allowance, so your other tools keep working.
Why not just "check for duplicates afterwards"?
Some tools post first and look for duplicates later. That is better than nothing, but it means duplicates exist for a while, perhaps across a month end, and someone has to decide which copy to void. In accounting, a document that was issued and then voided still leaves a trail. Preventing the duplicate is far cleaner than repairing it.
Why no AI here
We get asked whether AI could make a sync "smarter". For posting accounting records, we think the answer is no. The job is to do the same thing the same way every time, and to stop and ask when something is unclear. Rules do that. A model that is right most of the time is the wrong tool for a ledger. If we use AI anywhere, it will be for things like explaining an error message in plain language, never for deciding an entry.
What you will see
From the outside, all of this should be invisible. In the sync log you will see one row per order with its status and a link to the Zoho Books document. If an order failed and was retried, you will see that it was retried, and still only one document. If an order is waiting for you, it will say why.
Questions to ask any sync tool
- If a step fails after Zoho Books created something, what does the retry do?
- Do you store the Zoho Books document ID for each order?
- Do you check for an existing document before creating one?
- What happens when Zoho Books rate-limits you?
If the answers are vague, test it yourself: post an order, interrupt the sync halfway, and see what happens on retry.
LedgerStitch is in development for Zoho Books editions outside the US. See how it works, or join early access.