Skip to main content

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.

Zuny FesterBy Zuny Fester, Head of Operations and Marketing
Reviewed by Zuny Fester
Published Last reviewed Editorial policy

Part of the finance integrations guide.

SymptomAvaTax returns a DocumentCodeConflict error on transaction creation
Root causeThe document code matches an already-committed transaction
If the original is still uncommittedResubmitting 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 committedCall the adjust or void endpoint instead of resubmitting the code
If the original was already reported to a tax authorityNeither 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.

Book a workflow review

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

That creates a new, separate transaction — it doesn't fix a retry, it duplicates it. Check first whether the original already represents the transaction you intended (query by the original code); if so, the goal is recognizing that, not working around the conflict with a new code.

No — DocumentCodeConflict specifically requires the original to be committed. But that doesn't make an uncommitted resubmit safe: AvaTax has been observed accepting the same uncommitted code twice and creating two separate documents, silently, with no error at all.

It usually means the opposite — it's the error that prevents a committed duplicate. It fires because AvaTax caught the collision, not because one slipped through. A duplicate is more likely when the code changes between attempts and no conflict ever has the chance to fire.

Sources

Related