Direct Answer / Quick Summary:

When an enterprise's internet connection fails or the ZATCA gateway encounters downtime, your legal obligations under Saudi Arabia's Phase 2 E-Invoicing Regulations depend entirely on whether you are issuing Simplified (B2C) or Standard (B2B) tax invoices:

Simplified Tax Invoices (B2C / Retail POS): Offline operations are fully permitted. Retail cash registers and e-commerce stores can continue issuing printed or digital receipts to consumers without interruption. The local POS signs the invoice using its local private key, generates the mandatory Phase 2 cryptographic QR code, and queues the XML payload locally. The enterprise has a statutory grace window of 24 hours from the time of internet restoration* to report all queued transactions to ZATCA.

Standard Tax Invoices (B2B / B2G): Offline issuance is strictly restricted. Because B2B transactions legally require real-time pre-clearance, an un-cleared invoice cannot be legally delivered to a corporate buyer. Businesses may issue goods under a Delivery Note (Sanad Tasleem) or Proforma Invoice, but the official tax invoice must be held in a local queue and cleared with ZATCA before* being transmitted to the buyer for 15% input VAT deduction.

Prolonged Outages (>24 Hours): If an infrastructure failure persists beyond 24 hours, the enterprise must formally file an incident ticket through the ZATCA Portal* accompanied by ISP documentation to prevent statutory non-reporting fines.


Under Article 53 of the Executive Regulations for Value Added Tax and the technical provisions of ZATCA Resolution No. 09-08-2021, tax authorities recognize that physical telecommunication infrastructure, undersea fiber lines, and cloud data centers can suffer outages.

