# Data retention policy for test subscriptions

### Stripe automatically cancels subscriptions created in a sandbox or in test mode. This happens 90 days after the subscription is created. The subscription and related objects are deleted after a further 30 days.
---
You can disable this behavior for a test subscription in the Dashboard by clicking **Exclude from auto-cancellation** in the **Actions** menu for the subscription.
Subscriptions in live mode are **not** subject to the behavior described in this article.
### When will a test subscription be automatically canceled?
Subscriptions created in a sandbox or in test mode are automatically canceled after 90 days, unless you mark them as excluded from auto-cancellation.
The pending cancellation date is shown under **Test auto-cancellation** when viewing a test subscription in the Dashboard.
Subscriptions associated with a [test clock](https://docs.stripe.com/billing/testing/test-clocks) are automatically canceled 30 days after the test clock was created.
### What happens when a test subscription is automatically canceled?
The Subscription object will transition to `status: canceled` and a `customer.subscription.deleted` event will be created, the same as happens when a subscription is explicitly canceled.
For subscriptions  not associated with a test clock, the [`cancellation_details.reason` attribute](https://docs.stripe.com/api/subscriptions/object#subscription_object-cancellation_details-reason) will be updated according to your API version:
- 2026-03-25.dahlia or newer: `canceled_by_retention_policy`
- Older versions: `cancellation_requested`
### When will a test subscription be deleted?
Subscriptions associated with a test clock aren't deleted, and remain visible in your account after auto-cancellation.
Once a subscription has been automatically canceled by the test data retention policy, it will be permanently deleted from your acccount after a further 30 days, along with any associated objects. However, within this 30-day period after deletion, you can prevent the automated deletion by marking the subscription as exempt on the Dashboard.
Subscriptions created in live mode are never deleted during the lifetime of your Stripe account, and are subject to Stripe's overall [data retention policy](https://stripe.com/legal/privacy-center#how-long-will-stripe-keep-my-data).
### What happens when a test subscription is deleted?
When a test subscription is deleted, the Subscription object and any associated objects are permanently deleted from your account.
These types of object are deleted, if they were related to the subscription:
* Subscription
* SubscriptionSchedule
* Invoice
* InvoiceItem
* InvoicePayment
* CheckoutSession
* CreditNote
* Discount
* UsageRecord
* Quote
After deletion, these objects will no longer be visible on your Dashboard or using the API, and cannot be recovered.
If the Subscription produced any payments, the corresponding PaymentIntent, Charge, and BalanceTransaction objects will still exist. However, any invoice-related attributes on PaymentIntent or Charge objects will have a null value to reflect that the corresponding objects no longer exist.
No events are generated when a subscription and its associated objects are automatically deleted.
### What happens when a test subscription is excluded from auto-cancellation?
Use **Exclude from auto-cancellation**on a subscription in the Dashboard to prevent that subscription from being automatically canceled or deleted in future.
However, you can remove this exemption by selecting the **Revert to auto-cancellation** option from the **Actions** menu in the Dashboard. The test subscription will immediately be subject to automatic cancellation and deletion, according to the test data retention policy.
### Why should a test subscription be excluded from auto-cancellation?
You can mark a test subscription as exempt from the test data retention policy if you need to test subscription behavior over a long period of time. However, test clocks are the recommended way to achieve this.
If you’re building a demonstration where testers should be able to experience how billing feels to a user in real time, then the test subscription would need to be excluded from auto-cancellation.
Here are some questions you might ask under this kind of testing scenario:
* Did the user have sufficient notice to update their payment method?
* Did the user feel like they had a long enough free trial to convert to a paid subscription?
* Did the user use this application frequently enough or did they forget about their subscription?
* Did the user’s access to the application get revoked in a reasonable period of time after non-payment?
### How many test subscriptions can be excluded from auto-cancellation?
An account can have up to 50 subscriptions marked as excluded from auto-cancellation at any one time.
Use the **Revert to auto-cancellation** option on a subscription in the Dashboard to make it no longer exempt from auto-cancellation and deletion.
### When did this policy come into effect?
The test data retention policy was enabled on:
- November 16, 2022 for Stripe accounts created on or after November 16, 2022.
- February 1, 2023 for Stripe accounts created before November 16, 2022.