askledgerDocs
REST-APIInvoices
Documentatie

Book a purchase invoice

POST
/ledgers/{ledgerId}/purchase-entries

Book a purchase invoice in the accounting package (Exact: inkoopboeking), optionally with the invoice PDF attached. This is a permanent change to the books. Look up supplierId with search-contacts (role 'supplier'), ledger accounts with search-ledger-accounts, and journalCode with list-reference-data (kind 'journals', journalType 'purchase'). VAT needs no lookup: give each line a taxCategory and AskLedger picks the ledger's VAT code:

  • nl_high: Dutch supplier, 21% VAT on the invoice
  • nl_low: Dutch supplier, 9% VAT on the invoice (e.g. food, books, some repairs)
  • nl_reverse_charge: Dutch supplier, no VAT charged with "BTW verlegd" / "reverse charge" on the invoice (e.g. subcontracting, staffing)
  • eu_acquisition_high: supplier in another EU country, no VAT charged (reverse charge / intra-community), goods or services normally at 21% in NL
  • eu_acquisition_low: supplier in another EU country, no VAT charged, goods or services normally at 9% in NL
  • non_eu_import: supplier outside the EU (e.g. US software, UK after Brexit), no Dutch VAT charged
  • none: no VAT applies or the VAT is not deductible (exempt services such as insurance, bank fees, healthcare; foreign VAT you cannot reclaim): the whole amount is cost
  • zero_rated: Dutch VAT at 0% (e.g. international transport), only the base amount is reported Mixed rates on one invoice: one line per category. The package refuses a second booking with the same supplier and invoiceNumber (error code duplicate). The user must confirm before it is booked. If the result has created=false and a confirmation object, nothing was created yet: show confirmation.summary to the user verbatim and ask whether to create the booking. Only after the user explicitly says yes in the chat, call create-purchase-entry again with exactly the same arguments plus confirmationToken. Never confirm on the user's behalf and never reuse a token for other arguments.

A write: over REST only LedgerSuite products with askledger:purchase-write can call it, after their user approved the write in the product (no confirmation is asked). Other callers get 403 confirmation_required and use the MCP tool, which asks the user to confirm. Purchase entries: 409 duplicate when the package already has the booking (same supplier and invoice number); nothing was booked then. Send an Idempotency-Key to make retries safe.

Requires the ledger:write scope (Wijzigen in Exact). Same operation as the MCP tool create-purchase-entry.

Authorization

bearer
headerAuthorizationBearer <token>

A company group API key (al_live_…, created at /dashboard/api), an OAuth access token from the same authorization flow MCP clients use, or (other LedgerSuite products, /administrations routes only) a LedgerSuite client_credentials token.

Path Parameters

ledgerId*string

Ledger (administration) id, from list-ledgers

Length1 <= length

Header Parameters

Idempotency-Key?string

Unique per write (e.g. your own id for it), at most 255 characters. A retry with the same key and body gets the first response again (header Idempotent-Replayed: true) instead of a second write; the same key with another body answers 422 idempotency_key_reused, and a retry while the first request still runs 409 idempotency_in_progress. Kept for 7 days.

Lengthlength <= 255

Request Body

application/json
  1. body
supplierId*string

Supplier contact id (con_…) from search-contacts, or the remoteId create-supplier just returned

Length1 <= length
journalCode*string

Purchase journal code

Length1 <= length
invoiceDate*string

Invoice date (YYYY-MM-DD)

Match^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$
Formatdate
dueDate?string

Due date (YYYY-MM-DD); defaults from the payment term

Match^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$
Formatdate
invoiceNumber?string

The supplier's invoice number (Exact: Uw ref.)

Length1 <= length <= 255
description?string

Booking description

Lengthlength <= 255
paymentTermCode?string

Payment term code; defaults from the supplier

Length1 <= length
currency?string

ISO 4217 currency; the ledger's base currency when omitted

Match^[A-Z]{3}$
lines*array<>

Booking lines

Items1 <= items <= 100
document?

The invoice (PDF), attached to the booking in the package

Response Body

OK

application/json
  1. response
created*boolean
message*string
confirmation*|null
entry*|null
curl -X POST "https://example.com/ledgers/string/purchase-entries" \  -H "Content-Type: application/json" \  -d '{    "supplierId": "string",    "journalCode": "string",    "invoiceDate": "2019-08-24",    "lines": [      {        "ledgerAccount": "string",        "amount": 0,        "taxCategory": "nl_high"      }    ]  }'
{  "created": true,  "message": "string",  "confirmation": {    "token": "string",    "summary": "string",    "expiresInSeconds": 0  },  "entry": {    "ledgerId": "string",    "remoteId": "string",    "entryNumber": 0,    "supplierName": "string",    "invoiceNumber": "string",    "currency": "string",    "amountInclVat": 0,    "documentId": "string"  }}