However, Saudi tax law strictly distinguishes between unavoidable network failure (*Inqita' Al-Ittisal*) and intentional tax evasion (*Taharrub Dareebi*). To stay compliant during an outage, your software architecture must prove that no invoices were skipped, altered, or retroactively inserted while offline.

Stage 1Automated Failover

Outage Detection

ERP heartbeat detects connectivity loss with gw-fatoora.zatca.gov.sa

Stage 2Local SQLite/Redis Buffer

Local Signing & Chaining

POS signs transactions locally via secp256k1 key; increments ICV and maintains PIH chain

Stage 3Transaction Issued

Customer Receipt Handoff

B2C customer receives printed slip with valid QR code; B2B invoices held in pending queue

Stage 4Rate-Limited Sync

Connection Restoration

Gateway recovers; ERP background worker initiates rate-limited asynchronous sync

Stage 5Compliance Restored

Statutory Ledger Audit

Invoices clear and report to ZATCA; clearance stamps returned; audit log verified


Detailed Rules: B2C Simplified Invoicing During Outages

For retail stores, pharmacies, restaurants, and supermarkets, pausing checkout counters during an internet outage would paralyze commercial life. ZATCA engineered the Reporting Model specifically to accommodate offline environments:

1. How Offline B2C Invoicing Works Mechanically

Because the EGS Private Key resides locally on your server or POS cash register (rather than on ZATCA's cloud servers), your machine can perform 100% of the cryptographic operations offline:

1The POS creates the UBL 2.1 XML document.
2The POS computes the SHA-256 Invoice Hash.
3The POS signs the hash using its local ECDSA private key.
4The POS packs the 9 mandatory TLV tags and generates the Base64 QR code.
5The POS prints the receipt or sends it via SMS to the shopper immediately.

2. The 24-Hour Synchronization Rule

Under statutory regulations, all Simplified Tax Invoices generated offline must be transmitted to ZATCA's reporting endpoint (/invoices/reporting/single) within 24 hours of transaction timestamp.

Mandatory Regulatory Requirement

What If the Outage Lasts Longer Than 24 Hours?

If an internet failure exceeds 24 hours due to a documented fiber cut or telecommunications disaster, the enterprise must report the queued invoices immediately upon connection restoration. The system must preserve raw router/ISP logs proving the outage to defend against automated late-reporting penalties during tax audits.


Detailed Rules: B2B Standard Invoicing During Outages

While retail B2C invoicing can proceed seamlessly offline, business-to-business commerce faces strict legal boundaries due to the Clearance Model:

Operational StageNormal Online ModeOffline Outage Mode
Invoice GenerationERP creates XML payload.ERP creates XML payload and queues in local buffer.
ZATCA VerificationReal-time API call (/invoices/clearance/single).Cannot execute. System marks status as PENDING_CLEARANCE.
Document Delivery to BuyerCleared PDF/A3 with ZATCA Cryptographic Stamp delivered.STRICTLY PROHIBITED. Un-cleared invoice cannot be given to client.
Goods Dispatch ProcedureAccompanied by official cleared tax invoice.Dispatched using Commercial Delivery Note or Goods Receipt Note.
Input VAT Claim by BuyerBuyer immediately books 15% input VAT.Buyer cannot claim input VAT until clearance is received post-restoration.

Statutory Safeguards & Rights Protection

Mandatory protections enforced by MHRSD & Saudi Labor Law

1
No Fictitious Clearance StampsAn ERP must never generate a mock or placeholder ZATCA clearance stamp while offline. Delivering an invoice with a forged clearance mark constitutes criminal tax fraud.
2
Delivery Note ExceptionSellers may dispatch physical merchandise under Article 53 using commercial delivery notes (Bayan Tasleem), provided the formal tax invoice is cleared and delivered within 15 days of supply.
3
Buyer Legal ProtectionA corporate buyer who books input VAT deductions based on an un-cleared offline invoice faces complete deduction disallowance and a 50% penalty on the unpaid tax difference.

Technical Architecture: The Resilient Offline Queue & Sync Pattern

To prevent data loss and broken cryptographic chains during network interruptions, enterprise software must implement the Transactional Outbox Pattern:

Stage 01Local SQLite/Redis

Local Billing & Network Check

POS detects offline state; writes raw transaction into local encrypted Outbox queue

Stage 02Offline Issuance

Offline Signing & QR Issuance

System signs hash locally using secp256k1 key; issues customer receipt with 2D QR code

Stage 03Rate-Limited Sync

Automatic FIFO Resynchronization

Connection recovers; background worker transmits queued batches in strict sequential order

Critical Concurrency Rule: Strict Sequential Sync

When the network recovers, the background synchronization engine must process queued invoices in strict First-In, First-Out (FIFO) sequential order.

Because each invoice embeds the Previous Invoice Hash (PIH) of the preceding document, submitting invoices out of order will break the cryptographic chain, triggering error BR-KSA-51: Invalid Previous Invoice Hash across the entire backlog.

Resilient Sync Script with Exponential Backoff (Node.js Reference)

The following production code illustrates how an enterprise background sync worker queues offline invoices and submits them with exponential backoff and concurrency locking:

typescript|Technical Specification / Reference
Verified Schema
import axios from 'axios';

interface QueuedInvoice {
  id: string;
  icv: number;
  signedXmlBase64: string;
  invoiceHash: string;
  isStandardB2B: boolean;
}

class ZatcaOfflineSyncManager {
  private isSyncing = false;

  async processOfflineQueue(queue: QueuedInvoice[], csidAuthToken: string): Promise<void> {
    if (this.isSyncing) return; // Prevent concurrent sync loops
    this.isSyncing = true;

    try {
      // STRICT REQUIREMENT: Sort sequentially by ICV
      queue.sort((a, b) => a.icv - b.icv);

      for (const invoice of queue) {
        let attempts = 0;
        let success = false;

        while (!success && attempts < 5) {
          try {
            const endpoint = invoice.isStandardB2B
              ? 'https://gw-fatoora.zatca.gov.sa/e-invoicing/core/invoices/clearance/single'
              : 'https://gw-fatoora.zatca.gov.sa/e-invoicing/core/invoices/reporting/single';

            const response = await axios.post(
              endpoint,
              { invoice: invoice.signedXmlBase64, invoiceHash: invoice.invoiceHash },
              {
                headers: {
                  'Authorization': `Basic ${csidAuthToken}`,
                  'Accept-Version': 'V2',
                  'Content-Type': 'application/json',
                },
                timeout: 5000,
              }
            );

            if (response.status === 200) {
              await this.markAsSynced(invoice.id, response.data);
              success = true;
            }
          } catch (error: any) {
            attempts++;
            // Exponential backoff with jitter: 2^attempts * 500ms
            const delayMs = Math.pow(2, attempts) * 500 + Math.random() * 200;
            await new Promise((resolve) => setTimeout(resolve, delayMs));
          }
        }

        if (!success) {
          throw new Error(`Chain halted at ICV ${invoice.icv}: Sync failed after 5 retries.`);
        }
      }
    } finally {
      this.isSyncing = false;
    }
  }

  private async markAsSynced(id: string, zatcaResponse: any): Promise<void> {
    // Database update: Mark invoice as SYNCED with official ZATCA response
  }
}

Real-World Case Study: Dammam Industrial Supply Hub (14-Hour Fiber Cut)

In November 2025, road construction in the Second Industrial City of Dammam severed primary and backup optical fiber cables serving an industrial steel distributor:

The Situation: 14 hours of total internet black-out during active warehouse operations.
The Protocol:

* For retail cash sales (B2C), the POS terminals switched to offline mode, issuing 312 Simplified receipts with full cryptographic QR codes.

For corporate contractors (B2B), the logistics team held B2B tax invoice numbers in an atomic database queue and issued physical goods using Commercial Delivery Notes (Bayan Tasleem Goods)*.

The Recovery: When internet connectivity was restored at 11:30 PM, the automated sync service processed the 312 B2C invoices in sequential order within 4 minutes. The B2B invoices were then cleared in real-time, converted into PDF/A-3 documents, and automatically emailed to corporate buyers with their clearance stamps.
The Audit Result: When ZATCA performed a routine compliance review three months later, zero penalties were assessed because the hash chain remained unbroken and B2C reporting occurred well within the statutory 24-hour window.

Common Offline Sync Pitfalls & Troubleshooting

Error Code / SymptomRoot CauseImmediate Remediation
`HTTP 429 Too Many Requests`The ERP submitted hundreds of queued invoices simultaneously in parallel threads, overwhelming rate limits.Implement a sequential queue with a 50ms delay between API requests to smooth traffic.
`BR-KSA-51: Invalid Previous Hash`A multi-threaded sync worker processed Invoice #104 before Invoice #103, breaking the sequence.Enforce strict sequential FIFO ordering (ORDER BY icv ASC) when ingesting the outbox queue.
`Timestamp Out of Order`The offline POS clock drifted backward or was manually modified during power failure.Lock the operating system clock to a secure Network Time Protocol (NTP) daemon; prevent manual time adjustments.
`Database Lock Timeout`Concurrent checkout cashiers attempted to read and update the shared PIH table simultaneously while offline.Implement independent EGS units per register so each cash drawer maintains its own isolated hash chain.

Frequently Asked Questions (FAQ)

Can a retail store continue selling to walk-in consumers if the internet goes down?

Yes. Retail stores issuing Simplified Tax Invoices (B2C) can continue selling offline without interruption. The local POS system cryptographically signs the invoice, generates the required QR code, and holds the document in a local buffer for reporting within 24 hours.

Can an enterprise issue a Standard B2B invoice offline during an emergency?

No. Standard B2B invoices require real-time clearance from ZATCA before they can be legally issued to corporate buyers. Delivering an un-cleared B2B invoice to a client prevents the client from deducting input VAT and constitutes a direct regulatory violation.

What should an enterprise do if an internet outage lasts for 3 days?

The enterprise must: (1) Maintain all transactions in its sequential offline database; (2) Obtain an official outage incident certificate from its Internet Service Provider (STC, Mobily, Zain); (3) Submit an emergency notification ticket through the ZATCA ERAD Portal; and (4) Transmit all queued records immediately upon connection recovery.

Does offline invoicing reset the Invoice Counter Value (ICV)?

No. The Invoice Counter Value (ICV) must continue incrementing sequentially (N + 1) regardless of whether the system is online or offline. Operating offline must never reset or interrupt the continuous numerical sequence.

How does ZATCA know if an invoice was actually generated during an offline outage?

ZATCA verifies the internal transaction timestamp against the sequential hash chain (PIH) and compares submission times with regional telecommunication logs. If the hash sequence is unbroken and matches prior transactions, the offline generation is validated.