Customers
delete/v1/customers/{customer}/subscriptions/{subscription_exposed_id}

Cancel a subscription

Cancels a customer’s subscription. If you set the at_period_end parameter to true, the subscription will remain active until the end of the period, at which point it will be canceled and not renewed. Otherwise, with the default false value, the subscription is terminated immediately. In either case, the customer will not be charged again for the subscription.

Note, however, that any pending invoice items that you’ve created will still be charged for at the end of the period, unless manually deleted. If you’ve set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed.

By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.

Path parameters

NameDescription
customer*
subscription_exposed_id*

Request body

FieldTypeDescription
expandarray<string>

Specifies which fields in the response should be expanded.

invoice_nowboolean

Can be set to true if at_period_end is not set to true. Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items.

prorateboolean

Can be set to true if at_period_end is not set to true. Will generate a proration invoice item that credits remaining unused time until the subscription period end.

Response

FieldTypeDescription
applicationstring | application | deleted_application

ID of the Connect Application that created the subscription.

application_fee_percentnumber

A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account.

automatic_tax*subscription_automatic_tax
3 nested fields
FieldTypeDescription
disabled_reasonstring

If Stripe disabled automatic tax, this enum describes why.

enabled*boolean

Whether Stripe automatically computes tax on this subscription.

liabilityconnect_account_reference

The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.

billing_cycle_anchor*integer (unix-time)

The reference point that aligns future billing cycle dates. It sets the day of week for week intervals, the day of month for month and year intervals, and the month of year for year intervals. The timestamp is in UTC format.

billing_cycle_anchor_configsubscriptions_resource_billing_cycle_anchor_config

The fixed values used to calculate the billing_cycle_anchor.

billing_mode*subscriptions_resource_billing_mode

The billing mode of the subscription.

3 nested fields
FieldTypeDescription
flexiblesubscriptions_resource_billing_mode_flexible

Configure behavior for flexible billing mode

type*string

Controls how prorations and invoices for subscriptions are calculated and orchestrated.

updated_atinteger (unix-time)

Details on when the current billing_mode was adopted.

billing_schedules*array<subscriptions_resource_billing_schedules>

Billing schedules for this subscription.

array item fields
FieldTypeDescription
applies_toarray<subscriptions_resource_billing_schedules_applies_to>

Specifies which subscription items the billing schedule applies to.

bill_until*subscriptions_resource_billing_schedules_bill_until
key*string

Unique identifier for the billing schedule.

billing_thresholdssubscription_billing_thresholds

Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period

cancel_atinteger (unix-time)

A date in the future at which the subscription will automatically get canceled

cancel_at_period_end*boolean

Whether this subscription will (if status=active) or did (if status=canceled) cancel at the end of the current billing period.

canceled_atinteger (unix-time)

If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancel_at_period_end, canceled_at will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state.

cancellation_detailscancellation_details

Details about why this subscription was cancelled

collection_method*string

Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as active.

created*integer (unix-time)

Time at which the object was created. Measured in seconds since the Unix epoch.

currency*string (currency)

Three-letter ISO currency code, in lowercase. Must be a supported currency.

customer*string | customer | deleted_customer

ID of the customer who owns the subscription.

customer_accountstring

ID of the account representing the customer who owns the subscription.

days_until_dueinteger

Number of days a customer has to pay invoices generated by this subscription. This value will be null for subscriptions where collection_method=charge_automatically.

default_payment_methodstring | payment_method

ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over default_source. If neither are set, invoices will use the customer's invoice_settings.default_payment_method or default_source.

default_sourcestring | bank_account | card | source

ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If default_payment_method is also set, default_payment_method will take precedence. If neither are set, invoices will use the customer's invoice_settings.default_payment_method or default_source.

default_tax_ratesarray<tax_rate>

The tax rates that will apply to any subscription item that does not have tax_rates set. Invoices created will have their default_tax_rates populated from the subscription.

array item fields
FieldTypeDescription
active*boolean

Defaults to true. When set to false, this tax rate cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set.

countrystring

