Prompt
Why do accounting API retries create duplicate transactions?
Latest observation
Accounting API retries can create duplicate transactions when the API is not fully idempotent and the client repeats a request after a timeout or network failure.
Common reasons:
-
Unclear request outcome:
The client doesn’t know whether the server received and processed the first request, so it sends it again. -
Server processed the first request but response was lost:
The transaction was created successfully, but the client retried because it never got the success response. -
No idempotency key / deduplication token:
If the API doesn’t use a unique request ID to recognize “same request, already handled,” each retry looks like a new transaction. -
Retry happens at the wrong layer:
Middleware, SDKs, or load balancers may automatically retry POST/CREATE calls that should not be blindly retried. -
Partial failures and eventual consistency:
In distributed systems, one service may have committed the transaction while another step failed, making the retry create another record.
Example
- Client sends “create invoice payment”
- Server creates it
- Network drops before the client gets the response
- Client retries
- Server creates a second payment because it can’t tell it’s the same request
How to prevent it
- Use an idempotency key for create/payment requests
- Design APIs so repeated requests return the same result
- Only retry safe, idempotent operations unless deduplication is supported
- Record and check external transaction IDs
- Make retry logic aware of timeout vs. definitive failure
If you want, I can also show how to design an idempotent accounting API or give examples in specific platforms like Stripe, QuickBooks, or Xero.
Brands