Commet
  • Pricing
Log InTry out
Introduction

Quickstart

Learn

Manage SubscriptionsUpgrade and Downgrade Plans

Resources

SDK ReferenceError HandlingTestingCLI

Plugins

Better Auth
DocumentationKnowledge BaseBuild with AIAPI ReferenceWebhooks

Manage Subscriptions

Manage the complete lifecycle of customer subscriptions.

Subscriptions connect a customer to a plan and handle recurring billing automatically. Each customer can have one active subscription at a time. Create one via the SDK or dashboard, and Commet manages checkout, invoicing, and lifecycle transitions.

Subscription lifecycle

StateDescriptionExample
DraftCreated but not yet activatedSubscription just assigned, no checkout sent
TrialingFree trial period active14-day trial on the Pro plan
Pending PaymentCheckout sent, awaiting paymentCustomer received checkout link but hasn't paid
ActiveBilling normallyMonthly invoice paid, features enabled
PausedTemporarily paused, no billingCustomer requested a break
Past DuePayment failed, in grace periodCard declined, retry scheduled
CanceledNo longer billingCustomer canceled or end-of-period reached
ExpiredReached scheduled end dateFixed-term subscription ended

Dashboard management

From the customer detail page, you can assign a plan, change plans, cancel, or regenerate a checkout link if the original expired. If your plans are in a Plan Group, customers can also change plans themselves through the Customer Portal.

Create a subscription

const subscription = await commet.subscriptions.create({
  customerId: 'user_123',
  planCode: 'pro',
})

redirect(subscription.data.checkoutUrl)
subscription = commet.subscriptions.create(
    customer_id="user_123",
    plan_code="pro",
)

redirect(subscription.data["checkout_url"])
subscription, err := client.Subscriptions.Create(ctx, &commet.CreateSubscriptionParams{
    CustomerID: "user_123",
    PlanCode:   "pro",
})

redirect(subscription.Data.CheckoutURL)
var subscription = commet.subscriptions().create("user_123", "pro");

redirect(subscription.getData().get("checkout_url"));
$subscription = $commet->subscriptions->create(
    customerId: 'user_123',
    planCode: 'pro',
);

redirect($subscription->data['checkout_url']);
curl -X POST https://commet.co/api/subscriptions \
  -H "x-api-key: $COMMET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "user_123",
    "planCode": "pro"
  }'

Returns a checkoutUrl — redirect the user there to complete payment.

Parameters

ParameterTypeDescription
customerIdstringCommet customer ID (cus_xxx) or your external ID
planCodestringPlan code (alternative to planId)
planIdstringPlan UUID (alternative to planCode)
billingIntervalstringmonthly, quarterly, or yearly
initialSeatsobjectSeat type codes mapped to quantities
skipTrialbooleanSkip the plan's trial period
successUrlstringRedirect URL after successful payment

Get subscription

const sub = await commet.subscriptions.get('user_123')

if (sub.data?.status === 'active') {
  // User has paid
}
sub = commet.subscriptions.get("user_123")

if sub.data and sub.data["status"] == "active":
    # User has paid
sub, err := client.Subscriptions.Get(ctx, "user_123")

if sub.Data != nil && sub.Data.Status == "active" {
    // User has paid
}
var sub = commet.subscriptions().get("user_123");

if ("active".equals(sub.getData().get("status"))) {
    // User has paid
}
$sub = $commet->subscriptions->get('user_123');

if ($sub->data['status'] === 'active') {
    // User has paid
}
curl "https://commet.co/api/subscriptions/active?customerId=user_123" \
  -H "x-api-key: $COMMET_API_KEY"

Cancel

await commet.subscriptions.cancel({
  subscriptionId: 'sub_xxx',
})
commet.subscriptions.cancel(subscription_id="sub_xxx")
_, err := client.Subscriptions.Cancel(ctx, &commet.CancelSubscriptionParams{
    SubscriptionID: "sub_xxx",
})
commet.subscriptions().cancel("sub_xxx");
$commet->subscriptions->cancel(subscriptionId: 'sub_xxx');
curl -X POST https://commet.co/api/subscriptions/sub_xxx/cancel \
  -H "x-api-key: $COMMET_API_KEY"

The subscription will remain active until the end of the current billing period. Any pending metered usage will be billed in the final invoice.

Canceled subscriptions cannot be reactivated — create a new one.

Learn more

  • How Does Billing Work

Related

  • Manage Plans — Create pricing plans that drive subscriptions
  • Upgrade and Downgrade Plans — How plan changes work
  • Trial Periods — Configure free trial periods
  • Customer Portal — Self-service billing portal for customers

How is this guide?

Introductory Offers

Configure automatic discounts on the first billing cycles for new customers in Commet.

Upgrade and Downgrade Plans

How customers change plans through the Customer Portal and dashboard.

On this page

Subscription lifecycle
Dashboard management
Create a subscription
Parameters
Get subscription
Cancel
Learn more
Related