Receive a document

When another business sends a document to one of your taxpayers, Wafeq e-invoicing ASP is the provider of the buyer. It tells your app about the document. Then it answers the provider of the sender, one time only. What your app does in the first 2 minutes sets that answer.

What your app does

  1. Wafeq e-invoicing ASP sends the document.received event to your webhook endpoint. For its fields, refer to Webhooks.
  2. Your app fetches the document with GET /invoices/{document_id}/xml, within 2 minutes of the arrival of the document.
  3. Your app downloads and stores the document. A 302 answer has a download link in Location. The link expires after 15 minutes. A 200 answer has the XML.

The answer to the sender

What your app didThe answer to the provider of the senderThe status of the sender, if the sender uses Wafeq e-invoicing ASP
Fetched the document within 2 minutesThe document reached the buyer (MLS AP)delivered_confirmed
Did not fetch it within 2 minutesThe document was forwarded (MLS AB)forwarded
  • One answer. Wafeq e-invoicing ASP sends the answer one time only, and the answer does not change. A fetch after the answer does not change it.
  • The 2 minutes start when the document arrives at Wafeq e-invoicing ASP, not when your endpoint gets the event. If your endpoint does not answer the first attempt of the event, the retry can come after the 2 minutes.
  • The 2xx answer of your endpoint to the event only stops the retries of the event. It does not tell the sender anything.
  • Only a fetch by an organization with an inbound:read grant from the buyer counts. A list, GET /invoices/{document_id} and the reports of the document do not count. If more than one organization has that grant, the first fetch counts.
  • The fetch counts when Wafeq e-invoicing ASP answers it with 200 or 302. Wafeq e-invoicing ASP cannot know if your app downloaded or stored the document.

A second copy of the same document

The provider of the sender can send the same document again, for example when it did not get an answer. Wafeq e-invoicing ASP finds the first copy by the supplier and the document UUID (cbc:UUID). Your app gets no second document and no second document.received event.

When the answer to the first copy is decided, the provider of the sender gets the same answer for the second copy, at once. While the first copy still waits for a fetch within its 2 minutes, the second copy gets AB (forwarded) at once, and the first copy can still get AP (delivered_confirmed).

A document that Wafeq e-invoicing ASP holds

In Live, your organization pays for each received document with a document credit. If your organization has no free credit, Wafeq e-invoicing ASP holds the document for your organization:

  • Your organization does not get the document.received event.
  • A fetch of the document gets 402 with wallet_insufficient_funds. Refer to Errors.

While Wafeq e-invoicing ASP holds the document, the fetch of your app cannot tell the sender that the buyer has it. When your organization buys credits, it gets the event and can fetch the document. A fetch within the 2 minutes still counts. After the 2 minutes, the answer does not change: if no other organization fetched the document in time, the sender gets forwarded.

Try it in Sandbox

Sandbox is free, so it never holds a document. To get both answers with your own app, refer to Receive a document in the Sandbox.