Webhooks

This page uses these terms:

  • Your organization: the account of your company in the Wafeq e-invoicing ASP portal. Your webhook endpoints belong to your organization.
  • Mode: Live or Sandbox. Each mode has its own webhook endpoints, signing secrets and events.
  • Grant: the permission that a business gives to your organization. A grant has an ID (tgr_…) and scopes. The scopes are the permissions that the business approved.
  • Taxpayer: a business from which your organization has an active grant. Its ID is the Taxpayer ID (txpay_…).
  • Document: an invoice or a credit note. Its ID is the document ID (inv_…).
  • Delivery: the transfer of a document to the buyer's e-invoicing provider, on Peppol.
  • Report: the copy of a document that Wafeq e-invoicing ASP sends to the FTA, the UAE Federal Tax Authority. One document can have more than one report.
  • Webhook endpoint: a URL on your server. Wafeq e-invoicing ASP sends events to this URL.
  • Event: a message that Wafeq e-invoicing ASP sends to your webhook endpoint when something changes.
  • Signing secret: the secret of one webhook endpoint. Your server uses it to check that an event comes from Wafeq e-invoicing ASP.

Use this page when you build the webhook receiver of your app. To add a webhook endpoint, refer to Set up your organization. To use the document events, refer to Track a document.

Example: one invoice, three events. Your app submits an invoice to a buyer on Peppol. Wafeq e-invoicing ASP delivers it to the buyer's provider and sends document.sent. Some minutes later, the buyer's provider answers that it forwarded the invoice to the buyer. Wafeq e-invoicing ASP sends document.status. Later, the FTA accepts the report. Wafeq e-invoicing ASP sends document.reported. Each event gives your app a result that it cannot get at the time of the submission.

The events

Wafeq e-invoicing ASP sends eight events. You select the events for each webhook endpoint.

EventWafeq e-invoicing ASP sends it when
taxpayer.createdYour organization gets its first active grant from a business.
taxpayer.updatedThe details or the status of a taxpayer change, or your grants from it change.
taxpayer.deletedYour organization loses its last active grant from a taxpayer.
document.sentThe delivery of a document to the buyer's provider ends.
document.statusThe delivery of a document changes after that.
document.reportedThe FTA answers a report.
document.receivedA document from another business arrives for a taxpayer.
batch.completedEach document of a batch that your organization sent has its answer.

Taxpayer events

Why they matter. These events tell your app which businesses it can submit documents for. They also tell your app when the registered details of a taxpayer change. Wafeq e-invoicing ASP takes the seller details of each document from these registered details.

  • taxpayer.created comes when the business approves your app. It comes also if your callback does not receive the authorization code.
  • taxpayer.updated comes when the taxpayer starts to deregister in EmaraTax, or when its registered details change. It also comes when your grants from it change.
  • taxpayer.deleted comes when the business revokes your last grant, when your app revokes it, or when the deregistration of the taxpayer completes. After this event, your app cannot call the API for this taxpayer.

The data of the three events contains these fields:

FieldValue
taxpayer_idThe Taxpayer ID (txpay_…).
tinThe TIN of the taxpayer.
participant_idThe Peppol ID of the taxpayer: 0235: followed by the TIN.
nameThe name of the taxpayer.
statusThe status of the taxpayer, for example onboarded, deregistration_pending or disconnected.
grantsYour active grants from the taxpayer: grant_id, label, scopes and metadata of each grant.
profileThe registered details: legal_name, trade_name, vat_number, legal_registration and address.
deletedtrue. Only taxpayer.deleted has this field.
  • taxpayer.updated also has previous_attributes, next to data. It contains only the fields that changed, with their old values.
  • taxpayer.deleted contains the last data before the change.
  • After each taxpayer event, read GET /grants to get the current state. Events can arrive late. Do not restore a connection because of a late taxpayer.created event.

document.sent

Why it matters. This event tells your app how the handover of the document to the access point of the buyer's provider ended. The answer of the buyer's provider comes later, in document.status: a forward to the buyer, a confirmed delivery, or a rejection. No event tells you that the buyer approved the invoice.

