AdemeroHelp

Integrate Paige with the Business Central API

For developers: the four Business Central API calls that turn a Paige invoice into a draft purchase invoice with the PDF attached — create the invoice, add lines, create the attachment record, upload its content — fed either from Paige's SFTP export files or straight from the Paige API.

IntegratorsHalf a day for a developerVerified 2026-09-05

Before you begin

  • A Business Central environment with the standard v2.0 API enabled and an app registration (OAuth client credentials) with API permissions
  • Somewhere to run code on a schedule (a function, a container, a scheduled job)
  • Either an SFTP server Paige exports to, or a Paige API key

At the end of this guide you'll have the exact sequence of Business Central API calls — and the two ways to get Paige's data into them — to create a draft purchase invoice with the PDF attached for every invoice Paige finishes.

If you'd rather not write code, the Power Automate path makes the same calls through Microsoft's connector.

Getting Paige's data

Two sources, same content:

SourceHowWhen to prefer it
SFTP export filesPaige writes <name>.pdf and <name>.json per document; your job polls the folder and reads the JSON (fields, metadata.document_type, metadata.pdf_file)Simplest; the PDF is already assembled
Paige APIGET …/scanJobs/{id}/documentPages for finished documents, then …/pages/{pageId}/fieldValues for values; page images via signed URLsYou want to query rather than watch a folder. Note the API returns page images and per-page text layers, not one merged PDF — see Integrate your own system with the Paige API.

Most integrations use SFTP for the PDF and either source for the data. The rest of this guide assumes you have, per invoice, the field values and the PDF bytes.

Authenticate to Business Central

Register an app in Microsoft Entra ID with the Dynamics 365 Business Central API.ReadWrite.All application permission, grant it in Business Central under Microsoft Entra Applications, and obtain a token with the client-credentials flow. Every call below carries Authorization: Bearer <token> and targets:

https://api.businesscentral.dynamics.com/v2.0/{tenantId}/{environment}/api/v2.0/companies({companyId})

Get the company id once from GET …/api/v2.0/companies.

The four calls

1. Create the purchase invoice

http
POST …/companies({companyId})/purchaseInvoices
Content-Type: application/json

{
  "vendorNumber": "V00123",
  "invoiceDate": "2026-08-28",
  "dueDate": "2026-09-27",
  "vendorInvoiceNumber": "INV-20441"
}

Returns 201 Created with the invoice id and its status: "Draft". Use vendorNumber (the vendor's No.) or vendorId; look the vendor up first with GET …/vendors?$filter=displayName eq 'Acme Office Supply' if Paige only gives you the name.

You can also create the invoice and its first line in one request by nesting purchaseInvoiceLines in the body (deep insert).

2. Add lines

http
POST …/companies({companyId})/purchaseInvoices({invoiceId})/purchaseInvoiceLines

{
  "lineType": "Account",
  "accountId": "<G/L account id>",
  "description": "Paige – Vendor Invoice",
  "quantity": 1,
  "unitCost": 1284.50
}

One line at Paige's Total is the simplest. For itemized invoices, send one line per row of Paige's line_items table, using $batch with Isolation: snapshot so a bad line rolls back the lot.

3. Create the attachment record

http
POST …/companies({companyId})/attachments

{
  "parentId": "<invoice id>",
  "parentType": "Purchase Invoice",
  "fileName": "INV-20441.pdf"
}

Returns the attachment id. In Business Central an attachment is an incoming document, which is why it appears under the invoice's Incoming Document FactBox.

4. Upload the PDF content

http
PATCH …/companies({companyId})/attachments({attachmentId})/attachmentContent
Content-Type: application/pdf
If-Match: *

<raw PDF bytes>

What you should see: 204 No Content, and the PDF opens from the invoice in Business Central.

Idempotency and errors

  • Before call 1, GET …/purchaseInvoices?$filter=vendorInvoiceNumber eq 'INV-20441' and vendorNumber eq 'V00123' and skip if one exists — Paige can export a document twice if someone re-exports by hand.
  • Paige's values are strings as printed. Normalize dates to yyyy-MM-dd and amounts to numbers before sending; Business Central validates both.
  • If you poll SFTP, move processed files to a processed/ subfolder; if you poll the Paige API, record processed page IDs.