Dynamically update trial durations
Learn how to modify subscription trial periods during checkout.
Private preview
Dynamic trial updates is in private preview. Request access to dynamic trial updates.
Learn how to dynamically update trial durations on subscription Checkout Sessions.
Use cases 
- Dynamic trial management: Add or remove trials based on promotional conditions or customer actions.
- Extend trials for upsells: Offer longer trial periods when customers upgrade to higher-tier plans (for example. 7 days for monthly gets extended to 14 days for yearly).
Payment Intents API
If you use the Payment Intents API, you can use the Subscriptions API to adjust trial settings.
Set up the SDKServer-side
Use our official libraries to access the Stripe API from your application:
Update the server SDKServer-side
To use this beta, first update your SDK to use the private preview API version and the checkout_
beta version header.
Dynamically update trial durationsServer-side
Create an endpoint on your server to update the trial duration for a yearly upsell on the Checkout Session. You call this from the front end in a later step.
Security tip
Client-side code runs in an environment that’s controlled by the user. A malicious user can bypass your client-side validation, intercept and modify requests, or create new requests to your server.
When creating an endpoint, we recommend the following:
- Create endpoints for specific customer interactions instead of making them generic. For example, “extend trial for yearly upgrade” instead of a general “update” action. Specific endpoints can help with writing and maintaining validation logic.
- Don’t pass session data directly from the client to your endpoint. Malicious clients can modify request data, making it an unreliable source for determining the Checkout Session state. Instead, pass the session ID to your server and use it to securely retrieve the data from the Stripe API.
You can update trial durations using either:
trial_
: An integer that represents the number of days for the trial period, or an empty string to remove the trial.period_ days trial_
: A Unix timestamp that represents when the trial should end, or an empty string to remove the trial.end
Keep in mind the following:
- The
trial_
andperiod_ days trial_
parameters are mutually exclusive. You can only specify one of them in a single update request.end - When removing a trial, use the same field that it was set with. You can only use
trial_
to remove a trial set withperiod_ days: "" trial_
. You can only useperiod_ days trial_
to remove a trial set withend: "" trial_
.end
Test the integration
Test your integration to ensure trial duration updates work correctly:
- Create a subscription Checkout Session with an initial trial period.
- Trigger your server endpoint by interacting with the UI element you created.
- Verify the trial duration is updated correctly in the Checkout Session.
- Complete the checkout to ensure the subscription is created with the correct trial settings.
Note
When testing, use Stripe’s test mode to avoid creating live subscriptions. You can verify the trial duration changes by inspecting the Checkout Session object or the created subscription.
Common testing scenarios
- Trial extension: Start with a 7-day trial, extend to 14 days, and verify the change is reflected in the UI and session object.
- Remove existing trial: Start with a 7-day trial, remove it, and verify the change is reflected in the UI and session object. Remove the trial using the same field that it was set with.
- Error handling: Test invalid requests to ensure your error handling works correctly.