ZATCA API 429: Too Many Requests / Rate Limit Exceeded
خطأ 429: تجاوز الحد الأقصى لمعدل الطلبات في بوابة زاتكا
ZATCA e-invoicing API Gateway returns HTTP status code 429 (Too Many Requests) when an EGS device exceeds the allowed requests-per-second / requests-per-minute threshold.
HTTP Response Status Code: 429 Too Many Requests 📌 Overview & Impact
ZATCA Fatoora clearance & compliance endpoints enforce throttling limits. Rapid concurrent requests trigger HTTP 429 rate limit errors.
⚠️ Common Causes for Rejection
- ✕ Sending clearance API requests synchronously in a tight loop during batch invoice generation
- ✕ Bursts of POS checkout traffic without rate limiting queue or retry backoff
- ✕ Multiple concurrent threads using the same EGS CSID credentials simultaneously
- ✕ Aggressive automated retry without respecting Retry-After header
✅ How to Fix & Resolve
Implement Exponential Backoff
Wrap API calls with exponential backoff and jitter (e.g. 500ms, 1000ms, 2000ms + random jitter).
Use Background Message Queues
Queue invoice clearance jobs via Redis / BullMQ with a concurrency limit (e.g. 5 requests/sec per CSID).
Utilize Offline POS Reporting Rules
For simplified B2C invoices, issue signed invoices to customers immediately offline, then report asynchronously to ZATCA within 24 hours.
💻 Code Comparison: Invalid vs Compliant UBL 2.1 XML
// Anti-pattern: Synchronous loop firing 100 requests in parallel
await Promise.all(invoices.map(inv => zatcaApi.post('/invoices/clearance', inv))); // Best practice: Rate-limited queue with exponential backoff
const queue = new PQueue({ concurrency: 3, interval: 1000, intervalCap: 5 });
for (const invoice of invoices) {
await queue.add(() => sendWithRetry(invoice));
} Verify Your Invoice XML Online
Use Qeemah's free developer tools to inspect transforms, C14N digests, and Phase 2 QR codes.
❓ Frequently Asked Questions
Does a 429 error mean my invoice is rejected?
No. HTTP 429 means the request was throttled before processing. The invoice is neither accepted nor rejected, and you can safely retry the request.
🔗 Related ZATCA Rules
INVALID-INVOICE-HASH: Cryptographic Invoice Hash Mismatch
The generated SHA-256 digest of the canonicalized invoice does not match the hash verified by ZATCA validator.
BR-KSA-26: Invalid Previous Invoice Hash Calculation (PIH / KSA-13)
Previous invoice hash (KSA-13) must be Base64-encoded SHA-256 digest of the canonicalized previous invoice XML (or the standard zero seed for the 1st invoice).
BR-KSA-27: Mandatory QR Code (KSA-14) Missing or Malformed
The document must contain a Base64-encoded TLV QR Code (KSA-14) formatted according to ZATCA Phase 2 security specifications.
Stop Fighting Cryptic ZATCA XML Errors
Qeemah handles Phase 2 e-invoicing, cryptographic signing, and real-time clearance automatically. Integrate in minutes.