Usage Analytics
The usage analytics endpoint is how you read raw usage data back out of MarginFront. It returns rolled-up event counts, quantity totals, and cost for any customer, agent, or time window you specify. Use it to:- Power “current period usage” widgets in your own product
- Build cost dashboards that show your customers what they’ve used this month
- Project a customer’s end-of-month bill before the invoice is generated
- Feed data into your own BI tools
Looking for revenue, margin, or MRR? This page covers the raw usage roll-up. For revenue and margin use/v1/analytics/revenue. For cost with breakdowns by agent, customer, signal, day, plan, or model use/v1/analytics/cost. For monthly recurring revenue use/v1/analytics/mrr.
The endpoint
Method & URL:x-api-key header.
Query parameters
All optional. If you don’t specify any, you get a roll-up for the whole org over the default time window.| Param | Type | Description |
|---|---|---|
startDate | ISO date | Start of the time window (inclusive). |
endDate | ISO date | End of the time window (inclusive). |
customerId | UUID | Filter to a single customer. Use MarginFront’s internal customer UUID (not your externalId). |
agentId | UUID | Filter to a single agent. |
signalId | UUID | Filter to a single signal. |
groupBy | string | Time-bucket size for timeSeriesData. One of "daily", "weekly", "monthly". Default: "daily". |
breakdownBy | string | Add a dimensionBreakdown section broken out by one of "customer", "signal", "agent". When omitted, the response has no dimensionBreakdown field. |
groupBy or breakdownBy value, the API returns 400 Bad Request with a message listing the accepted values.
Example curl calls
Get everything for April 2026:What you get back (200 OK)
breakdownBy, an additional dimensionBreakdown field appears at the top level:
Understanding the response
summary: totals across the entire date range. This is what most dashboards want. Fields:totalEvents,totalQuantity,totalCost,avgCostPerEvent.timeSeriesData: one row per time bucket (daily,weekly, ormonthlydepending ongroupBy). Good for drawing charts. Note the row field iseventCount(nottotalEvents).metadata: lookup dictionaries mapping UUIDs to human-readable names for signals, customers, and agents referenced in the results. Use it to render labels without a second round-trip.dimensionBreakdown: present only when you passbreakdownBy=customer|signal|agent. An object withdimensionType, asummaryarray (one row per dimension with totals across the window), and atimelinearray (per-bucket rows tagged with the dimension).dateRangeandfilters: echo back what you queried so the response is self-describing.filterscontains only the keys you actually passed (it’s{}when you passed no filters).
totalCost, totalQuantity, totalEvents, and avgCostPerEvent on summary, every field on timeSeriesData rows, and every field on dimensionBreakdown rows. (Contrast with GET /v1/events, where per-event usageCost and quantity are strings.) Analytics values are already rolled up, so sub-cent precision only shows up in averages.
Common errors
400 Bad Request: a query parameter is in the wrong format (e.g.,startDateisn’t a valid ISO date).401 Unauthorized: API key missing or wrong.
Using the Node SDK
What this endpoint is for (and what it isn’t)
Use this for:- Live dashboards, projections, “usage so far this month” displays
- Triggering alerts when a customer hits a usage threshold
- Feeding simple BI reports
- Revenue, margin, or MRR. Use
/v1/analytics/revenueor/v1/analytics/mrrinstead. - Cost broken down by agent / customer / signal / day / plan / model. Use
/v1/analytics/costinstead. - Actual invoice data. Use invoices. Usage analytics gives you “here’s the raw usage roll-up,” but invoices are the finalized billing documents that include discounts, taxes, prorations, etc.
- High-resolution per-event drill-down. This endpoint returns aggregates. For event-level detail, use the signal-events listing endpoint at
GET /v1/events.

