HTTP API reference
Invoices & chart data
List and edit saved rows. `GET /api/invoices/aggregates` returns monthly series or top counterparties for dashboards — not the same as `GET /api/bi/summary` (period P&L totals).
Endpoints in this topic
GET/api/invoices
Paginated list of stored invoices for the authenticated user.
GET — query: page (≥1, default 1), limit (1–200, default 20), kind=expense|revenue, from / to (YYYY-MM-DD on parsed document date), q (search, max 200 chars; counterparty / invoice # / raw text).
{
invoices[], page, limit, total, totalPages
}
Each invoice: id, createdAt, invoiceKind, provider,
invoiceNumber, documentDate, total, currency, fileUrl, mimeType.GET/api/invoices/[id]
Fetch one invoice by id (path param).
Path segment [id] = invoice UUID.
{
invoice: {
id, createdAt, invoiceKind, provider, invoiceNumber,
documentDate, total, currency, fileUrl, mimeType, rawText?
}
}PATCH/api/invoices/[id]
Update invoice_kind and/or parsed_data fields.
Content-Type: application/json
{
"invoice_kind": "expense" | "revenue",
"parsed_data": { partial InvoiceExtract }
}
(both fields optional; parsed_data merges into existing parsed_data then re-validates){
invoice: { …same shape as GET /api/invoices/[id] … }
}DELETE/api/invoices/[id]
Delete a stored invoice.
Path segment [id] = invoice UUID.
200 { ok: true }. 404 with error JSON if the row is missing.GET/api/invoices/aggregates
Monthly revenue/expense series or top counterparties (groupBy=month|counterparty). Respects reporting currency like GET /api/bi/summary; response includes `caveats`.
GET — query: from, to (YYYY-MM-DD; default ≈ last 365 days UTC), groupBy=month | counterparty, kind=expense|revenue (counterparty mode only; default revenue), limit (1–50, default 10 for counterparty top-N).
groupBy=month: {
groupBy, period, series: [{ period, revenue, expenses }], caveats
}
groupBy=counterparty: {
groupBy, kind, period,
counterparties: [{ name, kind, total, invoiceCount }], caveats
}