ZATCA Guide

Comply with ZATCA e-Invoicing using B2Brouter API

The ZATCA e-Invoicing Resolution (Zakat, Tax and Customs Authority) mandates that businesses operating in Saudi Arabia must generate and submit electronic invoices in UBL XML format. B2Brouter's REST API allows your business to be fully compliant with ZATCA, handling XML generation, hash chaining, and clearance on your behalf.

What is ZATCA e-Invoicing?

ZATCA e-Invoicing (Fatoorah) requires:

  • Generating invoices in UBL 2.1 XML format, with Saudi-specific extensions.
  • Computing a SHA-256 hash chain linking each invoice to the previous one.
  • Submitting each invoice to the ZATCA Clearance API for validation and digital signing.
  • Embedding the QR code returned by ZATCA in the issued invoice.

With B2Brouter you can offload all of this. You issue invoices or create tax reports via REST calls, and B2Brouter handles chaining, clearance, and QR code generation.

Account (Company) Requirements

ZATCA invoices are issued by Saudi Arabian companies. The account must have country: "sa". The following fields are required for SA accounts:

API paramDescriptionNotes
nameCompany legal nameRequired
countryMust be "sa"Required
addressStreet nameRequired
address2Building numberRequired — 4-digit integer
cityCityRequired
postalcodePostal codeRequired
provinceDistrictRequired
tin_valueVAT registration number (15 digits)Required
tin_schemeMust be 9760 (SA VAT)Required

Note: The fields address2 and province correspond to the Saudi address concepts of building number and district respectively. Use address2 and province as the API param names — the API will return errors referencing these names.

Contact Requirements

Contacts (buyers) for ZATCA invoices must also have correct address data. The following fields apply when country is "sa":

API paramDescriptionNotes
nameBuyer legal nameRequired
countryISO-2 country codeRequired
addressStreet nameRequired for SA contacts with ZATCA enabled
address2Building numberRequired for SA contacts with ZATCA enabled
cityCityRequired for SA contacts with ZATCA enabled
postalcodePostal codeRequired for SA contacts with ZATCA enabled
provinceDistrictRequired for SA contacts with ZATCA enabled
tin_valueVAT registration numberRequired for B2B invoices
tin_scheme9760 for SA VAT; see Buyer ID types for foreign buyersRequired

Invoice Requirements

ZATCA invoices use SAR (Saudi Riyal) as currency. Taxes must use name: "VAT" and category: "S" for the standard 15% rate.

Minimal invoice example:

curl --request POST \
     --url https://api-staging.b2brouter.net/accounts/{ACCOUNT_ID}/invoices \
     --header 'X-B2B-API-Key: {YOUR_API_KEY}' \
     --header 'Content-Type: application/json' \
     --data '{
       "send_after_import": true,
       "invoice": {
         "date": "2025-01-15",
         "number": "INV-001",
         "currency": "SAR",
         "payment_method": 1,
         "contact": {
           "name": "Buyer Company Ltd",
           "address": "King Fahd Road",
           "address2": "1234",
           "city": "Riyadh",
           "postalcode": "12345",
           "province": "Riyadh",
           "country": "sa",
           "tin_value": "310175397400003",
           "tin_scheme": 9760,
           "language": "en",
           "currency": "SAR"
         },
         "invoice_lines_attributes": [
           {
             "quantity": 1.0,
             "description": "Professional services",
             "price": 100.0,
             "taxes_attributes": [
               {
                 "name": "VAT",
                 "percent": 15.0,
                 "category": "S"
               }
             ]
           }
         ]
       }
     }'

Tax Categories and Exemption Codes

ZATCA defines four VAT categories. For categories E (Exempt) and Z (Zero rated), a valid exemption reason code (comment on the tax line) is required — the invoice will be rejected without it.

CategoryDescriptionRateExemption code required?
SStandard rate15%No
EExempt from VAT0%Yes — VATEX-SA-29, VATEX-SA-29-7, or VATEX-SA-30
ZZero rated0%Yes — see table below
OOut of scope0%No

The exemption code is set in the comment field of the tax line:

{
  "name": "VAT",
  "percent": 0.0,
  "category": "Z",
  "comment": "VATEX-SA-32"
}

Valid VATEX-SA-* Codes

Category E — Exempt from VAT

CodeDescription
VATEX-SA-29Financial services mentioned in Article 29 of the VAT Regulations
VATEX-SA-29-7Life insurance services mentioned in Article 29 of the VAT Regulations
VATEX-SA-30Real estate transactions mentioned in Article 30 of the VAT Regulations

Category Z — Zero rated

CodeDescription
VATEX-SA-32Export of goods
VATEX-SA-33Export of services
VATEX-SA-34-1The international transport of Goods
VATEX-SA-34-2International transport of passengers
VATEX-SA-34-3Services directly connected and incidental to a Supply of international passenger transport
VATEX-SA-34-4Supply of a qualifying means of transport
VATEX-SA-34-5Any services relating to Goods or passenger transportation (Article 25 of the VAT Regulations)
VATEX-SA-35Medicines and medical equipment
VATEX-SA-36Qualifying metals
VATEX-SA-EDUPrivate education to citizen
VATEX-SA-HEAPrivate healthcare to citizen
VATEX-SA-MLTRYSupply of qualified military goods
VATEX-SA-DIPLOMATQualified Supplies to Diplomatic Missions
VATEX-SA-DUTYFREEQualified Supply of Goods in Duty Free area
VATEX-SA-32(bis)Supply under Customs Suspension Arrangement
VATEX-SA-ROYALDECREESupply on which the Government bears the VAT

Category O — Out of scope

CodeDescription
VATEX-SA-OOSServices outside scope of tax / Not subject to VAT (free text per case)

Buyer ID Types

For foreign buyers (non-SA), use tin_scheme to specify the identifier type:

tin_schemeDescription
9760Saudi VAT registration number
0002EU VAT number
0003Passport number
0004Official ID (country of residence)
0005Certificate of residence
0006Other document
0007Not registered

Tax Report Lifecycle

After creating or sending an invoice, ZATCA clearance is asynchronous. The tax_report will be in processing state initially.

Monitor progress via:

Field Mapping: Invoice API → ZATCA XML

Invoice API fieldZATCA XML element
numbercbc:ID
datecbc:IssueDate
company.tin_valueSupplier cbc:CompanyID
company.address2Supplier cbc:BuildingNumber
company.provinceSupplier cbc:District
contact.tin_valueCustomer cbc:CompanyID
contact.address2Customer cbc:BuildingNumber
contact.provinceCustomer cbc:District
tax.percentcbc:Percent
tax.categorycbc:ID in cac:TaxCategory
tax.commentcbc:TaxExemptionReasonCode
invoice.totalcbc:TaxInclusiveAmount
invoice.subtotalcbc:TaxExclusiveAmount