ZATCA-API-429 ⚡ API Clearance & Rate Limits error

ZATCA API 429: Too Many Requests / Rate Limit Exceeded

خطأ 429: تجاوز الحد الأقصى لمعدل الطلبات في بوابة زاتكا

Official ZATCA Specification:

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.

XPath Context: 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.

الوصف بالعربية: تفرض منصة فاتورة حداً أقصى لمعدل إرسال الفواتير في الثانية، ويؤدي إرسال طلبات متزامنة بكثافة إلى إرجاع خطأ HTTP 429.

⚠️ 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

1

Implement Exponential Backoff

Wrap API calls with exponential backoff and jitter (e.g. 500ms, 1000ms, 2000ms + random jitter).

2

Use Background Message Queues

Queue invoice clearance jobs via Redis / BullMQ with a concurrency limit (e.g. 5 requests/sec per CSID).

3

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

❌ Invalid XML (Rejected by ZATCA) Invalid Payload
// Anti-pattern: Synchronous loop firing 100 requests in parallel
await Promise.all(invoices.map(inv => zatcaApi.post('/invoices/clearance', inv)));
✓ Valid XML (Compliant UBL 2.1) Valid Payload
// 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.

Stop Fighting Cryptic ZATCA XML Errors

Qeemah handles Phase 2 e-invoicing, cryptographic signing, and real-time clearance automatically. Integrate in minutes.