FieldValue
document_idThe document ID (inv_…).
source_idThe value that your app sent in source_id.
invoice_numberThe number of the document.
invoice_type_codeThe document type.
statusHow the handover ended. delivered: the access point of the buyer's provider gave a receipt. delivery_status is then received_by_ap, or the answer of the provider if it came first. In Sandbox, a delivery to a test buyer has delivery_status: sent until the simulated provider answers, and a delivery to an active Sandbox taxpayer has sent for up to 2 minutes, then delivered_confirmed or forwarded, as the app of the buyer's organization fetches the document or not. Refer to Receive a document in the Sandbox. failed and attention_required: the same values as delivery_status. Refer to Delivery errors.
recipient_idThe address of the delivery: the Peppol ID of the buyer, or an FTA placeholder address.
seller_id, buyer_idThe Peppol IDs of the seller and the buyer.
currency, totalThe currency and the amount due of the document.

document.status

Why it matters. The buyer's provider can reject a document after the delivery. A rejection, or a missed deadline, can make it necessary to submit a correction. This event also shows the progress of a queued delivery.

FieldValue
document_idThe document ID. Old events can have no document_id. Refer to the note below the table.
source_idThe value that your app sent in source_id.
invoice_numberThe number of the document.
delivery_statusThe new status of the delivery. For the values, refer to Track a document.
response_codeThe answer of the buyer's provider (MLS). AB: the provider forwarded the document to the buyer, and it has no way to verify that the document arrived. AP: the provider has a verifiable confirmation that the document arrived on the side of the buyer. RE: the provider did not deliver the document. AB and AP are both a successful delivery, and neither tells you that the buyer approved the invoice. The provider answers one time only. Other events have null.
reason_codeThe reason for the change. In a delivery receipt, it is the main reason of the provider, for example BV, SV or FD. When the provider gives FD with other reasons, it is FD.
reason_codesOnly in a delivery receipt: every reason code that the provider gave, in upper case. An empty list when the provider gave none.
detailOnly in a delivery receipt: the text of the provider, at most 4,000 characters. null when the provider sent no text.
reporting_recoveryIn a delivery receipt, in a deadline event and in the event of a corrected document that replaces this document: how Wafeq e-invoicing ASP handles the report of the document after a rejection or a missed deadline. Its trigger tells why, and it does not change. null when there is nothing to handle. Refer to the list below the table.
message_idThe ID of the message that carried the document. The response of the submission gives the same value.
delivery_job_idThe ID of a queued delivery.
replacement_document_idThe document ID of a corrected document that replaces this document.
  • Old delivery receipts, sent before document_id was added, have no document_id. For them, use source_id to find the document. If your app sent no source_id, use message_id.
  • Wafeq e-invoicing ASP also sends document.status when it accepts a queued document, and when the queued delivery changes.

The values of reporting_recovery.trigger:

  • c3_validation_rejected: the buyer's provider rejected the document with BV or SV.
  • c3_delivery_rejected: the buyer's provider rejected the document with FD. It could not deliver the document.
  • c3_rejection_unclassified: the buyer's provider rejected the document, and the reason is not clear: no reason, BW only, an unknown reason, or FD together with BV or SV.
  • c3_transport_overdue: the access point of the buyer's provider gave no receipt for a queued delivery in time. Refer to The attempts of a queued delivery.
  • c3_mls_overdue: the buyer's provider did not answer a queued delivery within 10 minutes. Wafeq e-invoicing ASP does not use this trigger at this time. When the provider does not answer, Wafeq e-invoicing ASP keeps the report, and a document.status event comes with c3_deadlines.state: attention_required and reason_code: c3_mls_overdue.

document.reported

Why it matters. Wafeq e-invoicing ASP reports each document to the FTA. This event gives the answer of the FTA. Show this status to your users. It tells them if the FTA accepted the report of the document.

FieldValue
document_idThe document ID.
source_idThe value that your app sent in source_id.
tax_authority_statusREPORTED (the FTA accepted the report), NOT_COMPLIANT (the FTA rejected the report) or WITHDRAWN.
submission_idThe ID of the report (tdd_…).
document_type_codeThe type of report: S, R or W. Refer to the list below the table.
supersedes_idFor an R report: the submission_id of the report that it replaces.
fta_statusThe answer of the FTA: accepted or rejected.
reason_code, detailThe reason that the FTA gives, if it gives one.
reporting_recoveryThe same object as in document.status, for the document of the report, as it is when the FTA answers. Its trigger tells why Wafeq e-invoicing ASP withdrew the report. null when the document has none.

