Architectural Taxonomy: Developer Portal vs Simulation vs Production
ZATCA provides three distinct environments across the software development lifecycle. Understanding their boundaries prevents accidental production pollution:
| Dimension | Developer Developer Portal (Sandbox) | Simulation Sandbox (Staging) | Production Core (Live) |
|---|---|---|---|
| Gateway Hostname | gw-fatoora.zatca.gov.sa/e-invoicing/developer-portal | gw-fatoora.zatca.gov.sa/e-invoicing/simulation | gw-fatoora.zatca.gov.sa/e-invoicing/core |
| Target Audience | Software vendors building generic integrations. | Enterprise IT & taxpayers testing their specific ERP. | Operational daily business commerce. |
| Taxpayer Credentials | Generic test TRN (e.g., 399999999900003). | Real Taxpayer VAT TRN with portal OTP. | Real Taxpayer VAT TRN with live PCSID. |
| Legal Validity of Invoices | None (Zero). | None (Zero). Staging mirror. | 100% Legal Tax Record. |
| Schematron Rules Engine | Latest experimental/draft Schematron rules. | Exact mirror of production rules. | Enforces live statutory penalties. |
| Rate Limits | Moderate (throttled on high concurrency). | High (designed for volume testing). | Mission-critical enterprise throughput. |
Local Java SDK Audit
Validate raw UBL 2.1 XML offline using ZATCA SDK CLI; eliminate XSD and Schematron syntax errors
Simulation OTP Handshake
Log into Fatoora Portal, select 'Simulation Environment', generate 6-digit test OTP
Simulation CSID Issuance
Submit CSR to /simulation/compliance; obtain test Compliance CSID and secret
Execute Test Suite
Clear B2B Standard Invoices, Credit Notes, Debit Notes, and report B2C receipts in sandbox
Production Go-Live
Promote verified software to live /core endpoints with 100% confidence
Local Pre-Flight Testing: The ZATCA Java SDK CLI
Before sending HTTP requests over the network, developers should use the official ZATCA Java E-Invoicing SDK to catch arithmetic, UUID, and schema bugs locally:
1. Validating XML Against Schematron Rules
Run the SDK command-line interface against your generated invoice XML:
# Offline XML validation command
fatoora -validate -invoice sample_b2b_invoice.xmlExpected SDK Output (Success):
*** INVOICE VALIDATION RESULTS ***
[INFO] XSD Validation: PASSED
[INFO] Schematron Validation: PASSED
[INFO] Cryptographic Hash Verification: PASSED
[SUCCESS] Invoice is 100% compliant with ZATCA Phase 2 specifications.If errors exist, the SDK outputs the exact line number and rule ID (e.g., BR-CO-10: Tax amount rounding failure on line 4), allowing developers to patch software logic prior to cloud transmission.
Step-by-Step Guide: Onboarding on the Simulation Sandbox
Connecting an ERP to the Simulation Sandbox mirrors the production onboarding process:
Step 1: Generate a Simulation OTP on Fatoora Portal
Step 2: Request Simulation Compliance CSID (API Call)
Submit an HTTP POST request to the simulation gateway:
POST /e-invoicing/simulation/compliance HTTP/1.1
Host: gw-fatoora.zatca.gov.sa
Accept-Language: en
Accept-Version: V2
OTP: 839201
Content-Type: application/jsonRequest JSON Body:
{
"csr": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0K...[BASE64_CSR]..."
}Response (HTTP 200 OK):
{
"requestID": 501928,
"dispositionMessage": "ISSUED",
"binarySecurityToken": "MIIEkjCCA3qgAwIBAgIQ...[SIMULATION_X509_CERT]...",
"secret": "e1f2a3b4-c5d6-47e8-9f0a-1b2c3d4e5f6a",
"errors": null
}Step 3: Pass the Mandatory Simulation Test Cases
Using the binarySecurityToken and secret for HTTP Basic Auth, submit the 6 required test scenarios to /e-invoicing/simulation/compliance/invoices:
Step 4: Promote to Simulation Production CSID
Once all sample documents pass validation, execute the promotion call:
PATCH /e-invoicing/simulation/production/csids HTTP/1.1
Host: gw-fatoora.zatca.gov.sa
Accept-Language: en
Accept-Version: V2
Content-Type: application/json
Authorization: Basic <Base64(Simulation_BinarySecurityToken:Simulation_Secret)>{
"compliance_request_id": "501928"
}ZATCA returns your Simulation Production CSID, authorizing your software to test live simulated clearance and reporting calls.
Comprehensive Simulation Test Matrix for Enterprise QA
Enterprise Quality Assurance (QA) teams should execute the following test scenarios to verify operational resilience:
| Test Case ID | Transaction Type | Verification Objective | Expected Response |
|---|---|---|---|
| TC-SIM-01 | Standard B2B Invoice | Normal B2B sale with 15% VAT; clearance stamp returned. | HTTP 200 OK / status: CLEARED |
| TC-SIM-02 | Simplified B2C Invoice | Normal retail cash receipt; 9-tag QR code generated. | HTTP 200 OK / status: REPORTED |
| TC-SIM-03 | Zero-Rated Export Invoice | Cross-border supply with VAT Category Z (0%). | HTTP 200 OK / status: CLEARED |
| TC-SIM-04 | Exempt Supply Invoice | Financial services supply with VAT Category E. | HTTP 200 OK / status: CLEARED |
| TC-SIM-05 | B2B Partial Credit Note | Returns 25% of goods; links original UUID via BillingReference. | HTTP 200 OK / status: CLEARED |
| TC-SIM-06 | Out-of-Sequence ICV Test | Deliberately skip an ICV counter number (Negative Test). | HTTP 400 Bad Request / BR-KSA-53 |
| TC-SIM-07 | Broken Hash Chain Test | Inject incorrect PIH hash string (Negative Test). | HTTP 400 Bad Request / BR-KSA-51 |
| TC-SIM-08 | Gateway Timeout Test | Simulate network drop; verify ERP retry and idempotency. | Transaction queued locally; zero data loss |
Negative Testing: Stress-Testing Edge Cases
A major advantage of the Simulation Sandbox is the ability to deliberately break rules to ensure your ERP fails gracefully:
Statutory Safeguards & Rights Protection
Mandatory protections enforced by MHRSD & Saudi Labor Law
Real-World Case Study: Jeddah Retail E-Commerce Marketplace
In October 2025, a Jeddah-based e-commerce platform processing 45,000 orders weekly prepared for Phase 2 Wave 9 compliance:
* The checkout engine was using system UTC timestamps (14:00:00Z) rather than local Saudi Arabia time (17:00:00), failing Schematron rule BR-KSA-31.
* Promotional discount codes were generating negative line items, which is prohibited under ZATCA rules.
Common Simulation Errors & Immediate Developer Fixes
| Gateway Error Message | Root Cause | Remediation Protocol |
|---|---|---|
| `401 Unauthorized: Invalid Certificate` | Using a Production CSID on the Simulation gateway, or vice versa. | Keep simulation and production credentials in separate configuration environments. |
| `400 Bad Request: Invalid OTP` | Attempted to use a Production OTP on the /simulation/compliance endpoint. | Generate a dedicated Simulation OTP from the Fatoora Portal under the 'Simulation' tab. |
| `BR-KSA-09: Invalid UUID` | Random string used instead of RFC 4122 Version 4 UUID. | Generate strict UUIDv4 tokens (e.g., using crypto.randomUUID() in Node.js or uuid4() in Python). |
| `Invalid QR Code Base64` | QR code string has formatting breaks or missing TLV tags. | Validate TLV binary byte structure using the Java SDK QR parser tool before sending. |
Frequently Asked Questions (FAQ)
Do invoices issued in the ZATCA Simulation Sandbox create legal tax liabilities?
No. The Simulation Sandbox is an isolated staging environment. Invoices cleared or reported in simulation have zero legal standing, do not appear on your company's official tax balance sheet, and do not impact quarterly VAT returns.
Can I test with dummy company VAT numbers in the Simulation Sandbox?
On the Simulation Gateway (/e-invoicing/simulation), you must onboard using your real commercial Tax Registration Number (TRN) and a portal OTP. If you need to test with dummy data without an active Saudi VAT number, use the Developer Portal Sandbox (/e-invoicing/developer-portal).
How long does a Simulation CSID certificate remain valid?
Simulation CSIDs remain active as long as the test environment is maintained, but ZATCA periodically purges staging ledgers during major Schematron version upgrades. If a Simulation CSID stops working, generate a fresh OTP and re-onboard in 5 minutes.
Does the Simulation Sandbox support both Standard B2B and Simplified B2C testing?
Yes. The Simulation Sandbox provides full functionality for both real-time B2B clearances (/simulation/invoices/clearance/single) and asynchronous B2C reporting (/simulation/invoices/reporting/single).
Can third-party ERP vendors provide pre-tested sandbox environments?
Yes. Many ZATCA-accredited solution providers maintain permanent sandbox simulation instances where businesses can test invoicing workflows without configuring OpenSSL keypairs or Fatoora portal credentials manually.
Was this compliance guide helpful?
Your feedback helps our legal editorial team maintain authoritative KSA guidance.
Advocate High Court (Punjab Bar Council) and ATT GCC VAT Certified Specialist. Author of comprehensive regulatory commentaries on Saudi corporate law, ZATCA e-invoicing protocols, and Labor Reform Initiatives.