Validate a ZATCA XML file for free · ZATCA error codes
ZATCA BR-KSA-06: invoice transaction code (KSA-2)
BR-KSA-06 · Error
[BR-KSA-06]-The invoice transaction code (KSA-2) must exist and respect the following structure: NNPNESBCG where NN (positions 1 and 2) = invoice subtype: - 01 for tax invoice - 02 for simplified tax invoice P (position 3) = 3rd Party invoice transaction, 0 for false, 1 for true; N (position 4) = Nominal invoice transaction, 0 for false, 1 for true; E (position 5) = Exports invoice transaction, 0 for false, 1 for true; S (position 6) = Summary invoice transaction, 0 for false, 1 for true; B (position 7) = Self billed invoice transaction, 0 for false, 1 for true; C (position 8) = Continuous Supply invoice transaction, 0 for false, 1 for true; G (position 9) = B2G invoice transaction, 0 for false, 1 for true
The official rule text requires the invoice transaction code (KSA-2) to exist and to follow the structure NNPNESBCG, where:
- NN (positions 1–2) = invoice subtype:
01tax invoice,02simplified tax invoice - P, N, E, S, B, C, G (positions 3–9) = 3rd-party, nominal, exports, summary, self-billed, continuous supply, and B2G flags; each
0(false) or1(true)
The official message describes a 9-character code. In the same SDK XSL, the compiled xsl:if test accepts a code of length 7, 8 or 9 whose characters match those flags, and a related warning BR-KSA-F-06-C40 states that the minimum length is 7 and the maximum is 9. The svrl:failed-assert @test attribute still documents only the 7-character form. This page quotes those official artefacts as they are, without choosing between them.
Official context: cbc:InvoiceTypeCode; the transaction code is the name attribute (KSA-2), not the type-code value (BT-3).
Common causes
- The
nameattribute is missing, empty, or shorter than 7 characters. - Positions 1–2 are not
01or02, or a later position is not0or1. - The subtype was written in the element text instead of in
@name.
The snippet shows a 7-character standard tax invoice with all flags false (0100000). A 9-character form such as 010000000 matches the NNPNESBCG layout in the official message. Which flags must be 1 for a given supply is a tax-law question this page does not answer. Valifakt is not a ZATCA-onboarded EGS.
<cbc:InvoiceTypeCode name="0100000">388</cbc:InvoiceTypeCode>Is the type code 388 itself KSA-2?
No. BT-3 is the element text (for example 388). KSA-2 is the name attribute on that element.
7 or 9 characters?
The official message describes nine positions (NNPNESBCG). The compiled SDK test accepts length 7, 8 or 9, and BR-KSA-F-06-C40 warns that the length must be between 7 and 9. We quote both.
Which flags should I set to 1?
That depends on the transaction. This page only restates the official structure; it is not tax advice.
Related ZATCA rules
- BR-KSA-03 – Invoice UUID (KSA-1) missing or invalid
- BR-KSA-08 – Seller identification (BT-29) missing or wrong scheme
- BR-KSA-26 – Previous invoice hash (PIH, KSA-13) is not base64 SHA-256
- BR-KSA-27 – QR code (KSA-14) missing or not base64Binary
- BR-KSA-39 – Seller VAT number (BT-31) missing
- BR-KSA-40 – Seller VAT number (BT-31) is not 15 digits starting and ending with 3
- BR-KSA-04 – Invoice issue date (BT-2) is in the future or invalid
- BR-KSA-17 – Credit or debit note missing the reason (KSA-10)
Validate a ZATCA XML file for free Pricing
Not tax advice. Valifakt is not a ZATCA-onboarded e-invoicing solution (EGS). Official rule text is quoted from the ZATCA SDK validation-rules XSL.