Creates a draft purchase invoice. vendorNumber or vendorId is required.
You can include purchaseInvoiceLines in the body.
Use $expand=purchaseInvoiceLines to have the created lines included in the response.
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 purchase invoices. Supported navigations:
purchaseInvoiceLines, dimensionSetLines, pdfDocument, attachments, documentAttachments.
Line navigations can be nested, e.g. purchaseInvoiceLines($expand=dimensionSetLines,location).
Header-only invoice
{
"invoiceDate": "2025-04-02",
"postingDate": "2025-04-02",
"dueDate": "2025-04-12",
"vendorNumber": "V000045",
"payToVendorNumber": "V000045",
"currencyCode": "EUR",
"vendorInvoiceNumber": "PIN00000134"
}Invoice with lines (+$expand)
{
"invoiceDate": "2025-04-02",
"postingDate": "2025-04-02",
"dueDate": "2025-04-12",
"vendorNumber": "V000045",
"payToVendorNumber": "V000045",
"currencyCode": "EUR",
"vendorInvoiceNumber": "PIN00000134",
"purchaseInvoiceLines": [
{
"lineType": "Comment",
"lineObjectNumber": "",
"description": "Invoice No. PIN00000134:",
"quantity": 0,
"unitCost": 0,
"discountAmount": 0,
"discountPercent": 0,
"taxCode": ""
},
{
"accountId": "ded8a20e-3f41-ec11-a458-000d3adf1e39",
"lineType": "Account",
"lineObjectNumber": "5001",
"description": "Service Revenue",
"quantity": 1,
"unitCost": 300,
"discountAmount": 0,
"discountPercent": 0,
"taxCode": "F PASL21"
},
{
"lineType": "Item",
"lineObjectNumber": "Z0000001",
"description": "Sulankstoma kėdė",
"quantity": 10,
"unitCost": 50,
"discountAmount": 0,
"discountPercent": 0,
"taxCode": "A PREK21"
}
]
}Invoice with lines, deferral and API totals (+$expand=purchaseInvoiceLines)
{
"invoiceDate": "2025-03-14",
"postingDate": "2025-03-14",
"dueDate": "2025-03-29",
"vendorInvoiceNumber": "KP50055",
"vendorNumber": "T00001",
"payToVendorNumber": "T00001",
"shipToName": "Elgerta Polska",
"shipToAddressLine1": "Warsawa ul 154",
"shipToCity": "Warsawa",
"shipToCountry": "PL",
"currencyCode": "EUR",
"pricesIncludeTax": false,
"apiTotalAmountExclVAT": 500,
"apiTotalAmountInclVAT": 605,
"postingDescription": "Furniture Ltd. TSF24425345",
"purchaseInvoiceLines": [
{
"lineType": "Item",
"lineObjectNumber": "Z0000001",
"unitOfMeasureCode": "VNT",
"unitCost": 1,
"quantity": 500,
"taxCode": "A PREK21",
"expectedReceiptDate": "2025-03-14",
"locationCode": "CENTRINIS",
"deferralCode": "1Y"
}
]
}Writable purchase invoice fields. On create, vendorNumber or vendorId must be provided.
purchaseInvoiceLines and dimensionSetLines can be included for a deep insert.
Assigned User ID (BC user name, not a GUID).
Writable purchase invoice line fields. documentId is filled automatically when the line is created
under a purchase invoice. documentId, sequence and lineObjectNumber 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)
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)
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.
URL stored as a record link on the document.
Text stored as a record note on the document.
Created
Buy-from vendor number. Either vendorId or vendorNumber is required on create.
Assigned User ID (BC user name, not a GUID).
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").
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)
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.
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.
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. The page accepts a value but ignores it.
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