ZATCA Electronic Invoicing (Fatoora) Technical Specification & Architecture Reference
An encyclopedic engineering specification of the Kingdom of Saudi Arabia's national electronic invoicing mandate administered by the Zakat, Tax and Customs Authority (ZATCA), covering regulatory phases, OASIS UBL 2.1 XML extensions, XAdES-EPES cryptographic stamping (secp256k1), SHA-256 hash chaining, and binary Tag-Length-Value (TLV) QR serialization.
- Document ID
- KSA-ZATCA-TECH-SPEC
- XML Schema
- OASIS UBL 2.1
- Cipher Suite
- ECDSA secp256k1 + SHA-256
- Last Updated
1. Regulatory Framework & Two-Phase Mandate
Electronic invoicing in the Kingdom of Saudi Arabia—officially designated as the Fatoora (فاتورة) program—was established by the Board of Directors of the Zakat, Tax and Customs Authority (ZATCA) (formerly the General Authority of Zakat and Tax, GAZT) pursuant to Board Resolution No. (2-6-20) dated 19/04/1442 AH (4 December 2020). On 28 May 2021, ZATCA enacted the companion implementation statute, Controls, Requirements, Technical Specifications and Procedural Rules for Implementing the Provisions of the E-Invoicing Regulation.
The regulatory architecture applies to all resident VAT-registered taxpayers in Saudi Arabia (and third parties issuing tax invoices on their behalf) and is enforced in two sequential operational phases:
- Phase 1 — Generation Phase (مرحلة الإصدار والحفظ), effective 4 December 2021: Prohibits handwritten invoices and unformatted text editors. Mandates that all taxpayers generate and store electronic tax invoices, simplified tax invoices, and associated credit/debit notes using a compliant electronic invoicing system (EGS), including a Base64-encoded Tag-Length-Value (TLV) Quick Response (QR) code on simplified invoices containing five mandatory fiscal fields (Tags 1–5).
- Phase 2 — Integration Phase (مرحلة الربط والتكامل), effective 1 January 2023 in phased waves: Mandates direct cryptographic and API integration between each taxpayer's Electronic Invoice Generation Solution (EGS) unit and ZATCA's centralized Fatoora portal. Phase 2 enforces strict XML structural validation under OASIS Universal Business Language (UBL 2.1, ISO/IEC 19845:2015), tamper-evident invoice chaining via a SHA-256 Previous Invoice Hash (PIH), digital signing with an elliptic-curve Cryptographic Stamp Identifier (CSID), and four additional cryptographic QR tags (Tags 6–9).
2. Document Taxonomy & Clearance Models
Under Article 53 of the KSA VAT Implementing Regulations and the ZATCA E-Invoicing Data Dictionary, electronic fiscal documents are classified by two UBL attributes: cbc:InvoiceTypeCode (UN/CEFACT Code List 1001) and its seven-character subtype attribute name="NNPNESB".
| Document Category | Subtype Prefix (NN) | Type Codes (cbc:InvoiceTypeCode) | Phase 2 Transmission Model |
|---|---|---|---|
| Standard Tax Invoice (B2B / B2G) | 01xxxxx | 388 (Invoice), 381 (Credit Note), 383 (Debit Note), 386 (Prepayment) | Real-Time Clearance (CTC): XML is transmitted synchronously to ZATCA before issuance. ZATCA validates, counter-signs, injects the clearance stamp and QR code, and returns the cleared XML to the seller for delivery to the buyer. |
| Simplified Tax Invoice (B2C / POS) | 02xxxxx | 388 (Invoice), 381 (Credit Note), 383 (Debit Note) | Asynchronous Reporting: EGS signs the XML locally using its Production CSID, prints/delivers the invoice with a 9-tag QR code immediately to the consumer, and reports the signed XML to ZATCA within 24 hours of generation. |
3. OASIS UBL 2.1 XML & Hash Chaining (PIH)
Every Phase 2 electronic invoice is serialized as UTF-8 encoded XML (without Byte Order Mark, BOM) conforming to the OASIS UBL 2.1 schema (detailed UBL 2.1 XML guide). To prevent retroactive invoice deletion or sequence manipulation, each EGS unit maintains a strictly monotonic ledger anchored by three Saudi-specific business terms:
- Universally Unique Identifier (UUID,
KSA-1/cbc:UUID): A RFC 4122 Version 4 UUID uniquely identifying the fiscal document across the national registry. - Invoice Counter Value (ICV,
KSA-16): A sequential, non-resettable integer (1, 2, 3, ...) incremented per EGS unit for every generated fiscal document regardless of document type. - Previous Invoice Hash (PIH,
KSA-13): The Base64-encoded SHA-256 digest of the immediately preceding XML invoice generated by the same EGS unit. For the first invoice (ICV = 1) on a new EGS device, the specification mandates the SHA-256 digest of the ASCII character"0":
<!-- Genesis Previous Invoice Hash (PIH for ICV = 1: Base64(Hex(SHA-256("0")))) -->
<cac:AdditionalDocumentReference>
<cbc:ID>PIH</cbc:ID>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==</cbc:EmbeddedDocumentBinaryObject>
</cac:Attachment>
</cac:AdditionalDocumentReference>
<!-- Monotonic Invoice Counter Value (ICV) -->
<cac:AdditionalDocumentReference>
<cbc:ID>ICV</cbc:ID>
<cbc:UUID>1</cbc:UUID>
</cac:AdditionalDocumentReference>
To compute an invoice's canonical hash (KSA-14), the processor removes the <ext:UBLExtensions> block, the <cac:Signature> block, and the QR <cac:AdditionalDocumentReference> node via XPath filtering, applies W3C Canonical XML 1.1 (C14N11), hashes the resulting byte stream using SHA-256, and Base64-encodes the 32-byte binary digest.
4. Cryptographic Stamp Identifier (CSID) & Public Key Infrastructure
Unlike RSA-based e-invoicing regimes, ZATCA mandates Elliptic Curve Digital Signature Algorithm (ECDSA) over the secp256k1 curve (ASN.1 Object Identifier 1.3.132.0.10) with SHA-256 (`ecdsa-with-SHA256`). Each EGS unit undergoes a two-stage cryptographic onboarding lifecycle:
- Certificate Signing Request (CSR) Generation: The EGS generates a secp256k1 keypair locally and constructs a PKCS#10 CSR containing ZATCA-specific X.509v3 Subject Alternative Name (`SAN`) attributes: EGS Serial Number (`1-Vendor|2-Version|3-UUID`), 15-digit VAT Registration Number (`UID`), Invoice Type support mask (`1100` for both Standard and Simplified), Location/Branch address, and Industry category.
- Compliance CSID (CCSID): Using a 6-digit One-Time Password (OTP) generated in the Fatoora portal, the EGS submits the CSR to the ZATCA Compliance API and receives a short-lived Compliance CSID to execute mandatory compliance checks across standard, simplified, credit, and debit test payloads.
- Production CSID (PCSID): Upon passing compliance validation, ZATCA issues a Production X.509v3 certificate (`PCSID`) used to authenticate API requests (HTTP Basic Auth via BinarySecurityToken + Secret) and embed ETSI XAdES-EPES digital signatures inside
<ext:UBLExtensions>.
5. Binary TLV QR Code Encoding (Tags 1–9)
ZATCA QR codes do not encode plain text or web URLs; they encode a binary Tag-Length-Value (TLV) byte array serialized into a Base64 string (see detailed TLV QR implementation notes). Each field consists of a 1-byte unsigned integer Tag (`0x01`–`0x09`), a 1-byte (or multi-byte length-prefixed) unsigned integer Length representing the exact byte count, and the raw Value bytes:
| Tag Byte | Field Name | Data Dictionary ID | Value Encoding | Mandate Scope | Specification Notes |
|---|---|---|---|---|---|
| 0x01 (1) | Seller's Name | BT-27 | UTF-8 String | Phase 1 & 2 | Legal entity name registered with ZATCA; byte length equals UTF-8 octet count (not character count for Arabic). |
| 0x02 (2) | Seller's VAT Registration Number | BT-31 | ASCII Numeric (15 bytes) | Phase 1 & 2 | 15-digit Saudi Tax Identification Number (TIN) starting and ending with '3'. |
| 0x03 (3) | Invoice Issue Timestamp | BT-2 / KSA-25 | ASCII ISO 8601 | Phase 1 & 2 | Combined IssueDate and IssueTime formatted as YYYY-MM-DDTHH:mm:ssZ or local KSA time (UTC+03:00). |
| 0x04 (4) | Invoice Total Amount (with VAT) | BT-112 | ASCII Decimal | Phase 1 & 2 | TaxInclusiveAmount rounded to 2 decimal places (e.g., '1150.00'). |
| 0x05 (5) | Total VAT Amount | BT-110 | ASCII Decimal | Phase 1 & 2 | TaxTotal amount in SAR rounded to 2 decimal places (e.g., '150.00'). |
| 0x06 (6) | Cryptographic XML Invoice Hash | KSA-14 | Base64 / Raw SHA-256 | Phase 2 Only | SHA-256 digest of the canonicalized UBL 2.1 XML invoice excluding UBLExtensions and QR reference. |
| 0x07 (7) | ECDSA Digital Signature | KSA-15 | Base64 / ASN.1 DER | Phase 2 Only | ECDSA signature over secp256k1 generated using the taxpayer's private key. |
| 0x08 (8) | ECDSA Public Key | KSA-15 | Raw / DER Octets | Phase 2 Only | SubjectPublicKeyInfo extracted from the X.509 Cryptographic Stamp Identifier (CSID) certificate. |
| 0x09 (9) | ZATCA CA Certificate Signature | KSA-15 | Raw Octets | Phase 2 Only | Digital signature of the ZATCA Root/Subordinate CA over the taxpayer's CSID certificate (mandatory for Simplified Tax Invoices). |
6. Phase 2 Integration Rollout Waves (Waves 1–24)
ZATCA notifies taxpayer cohorts at least six months prior to their mandatory Phase 2 integration enforcement window based on annual VAT-taxable revenue in Saudi Riyals (SAR):
| Cohort Wave | Annual Taxable Revenue Threshold | Reference Tax Period | Mandatory Integration Window |
|---|---|---|---|
| Wave 1 | > SAR 3,000,000,000 | 2021 | 1 Jan 2023 – 30 Jun 2023 |
| Wave 2 | > SAR 500,000,000 | 2021 | 1 Jul 2023 – 31 Dec 2023 |
| Wave 3 | > SAR 250,000,000 | 2021 or 2022 | 1 Oct 2023 – 31 Jan 2024 |
| Wave 4 | > SAR 150,000,000 | 2021 or 2022 | 1 Nov 2023 – 29 Feb 2024 |
| Wave 5 | > SAR 100,000,000 | 2021 or 2022 | 1 Dec 2023 – 31 Mar 2024 |
| Wave 6 | > SAR 70,000,000 | 2021 or 2022 | 1 Jan 2024 – 30 Apr 2024 |
| Wave 7 | > SAR 50,000,000 | 2021 or 2022 | 1 Feb 2024 – 31 May 2024 |
| Wave 8 | > SAR 40,000,000 | 2021 or 2022 | 1 Mar 2024 – 30 Jun 2024 |
| Wave 9 | > SAR 30,000,000 | 2021 or 2022 | 1 Jun 2024 – 30 Sep 2024 |
| Wave 10 | > SAR 25,000,000 | 2022 or 2023 | 1 Oct 2024 – 31 Dec 2024 |
| Wave 11 | > SAR 15,000,000 | 2022 or 2023 | 1 Nov 2024 – 31 Jan 2025 |
| Wave 12 | > SAR 10,000,000 | 2022 or 2023 | 1 Dec 2024 – 28 Feb 2025 |
| Wave 13 | > SAR 7,000,000 | 2022 or 2023 | 1 Jan 2025 – 31 Mar 2025 |
| Wave 14 | > SAR 5,000,000 | 2022 or 2023 | 1 Feb 2025 – 30 Apr 2025 |
| Wave 15 | > SAR 4,000,000 | 2022 or 2023 | 1 Mar 2025 – 31 May 2025 |
| Wave 16 | > SAR 3,000,000 | 2022 or 2023 | 1 Apr 2025 – 30 Jun 2025 |
| Wave 17 | > SAR 2,500,000 | 2022 or 2023 | 1 May 2025 – 31 Jul 2025 |
| Wave 18 | > SAR 2,000,000 | 2022 or 2023 | 1 Jun 2025 – 31 Aug 2025 |
| Wave 19 | > SAR 1,750,000 | 2022 or 2023 | 1 Jul 2025 – 30 Sep 2025 |
| Wave 20 | > SAR 1,500,000 | 2022 or 2023 | 1 Aug 2025 – 31 Oct 2025 |
| Wave 21 | > SAR 1,250,000 | 2022, 2023, or 2024 | 1 Sep 2025 – 30 Nov 2025 |
| Wave 22 | > SAR 1,000,000 | 2022, 2023, or 2024 | 1 Oct 2025 – 31 Dec 2025 |
| Wave 23 | > SAR 750,000 | 2022, 2023, or 2024 | 1 Dec 2025 – 31 Mar 2026 |
| Wave 24 | > SAR 375,000 | 2022, 2023, or 2024 | 1 Mar 2026 – 30 Jun 2026 |
7. Normative References & Standards
- Zakat, Tax and Customs Authority (ZATCA): Electronic Invoicing Regulation, issued by GAZT Board Resolution No. (2-6-20) dated 19/04/1442 AH (4 December 2020), Riyadh, Kingdom of Saudi Arabia.
- Zakat, Tax and Customs Authority (ZATCA): Controls, Requirements, Technical Specifications and Procedural Rules for Implementing the Provisions of the E-Invoicing Regulation, 28 May 2021 (and subsequent amendments).
- Zakat, Tax and Customs Authority (ZATCA): Electronic Invoice XML Implementation Standard & Data Dictionary (vFATOORA) and Security Features Implementation Standards.
- ISO/IEC 19845:2015 / OASIS UBL 2.1: Information technology — OASIS Universal Business Language version 2.1 (UBL v2.1), International Organization for Standardization / OASIS Open.
- W3C XML-C14N11: Canonical XML Version 1.1, W3C Recommendation, 2 May 2008.
- ETSI EN 319 132-1: Electronic Signatures and Infrastructures (ESI); XAdES digital signatures; Part 1: Building blocks and XAdES baseline signatures.