Create a subscription
Before you begin
- Create at least one product and price in your catalog
- Create a customer with a payment method on file
- Decide on a billing interval (daily, weekly, monthly, or yearly)
Create a subscription
Dashboard
API
Python SDK
- Go to Billing > Subscriptions in the sidebar
- Click Create Subscription
- Select a customer
- Add one or more prices with quantities
- Set the billing interval and period start date
- Configure payment terms and collection method
- Click Create
The subscription is created and the first invoice is generated immediately.
Configuration options
Billing interval
Control how often the customer is billed:
Collection method
Payment terms
Set net_d to control when invoices are due for payment. A value of 0 means due immediately. A value of 30 gives the customer 30 days after invoice finalization.
Payment processor
Specify which payment processor to use for charging the subscription:
Fallback behavior:
- If
processor_idis not provided, PaymentKit uses the account’s default processor - If no default processor is configured for the account, the request fails with an error
You must either pass an explicit processor_id or have a default processor configured for your account. If neither is set, subscription creation will fail.
To set a default processor for your account:
- Go to Settings > Payment Processors in the dashboard
- Click the three-dot menu on a processor
- Select Set as Default
Or via API:
Add a trial period
Offer a free trial before the first charge by setting trial dates:
During the trial:
- The subscription is in Trialing state
- A
$0invoice is generated for the trial period - Three days before the trial ends, a
subscription.trial_will_endevent fires - At trial end, the subscription activates and the first paid invoice is created
Apply a discount
Attach a coupon or promotion code at creation:
Use coupon_id for a direct coupon reference, or promotion_code for a customer-facing code. If both are provided, the coupon referenced by the promotion code must match the given coupon_id.
Fixed-term subscriptions
Set total_billing_cycles to automatically cancel after a specific number of periods:
The subscription cancels automatically after 12 billing cycles complete.
Multiple items
A subscription can contain multiple prices. Each item represents a line on the recurring invoice:
What happens after creation
- The subscription is created in Incomplete state (or Trialing if a trial is set)
- An invoice is generated for the first billing period
- If
collection_methodischarge_automatically, payment is attempted immediately - On successful payment, the subscription transitions to Active
- The lifecycle engine schedules the next billing cycle
See Subscription lifecycle for details on state transitions.