Skip to content

Invoices → accounting

This guide connects MendriX invoicing to your accounting system: pull finalized invoices out, and post payments back in. It uses the Invoice service (list/get/patch/finalize/cancel/delete, plus payments).

Step 1 — Pull finalized invoices (incremental)

Section titled “Step 1 — Pull finalized invoices (incremental)”
Terminal window
# Page finalized invoices changed since your last run.
curl "$MENDRIX_BASE/invoice/invoices/?since=$WATERMARK&limit=1000" \
-H "Authorization: Bearer $MENDRIX_ACCESS_TOKEN" \
-H "Accept: application/json"
const since = loadWatermark() || 1; // sequence number; 1 on the first run
const params = new URLSearchParams({ limit: '1000', since });
const state = {};
for await (const invoice of listAll('/invoice/invoices/', params, state)) {
if (isFinalized(invoice)) {
postInvoiceToAccounting(invoice); // your side
}
}
saveWatermark(state.maxSequence); // once, at the end of the cycle

Fetch a single invoice’s full detail with GET /invoice/invoices/{invoiceId} when you need line-level data.

When your accounting system registers a payment, record it against the MendriX invoice:

Terminal window
curl -X POST "$MENDRIX_BASE/invoice/invoices/INVOICE_ID/payments" \
-H "Authorization: Bearer $MENDRIX_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "amount": 1250.00, "date": "2026-07-21", "reference": "BANK-TXN-8842" }'

List or remove payments:

Terminal window
curl "$MENDRIX_BASE/invoice/invoices/INVOICE_ID/payments" \
-H "Authorization: Bearer $MENDRIX_ACCESS_TOKEN"
curl -X DELETE \
"$MENDRIX_BASE/invoice/invoices/INVOICE_ID/payments/PAYMENT_ID" \
-H "Authorization: Bearer $MENDRIX_ACCESS_TOKEN"

Refer to the reference for the exact payment body.

The Invoice service also supports, via REST (see the reference):

  • POST /invoice/invoices/{invoiceId}/finalize — finalize a preliminary invoice.
  • POST /invoice/invoices/{invoiceId}/cancel — cancel an invoice.
  • DELETE /invoice/invoices/{invoiceId} — delete a preliminary invoice.
  • PATCH /invoice/invoices/{invoiceId} — merge-patch (preliminary-only fields apply while preliminary).
  • Match on a stable key (MendriX invoice id ↔ your accounting reference).
  • Idempotent payment posting — guard against posting the same bank transaction twice (dedupe on reference).
  • Watermark after success so a failed run safely re-reads next time.