Two-letter country code (ISO 3166-1 alpha-2).

created*integer (unix-time)

Time at which the object was created. Measured in seconds since the Unix epoch.

descriptionstring

An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.

display_name*string

The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page.

effective_percentagenumber

Actual/effective tax rate percentage out of 100. For tax calculations with automatic_tax[enabled]=true, this percentage reflects the rate actually used to calculate tax based on the product's taxability and whether the user is registered to collect taxes in the corresponding jurisdiction.

flat_amounttax_rate_flat_amount

The amount of the tax rate when the rate_type is flat_amount. Tax rates with rate_type percentage can vary based on the transaction, resulting in this field being null. This field exposes the amount and currency of the flat tax rate.

id*string

Unique identifier for the object.

inclusive*boolean

This specifies if the tax rate is inclusive or exclusive.

jurisdictionstring

The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer’s invoice.

jurisdiction_levelstring

The level of the jurisdiction that imposes this tax rate. Will be null for manually defined tax rates.

livemode*boolean

If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.

metadataobject

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

object*string

String representing the object's type. Objects of the same type share the same value.

percentage*number

Tax rate percentage out of 100. For tax calculations with automatic_tax[enabled]=true, this percentage includes the statutory tax rate of non-taxable jurisdictions.

rate_typestring

Indicates the type of tax rate applied to the taxable amount. This value can be null when no tax applies to the location. This field is only present for TaxRates created by Stripe Tax.

statestring

ISO 3166-2 subdivision code, without country prefix. For example, "NY" for New York, United States.

tax_typestring

The high-level tax type, such as vat or sales_tax.

descriptionstring

The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.

discounts*array<string | discount>

The discounts applied to the subscription. Subscription item discounts are applied before subscription discounts. Use expand[]=discounts to expand each discount.

ended_atinteger (unix-time)

If the subscription has ended, the date the subscription ended.

id*string

Unique identifier for the object.

invoice_settings*subscriptions_resource_subscription_invoice_settings
5 nested fields
FieldTypeDescription
account_tax_idsarray<string | tax_id | deleted_tax_id>

The account tax IDs associated with the subscription. Will be set on invoices generated by the subscription.

custom_fieldsarray<invoice_setting_custom_field>

A list of up to 4 custom fields to be displayed on the invoice.

descriptionstring

An arbitrary string attached to the object. Often useful for displaying to users.

footerstring

Footer to be displayed on the invoice.

issuer*connect_account_reference
items*object

List of subscription items, each with an attached price.

4 nested fields
FieldTypeDescription
data*array<subscription_item>

Details about each object.

array item fields
FieldTypeDescription
billed_untilinteger (unix-time)

The time period the subscription item has been billed for.

billing_thresholdssubscription_item_billing_thresholds

Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period

created*integer

Time at which the object was created. Measured in seconds since the Unix epoch.

current_period_end*integer (unix-time)

The end time of this subscription item's current billing period.

current_period_start*integer (unix-time)

The start time of this subscription item's current billing period.

discounts*array<string | discount>

The discounts applied to the subscription item. Subscription item discounts are applied before subscription discounts. Use expand[]=discounts to expand each discount.

id*string

Unique identifier for the object.

metadata*object

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

object*string

String representing the object's type. Objects of the same type share the same value.

price*price
quantityinteger

The quantity of the plan to which the customer should be subscribed.

subscription*string

The subscription this subscription_item belongs to.

tax_ratesarray<tax_rate>

The tax rates which apply to this subscription_item. When set, the default_tax_rates on the subscription do not apply to this subscription_item.

has_more*boolean

True if this list has another page of items after this one that can be fetched.

object*string

String representing the object's type. Objects of the same type share the same value. Always has the value list.

url*string

The URL where this list can be accessed.

latest_invoicestring | invoice

The most recent invoice this subscription has generated over its lifecycle (for example, when it cycles or is updated).

livemode*boolean

If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.

managed_paymentssmor_resource_managed_payments

Settings for Managed Payments for this Subscription and resulting Invoices and PaymentIntents.