The types of report:

  • S: the first report of the document.
  • R: a corrected report, after the FTA rejected a report. Wafeq e-invoicing ASP does not deliver the document again.
  • W: the withdrawal of a report. Wafeq e-invoicing ASP withdraws a report when the buyer's provider rejects the document, or when a queued delivery misses its deadline. The event then has tax_authority_status: WITHDRAWN, and reporting_recovery.trigger tells which. In this event, reporting_recovery.state can still be withdrawal_queued. The state becomes withdrawn shortly after, in GET /invoices/{document_id}.

After a withdrawal, for any reporting_recovery.trigger, your app can submit a correction with the same number: corrected content after BV or SV, the same content after any other cause. The correction is a new document with its own document_id, and the same source_id is allowed. Refer to Correct or cancel a document.

A document can have more than one report. Keep each event with the report that its submission_id identifies. GET /invoices/{document_id}/reports gives all the reports of a document. Old events can have no submission_id, document_type_code or supersedes_id.

document.received

Why it matters. This event tells your app that another business sent a document to a taxpayer, for example the invoice of a supplier. Your app can then get the document and show it to the user.

FieldValue
document_idThe document ID of the received document.
invoice_numberThe number of the document.
invoice_type_codeThe document type.
seller_id, buyer_idThe Peppol IDs of the seller and the buyer.
currency, totalThe currency and the amount due of the document.
statusreceived.

To get the document, send GET /invoices/{document_id}/xml.

The access point of the sender can send the same document again, for example when it did not get an answer. Wafeq e-invoicing ASP keeps one copy and sends document.received once when the same taxpayer receives the same supplier's document UUID (cbc:UUID). A new transport message ID does not create another document; a different document UUID does, even when its number and amounts match.

Fetch the document within 2 minutes. Wafeq e-invoicing ASP answers the sender's provider one time only. When your app fetches the document with GET /invoices/{document_id}/xml within 2 minutes of its reception, the answer is that the document reached the buyer (MLS AP): the sender gets delivered_confirmed. Without that fetch, the answer is that the document was forwarded (MLS AB): the sender gets forwarded, for good. A later fetch does not change the answer.

The 2xx answer of your endpoint to the event only stops the retries of the event. It does not tell the sender anything. For what counts as the fetch, a second copy of a document, and a held document, refer to Receive a document.

batch.completed

Why it matters. This event tells your app that a batch that it sent is complete: each document of the batch has its answer. Your app can then read the answers. Refer to Send many documents at once.

FieldValue
batch_idThe batch ID (bat_…).
statuscompleted.
document_countThe number of documents in the batch.
countsThe number of documents that are accepted, failed and unconfirmed. pending is 0.
created_at, completed_atWhen Wafeq e-invoicing ASP accepted the batch, and when the last document got its answer.
taxpayer_idThe Taxpayer ID (txpay_…).
grant_idsYour active grants from the taxpayer with invoices:write or invoices:read.

To get the answer of each document, send GET /batches/{batch_id}/items. Each accepted document of the batch also has its own document events.

Which events your organization receives

These rules decide which events Wafeq e-invoicing ASP sends to your organization:

  • Taxpayer events go to each organization that has an active grant from the taxpayer.
  • Document events go to your organization only if one of your active grants from the taxpayer has the invoices:read scope. Without this scope, your organization gets no document events, also for the documents that your app submits.
  • Received documents also need the inbound:read scope. This applies to document.received, and to the other events about a received document.
  • Documents of other apps. A taxpayer can approve more than one app. With invoices:read, your organization receives the events of all the documents of the taxpayer. data.issued_by identifies the organization that submitted the document.
  • Revoked grants. When your last grant from a taxpayer stops, document events stop immediately. This includes events that Wafeq e-invoicing ASP did not send yet.
  • Batch events go only to the organization that sent the batch, while it has an active grant from the taxpayer with invoices:write or invoices:read. Other organizations with a grant from the same taxpayer do not get them.
  • No past events. A new grant or a new webhook endpoint does not get the events of the past. To get earlier documents, use GET /invoices and the other list endpoints.

