e-copedia hjælpecenter
Booking and sending sales invoices through the e-conomic API
How to book a draft invoice and send it by e-mail or as an EAN e-invoice in the same request, and what to check first.
The e-conomic REST API lets you book a draft invoice and send it in the same request. The invoice can be delivered:
by Email
as an electronic invoice to the customer's EAN number (GLN);
not at all, so the invoice is only booked.
This guide explains how to choose the delivery method, how to prepare the customer and the invoice, and where to find the delivery status.
Obs
💡 Sending sales documents is only possible via the REST API for now.
💡 E-invoices to a CVR number, a P-number or Peppol can't be sent via the API.
Only EAN invoices can. Invoices for those recipients have to be sent from e-conomic itself.
Before Sending an Electronic Invoice
Make sure the following is in place:
Your agreement has its Danish CVR number and country in the master data, and it's a paying agreement. E-invoices can't be sent from a demo agreement.
The customer has a valid EAN number, and their NemHandel receiver type is EAN.
The customer is registered and active as a receiver in NemHandel.
The draft invoice has
recipient.nemHandelTypeset toean(see below).The customer and the invoice have a contact person (attention).
The invoice has at least one product line.
The customer isn't barred and hasn't opted out of receiving electronic invoices.
Booking and Sending an Invoice
A draft invoice is booked with POST /invoices/booked. The minimum request names the draft invoice to book:
{
"draftInvoice": {
"draftInvoiceNumber": {draftInvoiceNumber}
}
}To send the invoice right after it's booked, add sendBy:
{
"draftInvoice": {
"draftInvoiceNumber": {draftInvoiceNumber}
},
"sendBy": "Email"
}The supported values are:
Value | What happens |
| Books the invoice without sending it |
| Books the invoice and sends it by e-mail |
| Books the invoice and sends it as an e-invoice to the customer's EAN number |
If sendBy is left out, the invoice is booked without being sent. The invoice is only sent if the booking succeeds.
Obs
💡 An invoice is sent only once, when it's booked. A booked invoice can't be sent again via the API. If sending fails, find out why first, and then resend it from e-conomic.
Electronic Invoicing: EAN Only
Use "sendBy": "ean" to book the invoice and send it as an e-invoice:
{
"draftInvoice": {
"draftInvoiceNumber": {draftInvoiceNumber}
},
"sendBy": "ean"
}ean sends the invoice through NemHandel to the customer's EAN number (GLN), and only there. It can't send to a CVR number, a P-number or Peppol, whatever the customer or the invoice is set up for. Invoices for those recipients have to be sent from e-conomic itself.
What recipient.nemHandelType Does
The draft invoice has a field recipient.nemHandelType (ean, corporateIdentificationNumber, pNumber or peppol), set when you create the draft with POST /invoices/drafts.
It doesn't decide where the invoice goes. It only decides what e-conomic checks before sending:
| Result with |
| The CVR number isn't checked. The invoice is sent to the EAN number. |
| The CVR number is checked, and then the invoice is sent as an EAN invoice anyway. |
| The check fails. The invoice is neither sent nor booked. |
Set it to ean for e-invoices sent via the API. e-conomic doesn't fill it in from the customer when the draft is created via the API, so your integration has to set it.
Checking the Customer's Setup
e-conomic also checks the invoice against the receiver type on the customer. Get the customer with the Customers API and look at nemHandelReceiverType:
Receiver type |
|
EAN number |
|
CVR number |
|
P-number |
|
Peppol |
|
For an e-invoice via the API, the customer needs receiver type 0 (EAN) and an EAN number. If the type is EAN but there's no EAN number on the invoice, the request fails with E04300 "Angiv et EAN-nummer på fakturaen" ("Specify an EAN number on the invoice").
To fix it, set the customer's receiver type to EAN, in e-conomic or via the API, and set recipient.nemHandelType on the invoice to ean.
Delivery Status
Sent e-invoices show up in /invoices/sent with their delivery status. It covers e-invoices only, not e-mail, and it doesn't say why a delivery failed. The user can see the reason in e-conomic under Sales > Sent.