# Tutorial: Send Invoices

This page describes the steps necessary for sending invoices via Peppol using the SalesInvoice endpoint.

Send Document Diagram

# Step1: Query recipient party

Get the advised receiver partyId using the the SalesInvoice/queryRecipientParty.

In this example, lets use '0106:12345678' as the receiver, and your own partyId as the sender. If you don't know your own partyId, use the me/party call. For the sake of this example, we will use '0106:12345678' as both sender and receiver.

queryRecipientIdParameters

In return we get our endpointId:

{
 "id": "NL:KVK:12345678"
}

Read more about the queryRecipientParty

# Step 2: Send the invoice

Now we need to send the document to the receiver's endpointId. Reference on how the document should be structured can be found here (opens new window). Use the SalesInvoice/Send call to send the document. Please take note of the returned reference Id, since we are going to use that later on.

SendParameters

result:

{
  "id": "5618b40a-822d-4e74-8894-b489617dbaa4"
}

# Step 3: Verify that the document has been sent successfully

# Using Webhooks

Make sure you are subscribed to the relevant webhook. In this example, we are going to use a mailhook.

WebhookParameters

Example hook body:

{
  "id": "1",
  "name": "mail hook",
  "action": "mailto:example@econnect.eu",
  "topics": [
    "InvoiceReceived",
    "InvoiceReceivedError",
    "InvoiceSent",
    "InvoiceSentError",
    "InvoiceSentRetry",
    "HookSent",
    "HookSentError",
    "HookSentRetry"
  ],
  "isActive": true,
  "createdOn": "0001-01-01T00:00:00+00:00",
  "changedOn": null
}

When sending the document has succeeded, you will receive an email/webhook that looks something like the message below. You can verify that the document has been successfully send by comparing the documentId with the reference Id we saw earlier.

{
  "topic": "InvoiceSent",
  "partyId": "NL:KVK:12345678",
  "hookId": "2",
  "documentId": "5618b40a-822d-4e74-8894-b489617dbaa4",
  "details": {
    "id": "APAAS SwaggerTest",
    "sourceDocumentTypeId": "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:www.cenbii.eu:transaction:biitrns010:ver2.0:extended:urn:www.peppol.eu:bis:peppol4a:ver2.0:extended:urn:www.simplerinvoicing.org:si:si-ubl:ver1.2::2.1",
    "targetDocumentTypeId": "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:www.cenbii.eu:transaction:biitrns010:ver2.0:extended:urn:www.peppol.eu:bis:peppol4a:ver2.0:extended:urn:www.simplerinvoicing.org:si:si-ubl:ver1.2::2.1",
    "endpoint": "https://accp-ap.econnect.eu/as4/v1",
    "recipient": "NL:KVK:12345678",
    "attempt": "1",
    "protocol": "As4",
    "messageId": "3e3b336c-6563-431c-93bc-6b109dedfcc5@econnect.eu",
    "refToMessageId": null,
    "conversationId": null,
    "returnedMessageId": "640edc84-235a-4d74-a9ed-761bb2685316@econnect.eu"
  },
  "createdOn": "2020-06-22T09:31:57.7444125+00:00",
  "sentOn": "2020-06-22T09:31:57.8703556+00:00"
}

For more information regarding webhooks, please look at the hooks page.

# Using API calls

Call SalesInvoice/status in order to see if the document has been sent successfully. This is not the preferred method, please use the webhooks method as much as possible.

statusParameters

Example response:

[
  {
    "id": "46f68e6f-b05f-4531-8ec7-fc23a23f5cee",
    "name": "Initializing",
    "description": "Request received.",
    "createdOn": "2020-06-15T09:18:50.9699485+00:00"
  },
  {
    "id": "5e98e800-6d80-4640-a857-bb5715a8cfcc",
    "name": "DeterminingRoute",
    "description": "Successfully determined destination for party '0106:12345678' and document 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:www.cenbii.eu:transaction:biitrns010:ver2.0:extended:urn:www.peppol.eu:bis:peppol4a:ver2.0:extended:urn:www.simplerinvoicing.org:si:si-ubl:ver1.2::2.1'.",
    "createdOn": "2020-06-15T09:18:51.2563944+00:00"
  },
  {
    "id": "d04a4648-3995-4bbc-bed6-ead3a98a5870",
    "name": "Executing",
    "description": "'Invoice' successfully sent: '0d0167cb-72f1-4656-801b-17ff3a6ddb59@econnect.eu'.",
    "createdOn": "2020-06-15T09:18:51.7877889+00:00"
  },
  {
    "id": "b21f56c4-8ba8-4479-8b02-49eb6e6ae451",
    "name": "Finished",
    "description": "Process finished.",
    "createdOn": "2020-06-15T09:18:51.7914789+00:00"
  }
]
© 2021 eConnect International B.V.