Invoices
An invoice is a finalized bill. The document you send to a customer when it’s time to pay. MarginFront generates invoices automatically based on each customer’s subscription and logged usage events. The API lets you read those invoices back so you can display them in your own product, sync them to accounting tools, or hand them to your finance team. Right now the invoice API is read-only through the public surface. Invoice creation happens automatically at the end of each billing period (driven by the subscription’s billing cycle). Manual invoice creation will come later.The endpoints
List invoices
Method & URL:customerExternalId: filter to a single customerstatus: filter by state. Valid values aredraft,pending,issued,paid,overdue,void,refunded(see Invoice statuses below)startDate/endDate: filter by invoice date rangelimit/offset: pagination
200 OK):
Read one invoice
Method & URL:Invoice statuses
MarginFront invoices move through one of seven statuses over their lifetime. Every invoice in the API has itsstatus field set to exactly one of these.
| Status | Meaning |
|---|---|
draft | Still being built. Not yet sent. Amounts can still change. Does not count as billed revenue. |
pending | Finalized and queued to send. Sitting in the outbox waiting for the send step. |
issued | Sent to the customer. Awaiting payment. Counts as billed revenue. |
paid | Customer paid in full. Counts as collected revenue. |
overdue | Past the due date without full payment. Still counts as billed revenue; payment is late. |
void | Canceled. Treated as if it never happened for billing purposes. Does not count toward billed or collected. |
refunded | Was paid, then fully refunded. Counts as neither billed nor collected once it lands here. |
draft → pending → issued → paid. Most invoices go through exactly those four.
Refund flow
Refunds are recorded against a payment, not directly against the invoice. When you create a refund usingPOST /v1/invoices/:invoiceId/payments/:paymentId/refund, MarginFront records the refund and, if the refund covers the entire invoice, moves the invoice from paid to refunded. Partial refunds leave the invoice in paid and just reduce the net collected amount.
Once an invoice is refunded:
- It is excluded from collected revenue totals.
- It is excluded from billed revenue totals (as if it had never been invoiced).
- The underlying payment and refund records are preserved for audit.
refunded correctly. If you are rolling your own accounting sync, treat refunded invoices the same way you would treat void invoices for revenue-recognition purposes.
Common errors
401 Unauthorized: API key missing or wrong.404 Not Found: no invoice with that ID exists in this org.
Using the Node SDK
Analytics vs invoices: which do I want?
Quick disambiguation since both expose “cost” numbers:| Use analytics | Use invoices |
|---|---|
| ”How much has this customer used so far this month?" | "What’s the final bill I’m sending them?” |
| Live projections, dashboards | Accounting, A/R, customer portals |
| Raw usage data, no taxes/discounts | Finalized totals with taxes, discounts, prorations |
| Current period, real-time | Completed billing periods |

