Validate a ZATCA XML file for free · ZATCA error codes
ZATCA BR-KSA-40: seller VAT number (BT-31) format
BR-KSA-40 · Error
[BR-KSA-40]-If it exists in the invoice, the seller VAT registration number (BT-31) must contain 15 digits. The first and the last digits are "3"..
The official rule: if it exists in the invoice, the seller VAT registration number (BT-31) must contain 15 digits. The first and the last digits are 3.
Official test (UBL XPath), context the seller VAT tax scheme when CompanyID is present: matches(CompanyID, '^[0-9]{15}$') and starts-with(..., '3') and ends-with(..., '3').
Common causes
- A 10-digit identifier was used (a commercial registration belongs in BT-29, not BT-31).
- Spaces, hyphens or a country prefix were included.
- The value does not start or end with
3, or is shorter or longer than 15 digits.
The number below is a format example only, not a real VAT registration. Presence of BT-31 is BR-KSA-39. Valifakt is not a ZATCA-onboarded EGS. This page is not tax advice.
<cac:PartyTaxScheme>
<cbc:CompanyID>399999999900003</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>What if BT-31 is omitted?
BR-KSA-40 applies when the number exists. A missing seller VAT number is BR-KSA-39.
Are letters allowed?
The official test is 15 digits only, with 3 at both ends.
Is the example a real number?
No. It only illustrates the official 15-digit shape.
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-04 – Invoice issue date (BT-2) is in the future or invalid
- BR-KSA-06 – Invoice transaction code (KSA-2) missing 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.