Implement Saudi E-Invoicing Phase 2 with Structured Onboarding, Secure XML Signing & API Integration
Saudi Arabia's ZATCA Phase 2 e-invoicing requirements introduce an integration layer between a taxpayer's Electronic Invoicing Generation Solution (EGS) and the FATOORA platform operated by the Zakat, Tax and Customs Authority.
i-Softinc helps businesses, ERP providers, software companies, and development teams implement Saudi ZATCA Phase 2 e-invoicing workflows, including CSID onboarding, Certificate Signing Request (CSR) generation, XML invoice preparation, cryptographic signing, compliance validation, and production API integration.
Our implementation approach covers the complete technical journey—from registering an EGS unit and obtaining a Compliance CSID (CCSID) to completing compliance checks, obtaining a Production CSID (PCSID), and integrating invoice reporting and clearance workflows.
What Is Saudi ZATCA Phase 2 E-Invoicing?
ZATCA Phase 2, also known as the Integration Phase, connects taxpayer invoicing systems with the FATOORA platform through defined technical standards and APIs.
The integration requires an EGS to generate electronic invoices in the required XML format, apply applicable security features, and communicate with ZATCA through the appropriate API workflows.
Key implementation areas include:
- UBL 2.1-based XML invoice generation
- EGS unit identification and onboarding
- Certificate Signing Request (CSR) generation
- Compliance CSID and Production CSID management
- XML cryptographic signing and invoice hashing
- QR code generation according to applicable specifications
- Invoice reporting and clearance API integration
- Credit note and debit note processing
- Invoice validation, error handling, and audit records
The exact requirements depend on the invoice type, taxpayer configuration, EGS setup, and applicable ZATCA technical specifications.
Step-by-Step ZATCA Phase 2 CSID Onboarding Process
A structured onboarding process helps businesses prepare their invoicing systems for ZATCA integration. The following stages describe the main technical workflow.
Step 1: Prepare the Taxpayer & EGS Configuration
Before generating certificates, establish the taxpayer and EGS configuration required for onboarding.
The preparation process includes:
- Verify the taxpayer's Saudi VAT registration details.
- Identify the invoice-generating system or EGS unit.
- Configure the taxpayer and branch information.
- Define supported invoice document types.
- Prepare the registered address and business category.
- Identify the required technical environment.
- Review the relevant ZATCA XML and security specifications.
Each EGS unit must be configured with the appropriate identification and certificate information. The onboarding configuration should match the taxpayer and invoice-generation setup.
Step 2: Generate the Certificate Signing Request (CSR)
A Certificate Signing Request is generated using the required EGS configuration and cryptographic key pair.
The CSR contains the information required for the certificate onboarding process.
Our implementation approach covers:
- EGS identification and configuration
- Taxpayer VAT registration details
- Invoice document type configuration
- Registered business address
- Business category information
- Public and private key generation
- CSR generation and validation
The private key should be protected and retained securely within the appropriate key-management environment. It should not be exposed in application logs, public repositories, or ordinary API responses.
Step 3: Generate the OTP & Obtain Compliance CSID (CCSID)
The next stage is requesting the Compliance CSID through the applicable ZATCA onboarding workflow.
The process generally includes:
- Access the relevant ZATCA onboarding portal.
- Generate the required One-Time Password (OTP) for the EGS unit.
- Prepare the CSR using the configured taxpayer and EGS information.
- Submit the CSR to the Compliance CSID onboarding API with the required OTP.
- Process the onboarding response.
- Securely store the returned certificate information and associated secret.
- Record the relevant request identifier for the subsequent onboarding stages.
The Compliance CSID is used for the compliance testing stage. It should not be confused with the Production CSID used for live invoice integration.
Step 4: Perform ZATCA Compliance Invoice Checks
After obtaining the Compliance CSID, the EGS solution must demonstrate that it can generate the required invoice documents and submit them through the compliance-check workflow.
The compliance testing process can include:
- Standard tax invoice validation
- Simplified tax invoice validation
- Standard credit note validation
- Standard debit note validation
- Simplified credit note validation
- Simplified debit note validation
The exact sample documents required depend on the invoice types declared in the EGS configuration.
Our implementation covers:
- XML structure and schema validation
- Mandatory field verification
- Tax category and VAT calculation checks
- Invoice UUID and document reference validation
- Invoice hash generation and verification
- XML signature validation where applicable
- QR code structure validation
- API authentication and response processing
- Compliance error logging and correction workflows
ZATCA's SDK and developer tools can be used to validate invoice documents and test API integration before production onboarding.
Step 5: Obtain Production CSID (PCSID)
After completing the applicable compliance checks, the EGS can proceed with the Production CSID onboarding request.
The process generally involves:
- Confirm successful completion of the required compliance checks.
- Prepare the production onboarding request.
- Submit the relevant compliance request identifier.
- Authenticate using the applicable Compliance CSID credentials.
- Process the Production CSID response.
- Securely store the Production CSID certificate and associated secret.
- Configure the EGS for production communication.
The Production CSID is used for the live integration workflow. Certificate renewal and lifecycle management should also be included in the production architecture.
ZATCA Phase 2 API Integration Architecture
A reliable integration architecture separates invoice generation, security processing, certificate management, API communication, and transaction logging.
1. Invoice Generation Layer
The invoice generation layer receives transaction data from the ERP, POS, accounting system, or billing application.
Responsibilities include:
- Sales invoice creation
- Credit and debit note generation
- Customer and supplier information mapping
- VAT calculation
- Invoice numbering and UUID assignment
- XML document preparation
2. XML Validation & Security Layer
This layer prepares the XML document for the applicable ZATCA workflow.
Responsibilities include:
- XML schema validation
- Business rule validation
- Invoice hash calculation
- Previous invoice hash management
- Digital signature processing where required
- QR code generation
- Certificate selection and validation
3. CSID & Certificate Management Layer
This layer manages the certificate information associated with each EGS unit.
Responsibilities include:
- Compliance CSID management
- Production CSID management
- Certificate expiry tracking
- Secure private key storage
- Certificate renewal workflows
- Environment-specific certificate configuration
- Authentication credential management
4. ZATCA API Communication Layer
The API integration layer communicates with the appropriate ZATCA endpoints.
Key integration workflows include:
- Compliance CSID onboarding
- Compliance invoice checks
- Production CSID onboarding
- Production CSID renewal
- Simplified invoice reporting
- Standard invoice clearance
- Credit and debit note reporting or clearance as applicable
The integration should support secure HTTPS communication, request validation, response handling, retries where appropriate, and transaction-level logging.
5. Database & Audit Management Layer
A centralized database helps maintain invoice processing history and integration records.
Recommended records include:
- Invoice number and UUID
- EGS unit identifier
- Invoice type
- XML document reference
- Invoice hash and previous hash
- CSID reference
- Submission timestamp
- API request and response status
- Clearance or reporting status
- ZATCA response details
- Error messages and retry history
Sensitive certificate secrets and private keys should be stored separately using appropriate secure key-management controls.
Why Choose i-Softinc for Saudi ZATCA Phase 2 Integration?
- End-to-End Integration: Support across onboarding, CSID management, XML generation, signing, reporting, and clearance.
- Custom Software Compatibility: Integration with existing ERP, POS, accounting, and billing platforms.
- Secure Certificate Handling: Architecture for protected private keys, certificate storage, and renewal management.
- XML & API Engineering: Structured implementation of XML validation, invoice hashing, digital signatures, and API communication.
- Custom Middleware Development: Connect multiple business applications through a centralized ZATCA integration layer.
- Error Monitoring & Reporting: Track invoice submissions, API responses, validation issues, and processing status.
- Production-Oriented Architecture: Separate testing and production environments with appropriate configuration and operational controls.




