Skip to Content
API ReferenceSubscriptions

Subscriptions API

Manage recurring billing subscriptions with plan changes, pausing, and cancellation.

List Subscriptions

GET /api/billing/subscriptions

Response 200 OK

[ { "id": "01JQX...", "customerId": "01JQA...", "planId": "01JQB...", "status": "active", "billingCycle": "monthly", "currentPeriodStart": "2026-03-01T00:00:00Z", "currentPeriodEnd": "2026-04-01T00:00:00Z", "cancelAtPeriodEnd": false, "trialEnd": null, "createdAt": "2026-01-15T10:30:00Z" } ]

Create Subscription

POST /api/billing/subscriptions Content-Type: application/json

Body

FieldTypeRequiredDescription
customerIdUUIDYesCustomer to subscribe
planIdUUIDYesPricing plan
billingCyclestringYesmonthly, quarterly, or yearly
trialDaysintegerNoTrial period in days
couponCodestringNoDiscount coupon to apply

Response 201 Created

Update Subscription

PUT /api/billing/subscriptions/:id Content-Type: application/json
FieldTypeDescription
statusstringactive, paused, canceled
cancelAtPeriodEndbooleanSchedule cancellation at period end

Change Plan

POST /api/billing/subscriptions/:id/change-plan Content-Type: application/json

Body

FieldTypeRequiredDescription
newPlanIdUUIDYesTarget plan
proratebooleanNoWhether to prorate (default: true)

Plan changes are prorated by default — a credit is issued for unused time on the old plan.

Subscription Statuses

StatusDescription
activeCurrently billing
pausedTemporarily suspended (no invoices generated)
canceledPermanently canceled
past_duePayment failed, in dunning
trialingWithin trial period

Lifecycle Automation

The subscription lifecycle cron job runs daily and:

  1. Generates invoices for subscriptions reaching their period end
  2. Advances billing periods
  3. Expires trials
  4. Processes scheduled cancellations
  5. Triggers auto-charge for due invoices

See Configuration for cron schedule customization.

Last updated on