Why is Avalara rejecting a sales invoice with a DocumentCodeConflict error?
A DocumentCodeConflict means the document code you sent already belongs to a committed transaction in AvaTax. The fix is not a fresh code — retrying with a new code every time is exactly what creates duplicate tax transactions on a real network retry. Keep the code stable, derived from the source invoice, and call the adjust or void endpoint if the original genuinely needs to change.
Part of the finance integrations guide.
| Symptom | AvaTax returns a DocumentCodeConflict error on transaction creation |
|---|---|
| Root cause | The document code matches an already-committed transaction |
| If the original is still uncommitted | Resubmitting the same code can create a second document with a different transaction id — AvaTax does not treat this as a conflict, and does not treat it as idempotent either |
| If the original is committed | Call the adjust or void endpoint instead of resubmitting the code |
| If the original was already reported to a tax authority | Neither adjust nor void applies — file a reverse transaction instead |
What a document code actually is
Every transaction created in AvaTax carries a document code — an internal reference string your integration assigns, used to get, adjust, settle, or void that specific transaction later. Avalara's own model documentation describes it as "the internal reference code used by the client application," and notes that if you leave it blank, AvaTax assigns a GUID automatically. The code is how AvaTax tells two transactions apart — which is exactly what breaks when the same code shows up twice.
Why the conflict happens
AvaTax treats a committed transaction as finalized. Once a document code has been committed, that code is reserved and cannot be reused for a different transaction — Avalara's own DocumentCodeConflict error documentation states this directly. In practice, this shows up in one of two ways: a retry after a network timeout resubmits the same invoice with the same code, not realizing the first attempt actually succeeded and committed; or a downstream system reuses an invoice number as the document code for a genuinely different transaction — a credit memo, or a corrected invoice — without checking whether that number was already used.
The uncommitted case is not the safe case it looks like
If the original transaction with that code is still uncommitted, AvaTax won't raise DocumentCodeConflict — but that's not the same as safely deduplicating. A real sandbox replay (recorded internally as TD-2026-140) submitted the same uncommitted SalesInvoice document code twice, and both requests succeeded, each returning a different transaction id. AvaTax does not merge or reject the second submission; it creates a second document that happens to share a code with the first. The absence of an error is not confirmation that nothing duplicated — checking for an existing uncommitted document with that code before resubmitting is the only way to know.
If the original is committed
Don't resubmit the code at all: call the adjust endpoint to modify it, or the void endpoint to cancel it. If the transaction has already been reported to a tax authority, neither adjust nor void is available — the fix is to create a new, separate reverse transaction with opposite amounts, rather than trying to touch the original.
The fix that prevents it from recurring
Do the opposite of generating a fresh code per attempt: derive the document code deterministically from the source invoice or order — something stable across retries, not a GUID minted fresh each call — and reuse that exact code on every retry. A DocumentCodeConflict on a retry then becomes useful information: it tells you the earlier attempt already committed, not that something is broken. Generating a new code on every retry removes AvaTax's only way of recognizing a repeat, and is precisely what produces a duplicate — for both the uncommitted case above and the committed case DocumentCodeConflict is meant to catch.
Next step
Map the finance workflow with the most exposure and prove the automation path.
Bring the invoice, contract, payment reconciliation, or customer finance workflow you have to defend at audit. Loopfour can map the trigger, controls, integrations, and approval loop.
Worked example
A retried invoice that collides with itself
A billing system sends invoice INV-4821 to AvaTax using the invoice number as the document code. The request times out on the client side before a response arrives, so the integration retries automatically with the same code. What actually happened: the first request succeeded and committed. The retry now collides with a committed transaction carrying the same code, and AvaTax returns DocumentCodeConflict — which, correctly read, means the invoice is already taxed and committed, not that something is missing. Checking AvaTax's own transaction history for INV-4821 confirms it already exists. The fix here is to treat this exact outcome as expected: query GetTransactionByCode for INV-4821 before assuming a timeout means failure, and keep using the same deterministic code (the invoice number) on every retry — not a fresh one — so a genuine retry is always recognizable as a retry.
Frequently Asked Questions
Sources
Related
Topic
Integrations
Every finance automation vendor publishes an integrations page: a grid of logos, a claim of "seamless" connectivity, and not much else. That page answers a marketing question — does this vendor touch…
Read moreDiagnostic
Why doesn't an uncommitted Avalara transaction show up on my sales tax return?
AvaTax only reports committed transactions. Commit status is a flag that determines whether a transaction appears on your compliance reports and gets remitted — uncommitted transactions are treated as provisional and are excluded from liability calculations and filings until someone explicitly commits them.
Read moreHow-to
How do I sync a Rillet contract amendment into my revenue recognition schedule?
Call Rillet's amend-a-contract endpoint with an amendment_date, an amendment_reason, and the changed items, choosing whether each item takes effect as of the amendment date or at the end of the current billing cycle. Rillet regenerates the affected revenue schedule and journal impact for review before anything posts.
Read more