Types Reference
Every canonical type the SDK exports, with the full interface definition and a plain-English description of what it represents and when you’d see it. Money rule: every dollar amount isnumber, not string. Values come back at full precision. Round at render time, never before.
Null rule: a null means “not applicable here,” not zero. Most commonly: marginPercent: null means “revenue was zero, so margin cannot be computed.” Render as a dash, not 0%.
RevenueMetrics
The canonical revenue shape. Returned byanalytics.revenue, embedded inside the revenue block of customers.getWithRevenue and subscriptions.getWithRevenue.
revenue total and tell you WHERE it came from (usage events, recurring fees, seats, or one-time charges). eventCount is every event; eventCountWithNullCost is the subset whose cost couldn’t be calculated yet.
When you’d see it: any canonical analytics call, plus the revenue blocks on customer and subscription detail pages.
SubscriptionRevenue
One row per active subscription insideRevenueMetrics.bySubscription.
RevenueMetrics.bySubscription, returned by analytics.revenue and the two getWithRevenue overlays.
StrategyRevenue
One row per pricing strategy insideRevenueMetrics.byStrategy.
chargeType tells you whether this was a usage rate, a recurring fee, a seat fee, or a one-time charge. pricingModel tells you the shape of usage rates (flat/graduated/volume/credit_pool). For usage strategies, quantity is the total quantity that ran through the rate in the window; for non-usage strategies it’s 0.
When you’d see it: inside RevenueMetrics.byStrategy.
CostMetrics
The canonical cost shape. Returned byanalytics.costBreakdown.
prior is a same-length window immediately before startDate, populated only when you asked for it with includePriorWindow: true.
When you’d see it: analytics.costBreakdown.
CostByAgentRow
CostByCustomerRow
CostBySignalRow
signalId: null covers orphan events that aren’t tied to a signal.
CostByDayRow
date is an ISO string (JSON doesn’t carry Date objects); convert on your side if you need a Date.
CostByPlanRow
planId: null covers events whose subscription isn’t on a plan.
CostByModelRow
model: null covers non-LLM events and events whose model wasn’t recognized yet.
AgentEarned
The canonical shape returned byanalytics.agentEarned.
analytics.agentEarned.
AgentEarnedSubscriptionRow
AgentEarnedStrategyRow
quantity is the total quantity that ran through the rate.
InvoiceTotals
The canonical invoice-totals shape. Returned byanalytics.invoiceTotals.
billed is what you invoiced in the window (status issued or overdue). collected is what got paid in the window. draft is inventory of invoices not yet sent. outstanding is billed minus collected (age-independent). overdueAmount and overdueCount are current-state right now (not filtered by the date window). invoicesSentCount is how many non-draft invoices were dated in the window.
When you’d see it: analytics.invoiceTotals.
Mrr
Returned byanalytics.mrr.
mrr × 12). Stable across the current month (doesn’t move until the next month rolls over).
When you’d see it: analytics.mrr.
RunRateMrrResult
Returned byanalytics.runRateMrr.
analytics.runRateMrr.
RunRateMrrBreakdownRow
recurring is the monthly-normalized recurring fees. seatBased is seat fees based on max(booked, minimum) seats. usage is actual last-30-days events run through the pricing rate. The three add up to total, and all the totals add up to the top-level mrr.
CommittedMrrResult
Returned byanalytics.committedMrr.
RunRateMrrResult.mrr.
When you’d see it: analytics.committedMrr.
CommittedMrrBreakdownRow
usage column is minimum_commitment × rate (or 0 when the pricing strategy has no minimum set), not actual usage.
SubscriptionDetailWithRevenue
Returned bysubscriptions.getWithRevenue.
subscriptions.getWithRevenue.
CustomerDetailWithRevenue
Returned bycustomers.getWithRevenue.
customers.getWithRevenue.
Parameter types (for completeness)
All canonical analytics methods accept typed parameter objects. These are exported so you can use them in your own function signatures.RevenueMetricsParams
CostMetricsParams
InvoiceTotalsParams
customerId). That’s intentional: invoice math runs at the customer scope, not per-subscription or per-signal.
MrrParams
analytics.mrr uses a fixed “last complete calendar month” window. analytics.runRateMrr uses a fixed “last 30 days” window. analytics.committedMrr is not window-dependent at all.
AgentEarnedParams
Rounding and precision
Every money field in every type above is a rawnumber. No pre-rounding, no string wrapping.
Round exactly once, at the UI boundary:
Next steps
- Analytics: the seven methods that return these shapes
- Subscriptions: where
SubscriptionDetailWithRevenuecomes from - Customers: where
CustomerDetailWithRevenuecomes from

