Creates a draft sales invoice. Either customerNumber or customerId must be provided.
You can include salesInvoiceLines in the body (deep insert).
Use $expand=salesInvoiceLines to have the created lines included in the response.
invoiceDate, postingDate and dueDate are applied after the customer is validated, so the values sent are kept.
Send apiTotalAmountExclVAT and apiTotalAmountInclVAT with the totals calculated in your system. When Check VAT Mismatch in API Request
is enabled in E-Invoice Setup, the amount excluding VAT must match the amount calculated by Business Central (error "Amounts excl. VAT doesn't match.").
A VAT difference is corrected automatically only when Allow VAT Auto Correction is enabled and the difference does not exceed
Max. VAT Difference Allowed in General Ledger Setup; otherwise the request fails with "VAT amount mismatched by %1, which exceeds the maximum allowed.".
When the document is posted, both totals must match the document amounts, otherwise posting fails with "... must match.".
Documents created via the API are marked "Created via API" and cannot be edited by users unless Allow API Documents Edit is enabled.
GUID for targeted Company
OData $expand for sales invoices. Supported navigations:
salesInvoiceLines, dimensionSetLines, pdfDocument, attachments, documentAttachments.
Line navigations can be nested, e.g. salesInvoiceLines($expand=dimensionSetLines,location).
Header-only invoice
{
"invoiceDate": "2022-11-21",
"postingDate": "2022-11-21",
"dueDate": "2023-02-19",
"customerPurchaseOrderReference": "NOTARINĖS SUT NR.",
"customerNumber": "P00004",
"billToCustomerNumber": "P00004",
"shipToName": "Antanas Antanaitis",
"currencyCode": "EUR",
"salesperson": "AT"
}Header with external VAT totals
{
"invoiceDate": "2026-03-21",
"postingDate": "2026-03-21",
"dueDate": "2026-04-05",
"customerNumber": "P0000004",
"billToCustomerNumber": "P0000004",
"currencyCode": "EUR",
"salesperson": "PIRMAS",
"paymentMethodCode": "PAVEDIMU",
"locationCode": "CENTRINIS",
"apiTotalAmountExclVAT": 100,
"apiTotalAmountInclVAT": 121
}Invoice with lines (+$expand)
{
"externalDocumentNumber": "TEST001",
"invoiceDate": "2020-10-22",
"postingDate": "2020-10-22",
"dueDate": "2020-11-01",
"customerNumber": "P0000001",
"billToCustomerNumber": "P0000001",
"currencyCode": "EUR",
"salesperson": "PJ",
"shortcutDimension1Code": "PARD",
"shortcutDimension2Code": "444",
"salesInvoiceLines": [
{
"lineType": "Item",
"lineObjectNumber": "Z0000001",
"locationCode": "CENTRINIS",
"description": "Kėdė baro",
"unitOfMeasureCode": "VNT",
"unitPrice": 100,
"quantity": 20,
"taxCode": "A PREK21",
"shipmentDate": "2020-10-22"
},
{
"lineType": "Item",
"lineObjectNumber": "Z0000002",
"locationCode": "CENTRINIS",
"description": "Stalas baro",
"unitOfMeasureCode": "VNT",
"unitPrice": 150,
"quantity": 20,
"taxCode": "A PREK21",
"shipmentDate": "2020-10-22"
}
]
}Payload to create or update a sales invoice.
On create either customerId or customerNumber must be provided.
salesInvoiceLines can be included on create (deep insert).
The fields postingDescription, shortcutDimension1Code, shortcutDimension2Code, paymentMethodCode,
locationCode, userId, apiTotalAmountExclVAT and apiTotalAmountInclVAT are applied only when they are
not empty (not zero), so they cannot be cleared through the API.
documentLink and documentNote add a record link and a record note to the document.
Total excluding VAT as calculated by the external system. Compared with the amount calculated by Business Central when Check VAT Mismatch in API Request is enabled.
Total including VAT as calculated by the external system. Used for the VAT mismatch check and, when Allow VAT Auto Correction is enabled, to correct VAT differences within Max. VAT Difference Allowed.
Deep insert of lines (create only).
Payload to create or update a sales invoice line. Lines can only be changed on draft invoices.
documentId is required when the line is created through the root salesInvoiceLines endpoint.
shortcutDimension1Code and shortcutDimension2Code are applied only when not empty.
Created
Sales invoice, draft or posted. A draft invoice is a Sales Header with document type Invoice,
a posted invoice is a Sales Invoice Header. Use posted and status to tell them apart.
Sell-to customer SystemId. Either customerId or customerNumber is required on create.
Sell-to customer number. Either customerId or customerNumber is required on create.
Draft: amount including VAT. Posted: remaining amount of the invoice. Canceled: 0.
Total excluding VAT as calculated by the external system. Compared with the amount calculated by Business Central when Check VAT Mismatch in API Request is enabled.
Total including VAT as calculated by the external system. Used for the VAT mismatch check and, when Allow VAT Auto Correction is enabled, to correct VAT differences within Max. VAT Difference Allowed.
Assigned User ID of the document.
URL stored as a record link on the document.
Text stored as a record note on the document.
Posted invoice is fully applied (closed). Always false for drafts.
Dimension set line (standard page "APIV2 - Dimension Set Lines").
If the customer, vendor, G/L account or item has default dimensions, overriding them on a document line needs additional PATCH requests;
without default dimensions, send the dimensions with the line in the same request.
For documents with hundreds of lines, post dimensions in a separate $batch request.
SystemId of the dimension (not of the line)
SystemId of the sales invoice. Cannot be changed.
Line No. Cannot be changed, delete and insert the line again.
Item or G/L account number, depending on lineType. Cannot be changed once set.
Dimension set line (standard page "APIV2 - Dimension Set Lines").
If the customer, vendor, G/L account or item has default dimensions, overriding them on a document line needs additional PATCH requests;
without default dimensions, send the dimensions with the line in the same request.
For documents with hundreds of lines, post dimensions in a separate $batch request.
SystemId of the dimension (not of the line)
Location (standard page "APIV2 - Locations").
PDF of the document (standard page "APIV2 - PDF Document", read-only).
Download the file with GET .../pdfDocument/pdfDocumentContent.
The report and layout come from Report Selections for the document type; if more than one report is set up, the first in sequence is used.
Incoming document attachment (standard page "APIV2 - Attachments").
Upload or download the file content via .../attachments({id})/attachmentContent.
Document attachment (standard page "APIV2 - Document Attachments").
Upload or download the file content via .../documentAttachments({id})/attachmentContent.
When the attachment is created together with the document (e.g. a signed sales contract), the file content is sent in a separate PATCH request.
Bad Request
Unauthorized