In Live, your organization can pay for received documents with document credits. A document credit is a prepaid unit of your organization. If your organization has no free credit, Wafeq e-invoicing ASP holds the document.received event. Wafeq e-invoicing ASP sends it when your organization gets more credits. While Wafeq e-invoicing ASP holds the document, your app cannot fetch it. If the hold lasts more than 2 minutes, the sender gets forwarded, unless another organization fetches the document in time. Refer to Receive a document.

The format of an event

Wafeq e-invoicing ASP sends each event as a POST request with a JSON body. The body has these fields:

FieldValue
idThe ID of the event (evt_…). It is the same value as the webhook-id header.
typeThe name of the event, for example document.reported.
versionThe version of the format: "1".
created_atThe time when Wafeq e-invoicing ASP created the event.
participant_idThe Peppol ID of the taxpayer. In a test event, it is null.
environmentThe mode: live or sandbox.
testtrue for a test event, for example an event that you send from the portal. Otherwise false.
dataThe data of the event.

In each document event, data also contains these fields:

  • taxpayer_id: the Taxpayer ID.
  • grant_ids: the IDs of your grants that give your organization this event.
  • issued_by: the ID of the organization that submitted the document. A received document does not have this field.

Example of a document.reported event. The example shows only some of the fields in data:

{
  "id": "evt_6f1c2b7d0e9a4c3b8f5d2a1e0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b",
  "type": "document.reported",
  "version": "1",
  "created_at": "2026-10-15T09:12:44.512031+00:00",
  "participant_id": "0235:1999200000",
  "environment": "live",
  "test": false,
  "data": {
    "document_id": "inv_0123456789ABCDEFGHIJ",
    "source_id": "erp-invoice-8812",
    "tax_authority_status": "REPORTED",
    "fta_status": "accepted",
    "submission_id": "tdd_A1b2C3d4E5f6G7h8J9k0",
    "document_type_code": "S",
    "supersedes_id": null,
    "taxpayer_id": "txpay_K1m2N3p4Q5r6S7t8U9v0",
    "grant_ids": ["tgr_W1x2Y3z4A5b6C7d8E9f0"]
  }
}

Process an event: the four steps

Wafeq e-invoicing ASP sends each event at least one time. Thus your server can receive the same event more than one time. Events can also arrive in a different order than the changes.

StepAction
1Check the signature over the raw body.
2Find duplicates with the webhook-id header.
3Store the event, then answer with a 2xx status.
4Put the events in order with created_at.

Step 1: Check the signature over the raw body

Each request has three headers, in the Standard Webhooks format:

  • webhook-id: the ID of the event.
  • webhook-timestamp: the time of the delivery attempt.
  • webhook-signature: the signature of the ID, the timestamp and the body.

Check the signature with a Standard Webhooks library and the signing secret of the endpoint. Use the raw bytes of the body. Do not parse the JSON and serialize it again before the check, because this changes the bytes.

from standardwebhooks.webhooks import Webhook

event = Webhook(signing_secret).verify(raw_body, request_headers)

The library also checks the timestamp. Keep this check, because it stops old requests that someone sends again. If the check fails, do not process the request.

Step 2: Find duplicates with the webhook-id header

Read the webhook-id header. If your app already stored this ID, answer with a 2xx status and do nothing more.

Step 3: Store the event, then answer with a 2xx status

Store the event in your database. Then answer with a 2xx status. Process the event after you answer.

If your server does not answer with a 2xx status, Wafeq e-invoicing ASP sends the event again later. Refer to Retries.

Step 4: Put the events in order with created_at

Use created_at to put the events of one document or one taxpayer in the correct order. Do not let an older event replace the data of a newer event.

Retries

When a delivery attempt fails, Wafeq e-invoicing ASP sends the event again. Each new attempt is a retry.

A failed attempt. An attempt fails when one of these occurs:

  • Your server answers with a status of 400 or higher.
  • Your server does not answer in time.
  • Wafeq e-invoicing ASP cannot connect to your server.

