Guides

Subscriptions

Manage the full subscription lifecycle including creation, pausing, cancellation, and plan changes.

Subscription Management

Subscriptions link customers to plans and manage the billing lifecycle automatically.

Subscription Lifecycle

TRIALING → ACTIVE → PAUSED → ACTIVE → CANCELED
                  → PAST_DUE → ACTIVE (after retry)
                              → CANCELED (after max retries)

Create a Subscription

curl -X POST http://localhost:3000/api/subscriptions \
  -H "Authorization: Bearer sk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "cust_x1y2z3",
    "planId": "plan_abc123",
    "currency": "UGX"
  }'

List Subscriptions

curl -X GET "http://localhost:3000/api/subscriptions?status=ACTIVE&page=1&limit=20" \
  -H "Authorization: Bearer sk_live_a1b2c3d4..."

Cancel a Subscription

curl -X POST http://localhost:3000/api/subscriptions/sub_j3k4l5/cancel \
  -H "Authorization: Bearer sk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "cancelAt": "period_end"
  }'

Pause and Resume

Pause a Subscription

curl -X POST http://localhost:3000/api/subscriptions/sub_j3k4l5/pause \
  -H "Authorization: Bearer sk_live_a1b2c3d4..."

Resume a Subscription

curl -X POST http://localhost:3000/api/subscriptions/sub_j3k4l5/resume \
  -H "Authorization: Bearer sk_live_a1b2c3d4..."

Change Plan

curl -X POST http://localhost:3000/api/subscriptions/sub_j3k4l5/change-plan \
  -H "Authorization: Bearer sk_live_a1b2c3d4..." \
  -H "Content-Type: application/json" \
  -d '{
    "newPlanId": "plan_premium",
    "prorate": true
  }'

Subscription Statuses

StatusDescription
TRIALINGCustomer is in a free trial period
ACTIVESubscription is active and billing normally
PAST_DUEPayment failed, retrying automatically
PAUSEDSubscription is temporarily paused
CANCELEDSubscription has been canceled
Copyright © 2026