Subscriptions
The subscriptions resource on the SDK covers the usual list + get operations, plus one method built for subscription detail pages:getWithRevenue. It fetches the subscription and its revenue/cost/margin for a time window in one round trip.
This page covers:
- Listing subscriptions
- Getting one subscription
- Getting a subscription with its revenue numbers attached
Setup
subscriptions.list
Returns a paginated list of subscriptions with optional filters.
Signature
Parameters
All optional.| Name | Type | Description |
|---|---|---|
customerId | string | Filter to one customer (MarginFront’s internal UUID). |
customerExternalId | string | Filter to one customer by YOUR external id. |
agentId | string | Filter to one agent. |
status | string | "active", "paused", "cancelled", "ended", "pending". |
page | number | Page number (default 1). |
limit | number | Results per page (default 20). |
Example
subscriptions.get
Fetches one subscription by id. Returns the full subscription detail plus a usage summary for the current billing period.
Signature
Example
subscriptions.getWithRevenue
What it does in plain English: fetches a subscription AND its revenue numbers for a time window, in one call. Lets you render a subscription detail page (status, plan, usage, revenue, cost, margin) without juggling two round trips.
Behind the scenes the SDK fires both requests in parallel, so the wall-clock time is roughly the time of one call.
Signature
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
subscriptionId | string | yes | The subscription id. |
window.startDate | string | no | ISO date. Defaults to 30 days ago if omitted. |
window.endDate | string | no | ISO date. Defaults to today if omitted. |
Response shape
subscription field is the same shape as subscriptions.get returns. The revenue field is the same canonical shape analytics.revenue returns, scoped to this one subscription. See Types Reference for the complete interfaces.
Example
What this returns, in plain English
subscriptionthe usual subscription detail. Customer, agent, plan, status, billing cycle, current-period usage summary.revenuea full canonical revenue block for this one subscription, in the window you asked for. Revenue, cost, margin, marginPercent, plus the usage/recurring/seat/onetime breakdown and a per-pricing-strategy row list.
RevenueMetrics, see Types Reference.
When to use this
Subscription detail pages. “Customer plan overview” dashboards. Anywhere you need the subscription AND how it’s performing in one view. For just the subscription record (no revenue math), usesubscriptions.get. For revenue across many subscriptions, use analytics.revenue with no filter.
Next steps
- Analytics: all seven canonical analytics methods
- Types Reference: full interface definitions
- Customers with Revenue: the same pattern, but scoped to a customer

