Revenue analytics
GET /v1/analytics/revenue is the single place to read revenue, cost, and margin out of MarginFront. Same math the dashboard runs, same shape. Use it when you need to know:
- How much you earned in a time window
- What it cost you to earn that
- Your margin (dollars and percent)
- Where the revenue came from (per subscription, per pricing strategy)
The endpoint
Method and URL:x-api-key header. See Authentication.
Query parameters
| Param | Type | Required | Description |
|---|---|---|---|
startDate | ISO date | yes | Start of the window (inclusive). Example: 2026-04-01. |
endDate | ISO date | yes | End of the window (inclusive). |
variant | string | no | Response shape. canonical for the shape documented below. Omit or pass legacy to get the older dashboard breakdown. |
customerId | UUID | no | Narrow to one customer. Use MarginFront’s internal customer UUID, not your externalId. |
subscriptionId | UUID | no | Narrow to one subscription. |
agentId | UUID | no | Narrow to one agent. |
signalId | UUID | no | Narrow to one signal. |
variant: if you pass any of customerId, subscriptionId, or signalId, the response is always the canonical shape shown below. The variant flag only matters when you call the endpoint org-wide with no entity filter. The SDK method client.analytics.revenue() always passes variant=canonical, so SDK users never have to think about this.
Example curl calls
Org-wide revenue for April 2026:What you get back (200 OK)
Understanding the response
revenueis the full revenue total for the window: usage-based charges plus recurring fees plus seat fees plus one-time fees, all prorated if the subscription only partly overlapped the window.costis what it cost you to deliver the underlying usage: the sum ofusageCostacross every usage event in the window.marginisrevenueminuscost.marginPercentis margin divided by revenue, expressed as a percent (so74.98means 74.98%). If revenue is0the field isnull, never0and neverNaN. That way “no revenue yet” shows up differently from “zero margin.”usageRevenue/recurringRevenue/seatRevenue/onetimeRevenuesplit the revenue total by charge type. They always add up torevenue.eventCountcounts every usage event that fell inside the window.eventCountWithNullCostis the subset of those events whose cost could not be computed (no matching price in the catalog). They are counted ineventCountbut contribute0tocost. Treat this as a “needs attention” indicator.bySubscriptionis one row per subscription that produced revenue in the window. Useful for customer detail pages and per-subscription drill-down.byStrategyis one row per pricing strategy that contributed revenue. Useful for the “revenue by type” donut chart.
number, not strings.
When to use this vs. other endpoints
Use this endpoint when you want the revenue answer: Dollars in, cost out, margin. Use/v1/analytics/usage when you want raw usage roll-ups (event counts, quantity totals) without pricing math.
Use /v1/analytics/cost when you want cost broken down by agent, customer, signal, day, plan, or model, and you do not need revenue.
Use /v1/analytics/mrr when you want monthly recurring revenue specifically (last-calendar-month billed, run-rate, or contractual floor).
Use /v1/invoices when you want what was actually billed. Analytics tells you the revenue math; invoices are the documents you sent.
Using the Node SDK
Common errors
400 Bad Request:startDateorendDateis missing, in the wrong format, or one of the UUID filters is not a valid UUID.401 Unauthorized: API key missing or wrong.

