ZATCA e-invoicing errors explained, with fixes

These are the errors and warnings we actually hit while building Matheel's engine and running it against ZATCA's gateways. For each code: what it means, why it shows up, and how to fix it. If you use Matheel, most of them are handled before the invoice reaches ZATCA.

Counter and hash (the chain)

BR-KSA-33 and BR-KSA-34 · Invoice counter (ICV)

Meaning: every invoice must carry the invoice counter (ICV) in a cac:AdditionalDocumentReference with ID ICV, digits only. Missing it is an error and the invoice is rejected.

Fix: keep one counter per device that goes up by one per invoice and is never reset. Advance it once ZATCA accepts the invoice; fix a rejected invoice and resend it with the same counter. BR-KSA-33 details

BR-KSA-61 and BR-KSA-26 · Previous invoice hash (PIH)

Each invoice carries the previous one's hash (base64 SHA-256). The first invoice on a device uses the initial value published in ZATCA's SDK; after that, store invoice_hash from every accepted response. BR-KSA-61 details

The hash breaks after signing

Any change to the XML after the hash is computed, even re-indenting, makes the hash wrong. Hash last and never touch the document afterwards.

Seller and buyer

BR-KSA-09 and BR-KSA-37 · Seller address

The seller address needs street, building number, postal code, city, district and country code (BR-KSA-09), and the building number must be exactly 4 digits (BR-KSA-37). BR-KSA-09 · BR-KSA-37

BR-KSA-08 · Seller identification

The seller ID (BT-29) appears once with one of the schemes CRN, MOM, MLS, SAG, OTH or 700, alphanumeric only. Most common: the commercial registration with schemeID="CRN". Details

BR-KSA-42, BR-KSA-81 and BR-KSA-44 · Buyer details on standard invoices

A standard (B2B) tax invoice and its notes need the buyer name (BR-KSA-42). A buyer without a VAT number needs another buyer ID (BR-KSA-81); a buyer VAT number must be 15 digits starting and ending with 3 (BR-KSA-44). Simplified invoices need none of this. BR-KSA-42 · BR-KSA-81 · BR-KSA-44

BR-KSA-10 · Buyer address

On standard tax invoices the buyer address needs street, city and country code. ZATCA's message mentions non-Saudi buyers, but the check the SDK actually runs applies to every standard invoice. It does not apply to simplified invoices. Details

Credit and debit notes

BR-KSA-56 and BR-KSA-17 · Reference and reason

Credit (381) and debit (383) notes must reference the original invoice (BillingReference, BR-KSA-56) and state why they were issued (BR-KSA-17, an error that rejects the note). Keep amounts positive: the document type sets the direction. BR-KSA-56 · BR-KSA-17

Totals and lines

BR-CO-10, BR-CO-13 and BR-CO-15 · Totals

The sum of line net amounts equals the lines (BR-CO-10); the total without VAT equals the lines minus document allowances plus document charges (BR-CO-13); the total with VAT equals the total without VAT plus VAT (BR-CO-15, an error). BR-CO-15 details

BR-KSA-EN16931-11 and BR-KSA-51 · Line arithmetic

Line net amount = quantity × (price / base quantity) + line charges − line allowances, and the line amount with VAT = line net amount + line VAT. Details

BR-16, BR-25 and BR-26 · Lines

An invoice needs at least one line (BR-16), and each line needs an item name (BR-25) and a net price (BR-26). If your software only sends a total, make one line carrying the full amount.

BR-KSA-19 · Charge reason

Every document-level charge needs a reason code. Details

BR-KSA-EN16931-08 and BR-CO-18 · Tax total

Only one TaxTotal may carry the tax subtotals (TaxSubtotal), and the invoice needs at least one VAT breakdown (BR-CO-18). Details

VAT and exemptions

BR-KSA-CL-04 and BR-KSA-24 · Exemption reason codes

Zero-rated (Z) and exempt (E) lines need a reason code from ZATCA's list (VATEX-SA-…, BR-KSA-CL-04); out-of-scope (O) needs an exception reason code (BR-KSA-24), which is VATEX-SA-OOS. Watch out: the older VAT-OOS-SA triggers a CL-04 warning; we checked both against the SDK rules. BR-KSA-CL-04 · BR-KSA-24

BR-KSA-68 and BR-KSA-EN16931-02 · Tax currency

TaxCurrencyCode must be present (BR-KSA-68) and be SAR (BR-KSA-EN16931-02); both are errors. Details

BR-KSA-16 · Payment means code

If the invoice has a payment means (BT-81), its code must come from ZATCA's subset of UNTDID 4461 (for example 10 cash, 30 credit transfer, 48 bank card). Details

Timing and field length

BR-KSA-98 · The 24-hour window

Simplified invoices must be reported to ZATCA within 24 hours of issue. Details

BR-KSA-F-06 · Field length

A family of rules setting the length limits of each field. Empty or over-long values raise a warning. All limits in one table

Things with no code that still stop you

All rules and explanations are open data (JSON) on GitHub.

Got a response from ZATCA? Paste it into the response reader and every code in it is explained.

See also where ZATCA's rules differ from their own text: 6 tested findings.

All ZATCA rules

Saudi rules (BR-KSA)

Core invoice rules (EN 16931)

Totals and calculations (BR-CO)

VAT categories (S, Z, E, O)

Code lists (BR-CL)

Field formats (BR-KSA-F)

File a test invoice with ZATCA now

No certificate, no key: Matheel sends it to the developer portal and shows you ZATCA's answer, errors verbatim if any.

Try an invoice or read the API reference →