Skip to main content

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:
  1. Listing subscriptions
  2. Getting one subscription
  3. Getting a subscription with its revenue numbers attached

Setup


subscriptions.list

Returns a paginated list of subscriptions with optional filters.

Signature

Parameters

All optional.

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

Pass both window fields together or neither. Omitting both defaults to the last 30 days UTC.

Response shape

The 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

  • subscription the usual subscription detail. Customer, agent, plan, status, billing cycle, current-period usage summary.
  • revenue a 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.
For the full shape of 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), use subscriptions.get. For revenue across many subscriptions, use analytics.revenue with no filter.

Next steps