Complete ZATCA Phase 2 (Integration Phase) Technical & ERP Guide
Saudi Arabia’s Zakat, Tax and Customs Authority (ZATCA) Phase 2—known as the Integration Phase—requires VAT-registered taxpayers to integrate their E-Invoice Generation Solutions (EGS) directly with the FATOORA portal using UBL 2.1 XML, cryptographic stamps (CSID), SHA-256 invoice hash chaining, and real-time or 24-hour API transmission.
1. ZATCA Phase 1 (Generation) vs. Phase 2 (Integration)
Phase 1 (effective December 4, 2021) required taxpayers to stop issuing handwritten or unstructured invoices and generate electronic invoices containing basic mandatory fields and a 5-tag Base64 QR code on B2C receipts.
Phase 2 (the Integration Phase, rolled out in waves starting January 1, 2023) introduces strict technical and cryptographic requirements. Every invoice must be structured in ZATCA-compliant UBL 2.1 XML, linked to the preceding invoice via a SHA-256 Previous Invoice Hash (PIH), stamped with a Cryptographic Stamp Identifier (CSID) issued by ZATCA, and transmitted to ZATCA’s FATOORA APIs.
| Requirement Area | Phase 1 (Generation Phase) | Phase 2 (Integration Phase) |
|---|---|---|
| Invoice Format | Any electronic format (PDF, print) | Mandatory UBL 2.1 XML (or PDF/A-3 with embedded XML) |
| ZATCA Connectivity | Offline (no API transmission required) | Direct API integration with ZATCA FATOORA portal |
| Cryptographic Stamp | Not required in Phase 1 | Mandatory ECDSA cryptographic signature via ZATCA CSID |
| Invoice Chaining | Standard sequential numbering | Mandatory Invoice Counter Value (ICV) + Previous Invoice Hash (PIH) |
| QR Code Structure | 5 TLV tags (Seller, VAT, Timestamp, Total, VAT Amt) | 9 TLV tags (adds XML Hash, ECDSA Signature, Public Key & Certificate Signature) |
2. Core Technical Pillars: UBL 2.1 XML, PIH Chaining & TLV QR
Under Phase 2, an ERP cannot simply generate a visual PDF. The system must first construct a canonicalized UBL 2.1 XML document adhering to ZATCA’s Data Dictionary and Schematron validation rules (BR-KSA-*).
Each E-Invoice Generation Solution (EGS) unit maintains an immutable chain of invoices. The first invoice uses a base64-encoded SHA-256 hash of "0" as its Previous Invoice Hash (PIH), and every subsequent invoice embeds the SHA-256 digest of the immediately preceding XML invoice.
- UUID (Universally Unique Identifier): A RFC 4122 UUID v4 generated uniquely for every tax document.
- ICV (Invoice Counter Value): A strictly incrementing integer counter maintained per EGS unit without gaps.
- PIH (Previous Invoice Hash): Cryptographic link preventing retroactive deletion or tampering of historical invoices.
- ECDSA Digital Signature: Generated using the private key paired with the EGS unit’s ZATCA-issued CSID certificate.
3. Why Enterprises Use Middleware Between Their ERP and ZATCA
Core ERP platforms—such as Microsoft Dynamics 365, SAP, Oracle, and custom sector-specific billing systems—are designed for accounting ledgers and operational workflows, not real-time cryptographic XML signing and authority API retry management.
Deploying dedicated middleware like Saky ZATCA Connect decouples statutory e-invoicing cryptography from your core ERP upgrade cycle. Your ERP continues posting invoices normally while the middleware transforms payloads into UBL 2.1 XML, runs pre-flight Schematron validations, communicates with FATOORA, and returns the cleared XML and QR code.
Official ZATCA Regulatory References
- ZATCA E-Invoicing (FATOORA) Portal & Technical Guidelines— Zakat, Tax and Customs Authority (ZATCA)
- ZATCA E-Invoicing Detailed Technical Guideline & XML Implementation Standards— Zakat, Tax and Customs Authority (ZATCA)