Subscription Plans

List Plans

GET /api/billing/plans

Output: Array<{
  id: string
  name: string
  description: string | null
  storeId: string | null
  variants: Array<{
    id: string
    price: number
    currency: string
    interval: string
    interval_count: number
  }>
}>

Subscriptions

POST /api/billing/checkout

Input:
{
  planId: string
  variantId: string
  teamId: string
  redirectUrl?: string
}

Output: string // Checkout URL
POST /api/billing/portal

Input:
{
  subscriptionId: string
  redirectUrl?: string
}

Output: string // Customer Portal URL

Cancel Subscription

POST /api/billing/cancel

Input:
{
  id: string
}

Output: void

Resume Subscription

POST /api/billing/resume

Input:
{
  id: string
}

Output: {
  status: "ACTIVE" | "CANCELED" | "PAST_DUE" | "UNPAID" | "INCOMPLETE"
}

Sync Subscription (Admin Only)

POST /api/billing/sync

Input: {
  id: string
  teamId: string
  customerId: string
  status: "ACTIVE" | "CANCELED" | "PAST_DUE" | "UNPAID" | "INCOMPLETE"
  planId: string
  variantId: string
  currentPeriodStart: Date
  currentPeriodEnd: Date
  canceledAt: Date | null
  cancelAtPeriodEnd: boolean
}

Output: void

Notes

  1. All endpoints except List Plans require authentication.
  2. Most endpoints require team owner permissions.
  3. The billing system supports multiple providers (Stripe, Chargebee, LemonSqueezy) with a unified API interface.
  4. Subscription status changes are handled asynchronously through webhooks.
  5. All monetary values are in the smallest currency unit (e.g., cents for USD).