Subscription schedules
Learn about subscription schedules and how to use them.
Use subscription schedules to automate changes to subscriptions over time. You can create subscriptions directly through a schedule or you can add a schedule to an existing subscription. Use the phases attribute to define the changes you want to make to the subscription. After a schedule completes all of its phases, it completes based on its end_behavior.
Some changes you might want to schedule include:
- Starting a subscription on a future date
- Backdating a subscription to a past date
- Upgrading or downgrading a subscription
Subscription schedules are available in both the Stripe Billing Dashboard and the API. Here’s a quick video of how subscription schedules work in the Dashboard:
Subscription schedules in the Dashboard
The rest of this document explains subscription schedules in more detail. To see a list of examples, see the use cases page.
Phases
When creating a subscription schedule, use the phases attribute to define when changes occur and what properties of the subscription to change. For example, you might offer a coupon for 50% off for the first three months of a subscription. In this scenario, you’d create a subscription schedule where the first phase is three months long and contains the 50% off coupon. In the second phase, the subscription would be reverted to the normal cost and the coupon would be removed. Phases must be sequential, meaning only one phase can be active at a given time. You can have up to 10 phases.
Set the length of a phase
The interval of a price determines how often to bill for a subscription. For example, a monthly interval is billed every month. Phases have an iterations attribute that you use to specify how long a phase should last. Multiply this value by the interval to determine the length of the phase. If a subscription schedule uses a price with a monthly interval and you set iterations=2
, the phase lasts for two months.
The end_
of one phase has to be the start_
for the next phase. Using iterations
automatically sets the start_
and end_
properly. You can set these values manually, but Stripe recommends using iterations
instead. Because manually setting the start and end dates is prone to errors, only use it for advanced use cases.
Transition to the next phase
Phase transitions happen automatically after the end_
on a phase is reached. When a phase starts, Stripe updates the subscription based on the attributes of the next phase. You can optionally enable proration to credit the user for unused items or time on the plan.
Use trials
You can add trial periods by setting trial end on a phase. If you want the entire phase to be a trial, set the value of trial_
to the same time as the end_
of the phase. You can also set trial_
to a time before the end_
if you want to make only part of the phase a trial. When scheduling updates, you must specify the new trial_
on each phase.
Complete a schedule
Subscription schedules end after the last phase is complete. At this point, the subscription is left in place and is no longer associated with the schedule. If you want to cancel a subscription after the last phase of a schedule completes, you can set end_behavior to cancel
.
Phase attribute inheritance
When a phase becomes active, all attributes set on the phase are also set on the subscription. After the phase ends, attributes remain the same unless the next phase modifies them, or if the schedule has no default setting. You can set some attributes on both schedules and phases. This includes:
If one of these attributes is defined on the schedule, it becomes the default for all phases. When the same property is defined on both the schedule and the phase, the phase attribute overrides the schedule attribute. This behavior is explained more below:
Schedule attribute present | Phase attribute present | Outcome |
---|---|---|
No | No | Defaults to the customer or account settings |
Yes | No | Schedule attribute set |
Yes | Yes | Phase attribute set |
No | Yes | Phase attribute set |
Use phase metadata
You can use subscription schedule phases to set metadata on the underlying subscription. This allows you to control the metadata on a subscription with scheduled updates.
Learn how to copy subscription metadata onto subscription invoices.
Create subscription schedules
The use cases page has more thorough examples but below is a basic example of creating a subscription schedule using a customer. Creating a schedule this way automatically creates the subscription as well.
Note
Unlike when you create a subscription directly, the first invoice of a subscription schedule with collection_
set to charge_
behaves like a recurring invoice and isn’t immediately finalized at the time the schedule’s subscription is created. The invoice begins in a draft
status and is finalized by Stripe about 1 hour after creation.
This means that, for example, creating a charge-automatically subscription schedule with start_
also creates a subscription and an invoice in the draft
status. This gives you a 1-hour window to make edits to the invoice. Later, the invoice is auto-advanced into the open
or paid
status depending on the outcome of the asynchronous payment attempt at finalization time.
Update subscription schedules
You can only update the current and future phases on subscription schedules.
Preview an invoice
Use the schedule parameter in the create preview to preview the next invoice for a subscription schedule.
Previewing schedule creation and updates
Use the parameters in schedule_details to preview creating or updating a subscription schedule. Pass an existing schedule to tell Stripe whether it’s a creation or an update.
Pass all of the current and future phases you’re previewing.
For example, the following code previews the first invoice for a subscription schedule with 1
phase that lasts for 12
billing periods.
Dashboard limitations
You can create and update subscription schedules without code in the Dashboard.
In the Dashboard, you can set the following settings globally across all phases, but not on a per phase basis:
- Billing thresholds
- Payment methods
- Invoice settings
- Subscription description
- Trial days (only works with the first phase)
The following parameters aren’t supported in the Dashboard:
- Subscription schedule metadata
- Phase item metadata
- Currency
- All Connect parameters