When your server answers with a 2xx status, the delivery is complete. Wafeq e-invoicing ASP sends no more attempts of this event to this endpoint.

The schedule. Wafeq e-invoicing ASP sends a maximum of 10 retries. The time before each retry is two times the time before the previous retry. The times are approximate.

AttemptTime after the previous attemptTime after the first attempt
First––
Retry 130 seconds30 seconds
Retry 21 minute1.5 minutes
Retry 32 minutes3.5 minutes
Retry 44 minutes7.5 minutes
Retry 58 minutes15.5 minutes
Retry 616 minutes31.5 minutes
Retry 732 minutes1 hour 4 minutes
Retry 81 hour 4 minutes2 hours 8 minutes
Retry 92 hours 8 minutes4 hours 16 minutes
Retry 104 hours 16 minutes8 hours 32 minutes

If retry 10 also fails, Wafeq e-invoicing ASP stops the automatic retries of this event to this endpoint. The event is not lost. You can send it again from the portal.

What a retry contains.

  • The body and the webhook-id header are the same as in the first attempt. Thus Step 2 finds a retry of an event that your app already stored.
  • The webhook-timestamp and webhook-signature headers are new in each attempt. Thus the timestamp check of the library passes also for a late retry.
  • A retry can arrive after newer events. Step 4 puts the events in the correct order.

Each endpoint has its own retries. When one endpoint fails, Wafeq e-invoicing ASP continues to send events to your other endpoints. The retries of one endpoint do not delay the other endpoints.

Send an event again from the portal. In the Wafeq e-invoicing ASP portal, go to Developer Console → Events. Open the event, then select Delivery attempts. Select Retry delivery on a failed attempt. You can do this also after the automatic retries stop. The endpoint must be active. You cannot send again an event of a deleted endpoint.

Retries and revoked grants. When your last grant from a taxpayer stops, Wafeq e-invoicing ASP sends no new document events about this taxpayer. Retries of events that Wafeq e-invoicing ASP sent before the grant stopped can still arrive.

After the receiver works

These items are not steps. They tell you how to keep the receiver in good condition.

  • Rotate the signing secret. You can rotate the signing secret of an endpoint in the Wafeq e-invoicing ASP portal. The old secret stays valid for 24 hours. Install the new secret on your server in this period.
  • See the delivery attempts. The Wafeq e-invoicing ASP portal shows each delivery attempt and the answer of your server. You can send a failed event again from the portal. Refer to Retries.
  • Rules for the endpoint URL. The URL must use HTTPS on port 443. Its host name must resolve only to public IP addresses. The URL must not contain a user name, a password or a fragment.
  • Live and Sandbox. Add a webhook endpoint in each mode. Each endpoint has its own signing secret.
  • Test events. To test your receiver, send a test event from Developer → Webhooks in the Wafeq e-invoicing ASP portal. The endpoint must be active. A test event uses one of the events of the endpoint. It contains test: true and changes no document. The one exception is the test bill of the portal (Receive a test bill, on Purchases → Bills, in the Sandbox only): it makes a bill for the taxpayer and sends its document.received event with test: true.

Webhooks in Sandbox

  • Wafeq e-invoicing ASP does not send reports to the FTA. Sandbox accepts each report approximately 5 seconds after Wafeq e-invoicing ASP accepts the document. Then a real document.reported event comes, with test: false and data.simulated: true. A test buyer can give another answer of the FTA. Refer to Test buyers.
  • Wafeq e-invoicing ASP simulates the delivery. The document.status events of a simulated delivery contain simulated: true. A test buyer on Peppol sets the answer of its provider. After a rejection by the provider, a report that the FTA accepted is withdrawn: document.reported comes with tax_authority_status: WITHDRAWN and simulated: true. Refer to Test buyers.
  • When the buyer is a Sandbox taxpayer, the organizations of the buyer receive document.received. Fetch the document within 2 minutes to tell the sender that the buyer has it.
  • To test the other answers of the FTA, select an FTA answer for the test event. The endpoint must have the document.reported event. The test event then contains REPORTED, NOT_COMPLIANT or FAILED. FAILED occurs only in these test events.

For more about Sandbox, refer to Sandbox.


Webhooks