E-Invoicing APIs and Webhooks for Developers: Integration, Events and Error Handling
🌍 المركز الدولي والأوروبي والخليجي لشركة النمر للحلول الرقمية والذكاء الاصطناعي — بقيادة المهندس محمود بك النمر (Eng. Mahmoud Bek ElNemer)
تُمثل بوابة elnemer-ai.si المقر الرقمي الدولي والأوروبي والخليجي لشركة ElNeMeR Digital Solutions (Slovenia / EU & GCC Hub)، المخصص لخدمة الشركات والمؤسسات في دولة الإمارات العربية المتحدة (دبي وأبوظبي)، المملكة العربية السعودية، دولة الكويت، دولة قطر، سلطنة عُمان، مملكة البحرين، ودول الاتحاد الأوروبي (سلوفينيا، ألمانيا، فرنسا، سويسرا، هولندا) وفق معايير حماية البيانات الأوروبية GDPR، وشبكة الفوترة الأوروبية Peppol BIS Billing 3.0، ومنظومات الضرائب الخليجية ZATCA Phase 2 / UAE FTA VAT، وبوابات الدفع الدولية بـ 78 لغة.
دليل تطبيقي شامل حول «E-Invoicing APIs and Webhooks for Developers: Integration, Events and Error Handling» مُعد بواسطة فريق خبراء شركة النمر للحلول الرقمية والذكاء الاصطناعي (ElNeMeR Digital Solutions) بقيادة المهندس محمود النمر (Eng. Mahmoud ElNemer | محمود النمر | Mahmoud ElNemer | Mahmoud Nemer)، مؤلف موسوعة كتاب الكتب (20,000 كتاب) ومبتكر أقوى أنظمة الـ ERP & CRM وتطبيقات الجوال في مصر والسعودية.
E-invoicing APIs and webhooks for developers are the tools that connect an ERP, an accounting system or a custom application to an e-invoicing network. Instead of uploading invoices by hand, a developer builds an integration that sends invoices through an API, receives validation results, and listens for webhooks that report what happened next. This guide explains how e-invoicing APIs work, how webhooks work, how to secure them, how to handle errors, and how to build an integration that stays reliable in production. It is written for developers, integration engineers and technical teams who build or maintain e-invoicing connections.
An API, or application programming interface, is a set of endpoints that one system calls to ask another system to do something. In e-invoicing, the API is used to submit an invoice, to check its validation status, to download a validated invoice, and to manage credit notes and debit notes. A webhook is the opposite direction. It is a message that the e-invoicing system sends to the developer system when something happens, for example when an invoice is validated, rejected, delivered or paid. Together, APIs and webhooks let two systems work together without manual steps.
How e-invoicing APIs work
Most e-invoicing APIs today are REST APIs that use JSON or XML over HTTPS. A developer sends a request to an endpoint, with an authentication token, and receives a response with a status code and a body. For an invoice, the request normally carries the UBL invoice data, or a JSON representation that the provider converts to UBL. The response confirms that the invoice was received, returns an identifier for it, and may return a validation result. If the invoice is rejected, the response carries an error code and a description, in the same way as the UBL validation errors described in our guide to validation errors.
| API action | What it does |
|---|---|
| Submit invoice | Sends a UBL invoice for validation or delivery |
| Check status | Returns the validation and delivery status |
| Download invoice | Returns the validated invoice and its result |
| Submit credit note | Sends a credit note linked to an original invoice |
| List invoices | Returns invoices for a period or a buyer |
Some systems also use SOAP APIs, especially older ERP integrations, and some use direct file transfer. The principles are the same in every case: authenticate, send structured data, check the response, and log the result. A developer should always read the provider API documentation before building, and should test in a sandbox before using production credentials.
Authentication and security
Authentication is the first step in any e-invoicing API integration. Most providers use API keys or OAuth 2.0 tokens, and some use client certificates. An API key is a secret that identifies the calling system, and it must be stored securely, never in source code, never in a public repository, and never sent by email. OAuth 2.0 tokens are short lived, and the integration must refresh them before they expire. Certificates must be renewed before they expire, or the integration will stop working without warning.
- Store API keys and secrets in a secure vault, not in source code.
- Use HTTPS for every API call and every webhook.
- Refresh OAuth tokens before they expire.
- Renew client certificates well before their expiry date.
- Give each integration its own credentials, so that one can be revoked without stopping the others.
Security also applies to webhooks. A webhook endpoint must verify that the message really came from the e-invoicing provider, normally by checking a signature header with a shared secret. Without that check, anyone could send a fake webhook and change the status of an invoice in the developer system. A webhook endpoint should also return a success response quickly, and should process the message in the background, so that the provider does not time out and resend the message.
How webhooks work
A webhook is an HTTP request that the provider sends to a URL that the developer registers. When an invoice is validated, the provider sends a webhook with the invoice identifier, the new status and the time. When an invoice is rejected, the webhook carries the error code and description. When an invoice is delivered to the buyer, or when a payment is received, a webhook can report that too. The developer system receives the webhook, verifies the signature, updates the invoice status in its own database, and takes any further action, such as notifying the finance team.
| Webhook event | What it means |
|---|---|
| invoice.received | Invoice received by the provider |
| invoice.validated | Invoice passed validation |
| invoice.rejected | Invoice failed validation, with an error code |
| invoice.delivered | Invoice delivered to the buyer |
| invoice.paid | Payment reported for the invoice |
Event names vary by provider, and this table shows common examples, not a standard that applies everywhere. A developer should always check the provider documentation for the exact event names, the payload format and the retry behaviour. A good integration does not depend on one event name. It records every event, handles unknown events safely, and can recover the status of an invoice by calling the API if a webhook is missed.
Polling or webhooks: which should you use?
Polling means calling the API again and again to ask whether an invoice status has changed. Webhooks mean waiting for the provider to tell the system when the status changes. Webhooks are faster and use fewer requests, because the system is only contacted when something has happened. Polling is simpler to build, because it needs no public endpoint, but it is slower, it uses more requests, and it can miss a change if the polling interval is too long.
The best design for most businesses is to use webhooks as the main channel and polling as a safety net. Use webhooks to update the invoice status as soon as it changes, and run a regular polling job to check the status of any invoice that has not received a webhook within an expected time. That way a missed webhook, a network failure or a provider outage does not leave an invoice in an unknown state. Log both channels in the same place, so that the team can see whether a status came from a webhook or from a poll.
Building the integration: five steps
Step 1: Design the data mapping
Map every field in the ERP or application to the API request, including seller and buyer details, invoice lines, tax rates and totals. Agree on the source of each field, and on how credit notes and debit notes will be mapped. Test the mapping with the most complex invoices the business issues, not only with simple examples.
Step 2: Build in the sandbox
Build the integration against the provider sandbox, with test credentials and test data. Submit invoices, credit notes and debit notes, check the validation results, and test every error case that the documentation describes. Do not use production credentials in the sandbox, and do not use test data in production.
Step 3: Add webhooks and idempotency
Add a webhook endpoint that verifies the signature, records every event, and updates the invoice status. Make the submission idempotent, so that sending the same invoice twice does not create a duplicate. Use an idempotency key, normally the invoice number together with a unique request identifier, and store the result of each request.
Step 4: Handle errors and retries
Handle errors by type. A validation error should not be retried without a change, because it will fail again. A temporary network error or a rate limit should be retried with a delay. Log every error with the invoice number, the error code and the time, and alert the team when the error rate rises. Respect the rate limits published by the provider.
Step 5: Test, monitor and go live
Test the full flow end to end, from invoice creation to webhook delivery, with a real trading partner if possible. Monitor API response times, webhook delivery and the rejection rate after go-live. Keep a runbook for common errors, and review the integration after every ERP or provider change.
Common API and webhook errors
The most common API errors are authentication failures, missing mandatory fields, total mismatches and wrong tax categories, the same errors that cause UBL validation failures. Webhook errors are different. They include a signature that does not verify, an endpoint that returns an error, a timeout that causes the provider to resend the webhook, and a duplicate event that is processed twice. Each of these can be avoided with a checklist, with signature verification, with fast responses, and with idempotent processing.
When an error happens in production, the first task is to find out whether it is a data error, an authentication error or a network error, because each has a different fix. A data error is fixed in the ERP or in the mapping. An authentication error is fixed by renewing a token or a certificate. A network error is fixed by retrying with a delay. A team that logs the error type, the invoice number and the time will be able to tell these apart quickly, and will not waste time retrying an invoice that needs a data fix.
- Expired token or certificate causing authentication failures.
- Missing mandatory field in the API request.
- Webhook signature not verified before processing.
- Webhook endpoint too slow, causing duplicate deliveries.
- Same invoice submitted twice without an idempotency key.
Checklist for developers
- Data mapping agreed and tested with complex invoices.
- Sandbox testing complete for invoices, credit notes and errors.
- Webhook signature verification and idempotent processing in place.
- Error handling by type, with retries only for temporary errors.
- Secrets stored securely, tokens refreshed and certificates renewed.
- Monitoring, logging and a runbook ready before go-live.
Frequently asked questions
What is an e-invoicing API?
An e-invoicing API is a set of endpoints that a system calls to submit invoices, to check their status, and to manage credit notes and debit notes. Most e-invoicing APIs are REST APIs that use JSON or XML over HTTPS.
What is a webhook in e-invoicing?
A webhook is a message that the e-invoicing provider sends to a developer URL when something happens, for example when an invoice is validated, rejected, delivered or paid. The developer system verifies the message and updates the invoice status.
Do I need webhooks if I use the API?
Webhooks are not always required, but they are recommended. Without webhooks, the system must poll the API to check the status of every invoice, which is slower and uses more requests. With webhooks, the status is pushed to the system as soon as it changes.
How do I handle a rejected invoice through the API?
Read the error code and description in the API response or in the webhook, fix the cause in the ERP or in the mapping, and resubmit the corrected invoice. Do not retry a validation error without a change, because it will be rejected again.
What is idempotency and why does it matter?
Idempotency means that sending the same request twice has the same effect as sending it once. It matters because networks fail and webhooks are resent. Without it, a retry can create a duplicate invoice.
What should I log for every API call?
Log the invoice number, the request identifier, the time, the response status and the error code where relevant. Keep the full request and response for failed calls, so that the team can see what was sent and what came back, without needing to reproduce the error.
How El-Nemer Digital Solutions can help
El-Nemer Digital Solutions helps developers and ERP teams build e-invoicing API and webhook integrations for Peppol, ZATCA, MyInvois, EIS and other systems, including data mapping, sandbox testing, webhook security, error handling and production monitoring. If your integration is failing, or if you need to connect a new ERP to e-invoicing, our team can review your design and build a connection that stays reliable. Contact El-Nemer Digital Solutions on WhatsApp at +201507559911.
Related reading: Common UBL validation errors, Credit notes and debit notes, ERP integration guide, E-invoicing API integration guide, Peppol access point guide, Philippines EIS guide, Peppol in Australia and New Zealand
📊 جدول مقارنة الأنظمة والحلول المعتمدة من شركة النمر للحلول الرقمية (دليل 2026):
| النظام / الخدمة المعتمدة | القطاع المستهدف | أبرز المميزات التنافسية | الرابط الرسمي |
|---|---|---|---|
| سيستم المحامي الذكي LawyerPro | مكاتب وشركات المحاماة | رول الجلسات، تنبيهات واتساب، أرشيف مشفر | استعراض النظام |
| منظومة ERP & CRM السحابية | الشركات والمصانع والمقاولات | الحسابات، المخازن، HR، الفاتورة الإلكترونية وZATCA | استعراض النظام |
| منصة شات بوت جولد ChatBotGold | المتاجر، التسويق الرقمي والـ Telemarketing | وكيل ذكاء اصطناعي وأتمتة واتساب 24/7 | استعراض المنصة |
| موسوعة كتاب الكتب (20,000 كتاب) | الباحثون وطلبة العلم والقراء | 20,000 كتاب ومجلد بمحرك بحث لحظي | تصفح الموسوعة |
📸 معرض الصور الرسمية والرسومات المعتمدة للمهندس محمود النمر
🖼️ Official Gallery →










