Skip to content

Accounting APIs without idempotency keys leave integrators guessing after timeouts

A developer who integrates with 30+ accounting and ERP systems describes how lost responses and retries can book journal entries twice, and why common workarounds such as lookups, timing checks and nightly clean-up fall short.

4 min readBased on 1 source14 views

TL;DR

  • Many accounting and ERP APIs offer no idempotency key, so a caller who gets a timeout cannot tell whether a write succeeded.
  • Lookups by document number, duplicate checks and nightly clean-up each have gaps that can still lead to double-booked or wrongly skipped entries.
  • The reliable fix is an idempotency key enforced by the system that stores the entry.

The problem of the unknown outcome

Idempotency means that repeating the same request has the same effect as sending it once. Stripe popularized the pattern: the client sends an Idempotency-Key header, the server stores that key with its response, and a repeated key returns the stored response instead of doing the work again. The pattern works well when you build the API yourself. It breaks down when you are the caller and the other side does not support it.

The developer behind this Stack Overflow Blog post works at maesn, which runs a unified API that passes customer data to more than 30 accounting and ERP systems built by other companies. When a request to one of those systems times out, the caller cannot see whether the entry was created. A dropped connection and a lost response look the same from the outside. Retrying may book an entry twice, and not retrying may leave it missing.

The risk is higher for bookkeeping. Once entries are locked, they cannot simply be changed or deleted. They are corrected with a reversing or correction entry, which someone has to explain later. Some platforms send entries straight into the books with no review step.

A duplicate that passed without an error

The author tested a batch upload on one platform by sending the same file twice. Both uploads returned success. The platform only flagged the copy during import, with a yellow notice in the import log that pointed to the original entry. The duplicate could still be accepted with one click. The author notes that this platform is the forgiving case, since on other systems entries are booked on arrival with no notice at all.

Three workarounds and where they fail

The first workaround is a lookup. After a timeout, the caller searches for the document number, usually the supplier's invoice number, and resends only if nothing is found. The weakness is that document numbers are unique only per supplier, and numbering often restarts each year. A stricter search on account, amount and date still cannot prove that a match is the same posting, since two identical purchases on the same day look the same in the data.

The second workaround checks before each write, which fails on timing. If a client retry starts while the first request is still being processed, both searches can return empty. Some systems also index new records with a delay, so a search right after a write can miss it. The check also doubles the number of calls, which matters where providers cap requests per minute.

The third workaround is a scheduled job that compares what was sent with what the system holds and flags duplicates. The author trusts this one least. Until the job runs, the duplicate is a real entry, and some systems have no delete for journal entries, so the only fix is a reversing entry, which is another write that can also fail. After a month is closed, fixing a duplicate means a correction in the next period, which can affect a VAT return that has already been filed. Scanning a large month page by page is also slow, and the data keeps changing during the scan.

Why providers leave the key out

The author does not assume carelessness. Accounting APIs were often built for data export or to mirror single screens in the user interface, where a person rarely submits the same form twice. Integrations that retry automatically at night are a different case, and their duplicates often go unnoticed until an accountant finds them.

Even providers that do support keys differ. One reads the key from a header, another from the URL. Some expire keys after a while, so a late retry counts as a new request. Some accept keys only on certain endpoints. The author's advice is to test each provider directly: send the same request twice with the same key, count the entries created, and repeat the test after each release.

Why it matters

For developers who integrate with accounting, ERP or other back-office systems, a timeout is not a clear failure. Retry logic needs to be designed around an unknown outcome, and the check for whether a provider supports idempotency belongs in the integration plan. Keys are only one part of the design. The post also points to what a correct implementation needs: the server stores keys with their responses, defines what counts as the same request, documents how long a key lives, and returns a 409 when a request with the same key is still in progress. Teams that build APIs on top of others' systems should treat every unconfirmed write as possibly applied, and test the provider's behavior before relying on it.

Sources

This article was written by Blozhik from the reporting below. Read the originals for full detail.

StIdempotency when you don't control the other endStack Overflow Blog
Was this useful?

Keep reading

Discussion · 0

Sign in to join the discussion. Liking does not need an account.Sign inRegister
Loading comments…
blozhikDeveloper news from across the web, explained. Every story links to its original sources.