Subscriptions
A subscription ties a customer to a pricing plan. It’s the thing that says “starting on this date, bill this customer according to this plan’s rules.” Until a customer has a subscription, MarginFront doesn’t know how to charge them. Usage events can still be logged, but there’s no pricing rule attached. Creating a subscription is the most complex create in the whole API because it brings together four other objects: a customer, an agent, a pricing plan, and a start date. All four have to already exist before you can create the subscription.The whole integration chain
Before you can create a subscription, you need (in this order):- A customer. See customers.
- An agent. See agents.
- One or more signals attached to that agent. See signals.
- A pricing plan attached to that agent. See pricing-plans.
Create a subscription
In plain English: Start billing a customer according to a pricing plan. You’re saying “from this date forward, charge this customer for this agent’s usage according to this plan.” Method & URL:name(string): a human-readable name for the subscription. Useful for identifying it in the dashboard.planId(UUID string): the pricing plan’s internal ID. From the pricing plan’s create response.agentId(UUID string): the agent’s internal ID. Must match the agent that the plan belongs to.customerId(UUID string): the customer’s internal ID. From the customer’s create response.startDate(ISO 8601 date string): when this subscription starts billing. Can be in the past (for backdating) or the future (for scheduled activation). Example:"2026-04-10T00:00:00.000Z".
status("upcoming"|"active"|"ended", default"upcoming"): current state. Use"active"if you want billing to start immediately.billingCycle("monthly"|"yearly"|"custom", default"monthly"): how often invoices are generated.billingModel("subscription"|"usage"|"hybrid", default"subscription"): how billing is calculated."subscription"= flat recurring fee"usage"= pay only for what you use"hybrid"= base fee + usage
netTerms(number, default30): payment terms in days after invoice issued.
endDate(ISO date): fixed end date if this is a time-limited subscriptionisForever(boolean, defaultfalse): set true for subscriptions with no end date (ignoresendDate)subscriptionDetails(object): free-form metadata specific to this subscriptionseatsCount(number, default0): for per-seat pricingcustomCycleDays(number): only whenbillingCycleis"custom"; how many days between invoicesproratedAmount(number): proration adjustment for mid-cycle startstimezone(string): override for billing period calculationsbillingDay(1-31): day of the month invoices are generatedinvoiceMemo(string): a note that appears on every invoice for this subscriptionmetadata(object): custom key/value pairs; stored but not interpreted
201 Created):
400 Bad Request: missing one of the required fields, or a UUID is the wrong format, orstartDateisn’t a valid ISO date.404 Not Found: one of the referenced objects (customer, agent, plan) doesn’t exist in this org.409 Conflict: this customer already has an overlapping active subscription for this plan, depending on your org’s rules.
Read a subscription
Method & URL:Read a subscription with revenue
In plain English: fetch a subscription together with its revenue, cost, and margin for a time window. Use this to power subscription detail pages without two round trips. Method & URL:startDate(ISO date): start of the window, inclusiveendDate(ISO date): end of the window, inclusive
RevenueMetrics object scoped to this subscription. Same shape as GET /v1/analytics/revenue, same math. Revenue, cost, margin, margin percent, the usage/recurring/seat/onetime breakdown, per-subscription breakdown (one row for this subscription), per-strategy breakdown.
See the SDK types reference for the full RevenueMetrics shape.
Using the SDK: client.subscriptions.getWithRevenue(id, window) wraps this endpoint and returns { subscription, revenue } in a single call (it fires the subscription fetch and this revenue fetch in parallel). See SDK subscriptions.
Common errors:
404 Not Found: no subscription with that ID exists in this org.401 Unauthorized: API key missing or wrong.
List subscriptions
Method & URL:customerId, status, agentId (check the controller for the full list).
Update a subscription
Method & URL:planId, agentId, customerId) generally should NOT be changed. If a customer switches plans, it’s usually cleaner to end the current subscription and create a new one rather than mutating the existing subscription, because it preserves a clean audit trail for accounting.
The billing dates can’t be changed after a subscription is created. The startDate and the current billing period’s start and end dates decide which usage each invoice picks up, so they’re locked once the subscription exists. If you include any of them in a PATCH, the request comes back 400 Bad Request with a message naming the fields you tried to move. To bill on a different schedule, end this subscription and create a new one that starts on the dates you want.
Update invoice dates
Method & URL:Read the subscription changelog
Method & URL:Using the Node SDK
@marginfront/sdk npm package. For now, create subscriptions through the HTTP API using curl or your language of choice. See the “Create a subscription” section above.
