Skip to content

Stripe: Create a subscription — customers post Customers Customer Subscriptions

Stripe customers.postCustomersCustomerSubscriptions: arguments, response, policy and SDK examples.

← Customers operations · Get started

Operation stripe.postcustomerscustomersubscriptions

Provider route: POST /v1/customers/{customer}/subscriptions. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/stripe with npm, or alter-sdk-stripe with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { StripeIntegration } from "@alter-ai/stripe";
async function execute(input: Parameters<StripeIntegration["customers"]["postCustomersCustomerSubscriptions"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new StripeIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.customers.postCustomersCustomerSubscriptions(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_stripe import StripeIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = StripeIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.customers.post_customers_customer_subscriptions(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.customerstringRequired within parentMaximum length: 5000
headersobjectOptionalAdditional keys: not allowed
headers.Idempotency-KeystringOptionalMinimum length: 1
Maximum length: 255
bodyobjectOptionalAdditional keys: not allowed
body.add_invoice_itemsarrayOptionalA list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. You may pass up to 20 items.
body.add_invoice_items[]ModelEach itemExpand Update a subscription — request body — body add invoice items item
body.application_fee_percentJSONOptionalA 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. The request must be made by a platform account on a connected account in order to set an application fee percentage. For more information, see the application fees [documentation](https://stripe.com/docs/connect/subscriptions#collecting-fees-on-subscriptions).
body.application_fee_percent (anyOf 1)numberAlternative
body.application_fee_percent (anyOf 2)stringAlternativeOne of:
body.automatic_taxobjectOptionalAutomatic tax settings for this subscription.
body.automatic_tax.enabledbooleanRequired within parent
body.automatic_tax.liabilityobjectOptional
body.automatic_tax.liability.accountstringOptional
body.automatic_tax.liability.typestringRequired within parentOne of: account, self
body.backdate_start_dateintegerOptionalA past timestamp to backdate the subscription’s start date to. If set, the first invoice will contain line items for the timespan between the start date and the current time. Can be combined with trials and the billing cycle anchor.
Format: unix-time
body.billing_cycle_anchorintegerOptionalA future timestamp in UTC format to anchor the subscription’s [billing cycle](https://docs.stripe.com/subscriptions/billing-cycle). The anchor is 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.
Format: unix-time
body.billing_thresholdsJSONOptionalDefine thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds.
body.billing_thresholds (anyOf 1)objectAlternative
body.billing_thresholds (anyOf 1).amount_gteintegerOptional
body.billing_thresholds (anyOf 1).reset_billing_cycle_anchorbooleanOptional
body.billing_thresholds (anyOf 2)stringAlternativeOne of:
body.cancel_atJSONOptionalA timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. If set during a future period, this will always cause a proration for that period.
body.cancel_at (anyOf 1)integerAlternativeFormat: unix-time
body.cancel_at (anyOf 2)stringAlternativeOne of: max_billed_until, max_period_end, min_period_end
body.cancel_at_period_endbooleanOptionalIndicate whether this subscription should cancel at the end of the current period (`current_period_end`). Defaults to `false`.
body.collection_methodstringOptionalEither `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`. Defaults to `charge_automatically`.
One of: charge_automatically, send_invoice
body.currencystringOptionalThree-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
Format: currency
body.days_until_dueintegerOptionalNumber of days a customer has to pay invoices generated by this subscription. Valid only for subscriptions where `collection_method` is set to `send_invoice`.
body.default_payment_methodstringOptionalID 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](https://docs.stripe.com/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://docs.stripe.com/api/customers/object#customer_object-default_source).
Maximum length: 5000
body.default_sourcestringOptionalID 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](https://docs.stripe.com/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://docs.stripe.com/api/customers/object#customer_object-default_source).
Maximum length: 5000
body.default_tax_ratesJSONOptionalThe 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.
body.default_tax_rates (anyOf 1)arrayAlternative
body.default_tax_rates (anyOf 1)[]stringEach itemMaximum length: 5000
body.default_tax_rates (anyOf 2)stringAlternativeOne of:
body.discountsJSONOptionalThe coupons to redeem into discounts for the subscription. If not specified or empty, inherits the discount from the subscription’s customer.
body.discounts (anyOf 1)arrayAlternative
body.discounts (anyOf 1)[]objectEach item
body.discounts (anyOf 1)[].couponstringOptionalMaximum length: 5000
body.discounts (anyOf 1)[].discountstringOptionalMaximum length: 5000
body.discounts (anyOf 1)[].promotion_codestringOptionalMaximum length: 5000
body.discounts (anyOf 2)stringAlternativeOne of:
body.expandarrayOptionalSpecifies which fields in the response should be expanded.
body.expand[]stringEach itemMaximum length: 5000
body.invoice_settingsModelOptionalExpand Create a subscription — subscriptions post Subscriptions — request body — body invoice settings
body.itemsarrayOptionalA list of up to 20 subscription items, each with an attached price.
body.items[]ModelEach itemExpand Create a subscription — subscriptions post Subscriptions — request body — body items item
body.metadataJSONOptionalSet of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`.
body.metadata (anyOf 1)objectAlternativeAdditional keys: see wildcard field
body.metadata (anyOf 1).*stringAdditional keys
body.metadata (anyOf 2)stringAlternativeOne of:
body.off_sessionbooleanOptionalIndicates if a customer is on or off-session while an invoice payment is attempted. Defaults to `false` (on-session).
body.payment_behaviorstringOptionalControls how Stripe handles the first invoice when payment is required and `collection_method=charge_automatically`. Subscriptions with `collection_method=send_invoice` are automatically activated regardless of the first Invoice status.
One of: allow_incomplete, default_incomplete, error_if_incomplete, pending_if_incomplete
body.payment_settingsModelOptionalExpand Update a subscription — request body — body payment settings
body.pending_invoice_item_intervalJSONOptionalSpecifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](/api/invoices/create) for the given subscription at the specified interval.
body.pending_invoice_item_interval (anyOf 1)objectAlternative
body.pending_invoice_item_interval (anyOf 1).intervalstringRequired within parentOne of: day, month, week, year
body.pending_invoice_item_interval (anyOf 1).interval_countintegerOptional
body.pending_invoice_item_interval (anyOf 2)stringAlternativeOne of:
body.proration_behaviorstringOptionalDetermines how to handle [prorations](https://docs.stripe.com/billing/subscriptions/prorations) resulting from the `billing_cycle_anchor`. If no value is passed, the default is `create_prorations`.
One of: always_invoice, create_prorations, none
body.transfer_dataobjectOptionalIf specified, the funds from the subscription’s invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges.
body.transfer_data.amount_percentnumberOptional
body.transfer_data.destinationstringRequired within parent
body.trial_endJSONOptionalUnix timestamp representing the end of the trial period the customer will get before being charged for the first time. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special value `now` can be provided to end the customer’s trial immediately. Can be at most two years from `billing_cycle_anchor`. See [Using trial periods on subscriptions](https://docs.stripe.com/billing/subscriptions/trials/free-trials) to learn more.
body.trial_end (anyOf 1)stringAlternativeOne of: now
Maximum length: 5000
body.trial_end (anyOf 2)integerAlternativeFormat: unix-time
body.trial_from_planbooleanOptionalIndicates if a plan’s `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](https://docs.stripe.com/billing/subscriptions/trials/free-trials) to learn more.
body.trial_period_daysintegerOptionalInteger representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. See [Using trial periods on subscriptions](https://docs.stripe.com/billing/subscriptions/trials/free-trials) to learn more.
body.trial_settingsobjectOptionalSettings related to subscription trials.
body.trial_settings.end_behaviorobjectRequired within parent
body.trial_settings.end_behavior.billing_cycle_anchorstringOptionalOne of: now, unchanged
body.trial_settings.end_behavior.missing_payment_methodstringOptionalOne of: cancel, create_invoice, pause

Referenced models: Update a subscription — request body — body add invoice items item, Create a subscription — subscriptions post Subscriptions — request body — body invoice settings, Create a subscription — subscriptions post Subscriptions — request body — body items item, Update a subscription — request body — body payment settings

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Pause a subscription — response body

Referenced models: Pause a subscription — response body

711 more schemas are linked from the tables above, on the schema pages.

Update a subscription — request body — body add invoice items item
FieldTypePresenceDescription and constraints
$objectRoot
discountablebooleanOptional
discountsarrayOptional
discounts[]objectEach item
discounts[].couponstringOptionalMaximum length: 5000
discounts[].discountstringOptionalMaximum length: 5000
discounts[].promotion_codestringOptionalMaximum length: 5000
metadataobjectOptionalAdditional keys: see wildcard field
metadata.*stringAdditional keys
periodobjectOptional
period.endobjectRequired within parent
period.end.timestampintegerOptionalFormat: unix-time
period.end.typestringRequired within parentOne of: min_item_period_end, timestamp
period.startobjectRequired within parent
period.start.timestampintegerOptionalFormat: unix-time
period.start.typestringRequired within parentOne of: max_item_period_start, now, timestamp
pricestringOptionalMaximum length: 5000
price_dataobjectOptional
price_data.currencystringRequired within parentFormat: currency
price_data.productstringRequired within parentMaximum length: 5000
price_data.tax_behaviorstringOptionalOne of: exclusive, inclusive, unspecified
price_data.unit_amountintegerOptional
price_data.unit_amount_decimalstringOptionalFormat: decimal
quantityintegerOptional
tax_ratesJSONOptional
tax_rates (anyOf 1)arrayAlternative
tax_rates (anyOf 1)[]stringEach itemMaximum length: 5000
tax_rates (anyOf 2)stringAlternativeOne of:
Create a subscription — subscriptions post Subscriptions — request body — body invoice settings
FieldTypePresenceDescription and constraints
$objectRootAll invoices will be billed using the specified settings.
account_tax_idsJSONOptional
account_tax_ids (anyOf 1)arrayAlternative
account_tax_ids (anyOf 1)[]stringEach itemMaximum length: 5000
account_tax_ids (anyOf 2)stringAlternativeOne of:
custom_fieldsJSONOptional
custom_fields (anyOf 1)arrayAlternative
custom_fields (anyOf 1)[]objectEach item
custom_fields (anyOf 1)[].namestringRequired within parentMaximum length: 40
custom_fields (anyOf 1)[].valuestringRequired within parentMaximum length: 140
custom_fields (anyOf 2)stringAlternativeOne of:
descriptionstringOptionalMaximum length: 1500
footerstringOptionalMaximum length: 5000
issuerobjectOptional
issuer.accountstringOptional
issuer.typestringRequired within parentOne of: account, self
Create a subscription — subscriptions post Subscriptions — request body — body items item
FieldTypePresenceDescription and constraints
$objectRoot
billing_thresholdsJSONOptional
billing_thresholds (anyOf 1)objectAlternative
billing_thresholds (anyOf 1).usage_gteintegerRequired within parent
billing_thresholds (anyOf 2)stringAlternativeOne of:
current_trialobjectOptional
current_trial.trial_offerstringRequired within parentMaximum length: 5000
discountsJSONOptional
discounts (anyOf 1)arrayAlternative
discounts (anyOf 1)[]objectEach item
discounts (anyOf 1)[].couponstringOptionalMaximum length: 5000
discounts (anyOf 1)[].discountstringOptionalMaximum length: 5000
discounts (anyOf 1)[].promotion_codestringOptionalMaximum length: 5000
discounts (anyOf 2)stringAlternativeOne of:
metadataobjectOptionalAdditional keys: see wildcard field
metadata.*stringAdditional keys
pricestringOptionalMaximum length: 5000
price_dataModelOptionalExpand Update a subscription — request body — body items item price data
quantityintegerOptional
tax_ratesJSONOptional
tax_rates (anyOf 1)arrayAlternative
tax_rates (anyOf 1)[]stringEach itemMaximum length: 5000
tax_rates (anyOf 2)stringAlternativeOne of:

Referenced models: Update a subscription — request body — body items item price data

Update a subscription — request body — body payment settings
FieldTypePresenceDescription and constraints
$objectRootPayment settings to pass to invoices created by the subscription.
payment_method_optionsModelOptionalExpand Update a subscription — request body — body payment settings payment method options
payment_method_typesJSONOptional
payment_method_types (anyOf 1)arrayAlternative
payment_method_types (anyOf 1)[]stringEach itemOne of: ach_credit_transfer, ach_debit, acss_debit, affirm, alipay, amazon_pay, au_becs_debit, bacs_debit, bancontact, billie, blik, boleto, card, cashapp, crypto, custom, customer_balance, eps, fpx, giropay, grabpay, ideal, jp_credit_transfer, kakao_pay, klarna, konbini, kr_card, link, mb_way, multibanco, naver_pay, nz_bank_account, p24, pay_by_bank, payco, paynow, paypal, payto, pix, promptpay, revolut_pay, satispay, sepa_credit_transfer, sepa_debit, sofort, swish, twint, upi, us_bank_account, wechat_pay
payment_method_types (anyOf 2)stringAlternativeOne of:
save_default_payment_methodstringOptionalOne of: off, on_subscription

Referenced models: Update a subscription — request body — body payment settings payment method options

PostApplicationFeesIdRefund — response body — application / object: application
FieldTypePresenceDescription and constraints
$objectRoot
idstringRequired within parentUnique identifier for the object.
Maximum length: 5000
nameJSONOptional
name (anyOf 1)stringAlternativeThe name of the application.
Maximum length: 5000
name (anyOf 2)nullAlternative
objectstringRequired within parentString representing the object's type. Objects of the same type share the same value.
Known values: application
Pause a subscription — response body — cancellation details Details about why this subscription was cancelled comment, feedback, feedback option, reason
FieldTypePresenceDescription and constraints
$objectRoot
commentJSONOptional
comment (anyOf 1)stringAlternativeAdditional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.
Maximum length: 5000
comment (anyOf 2)nullAlternative
feedbackJSONOptional
feedback (anyOf 1)stringAlternativeThe customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user.
Known values: customer_service, low_quality, missing_features, other, switched_service, too_complex, too_expensive, unused
feedback (anyOf 2)nullAlternative
feedback_optionJSONOptional
feedback_option (anyOf 1)JSONAlternativeCustomized feedback options that provide deeper insight into why the subscription was canceled, if the subscription was canceled explicitly by the user.
feedback_option (anyOf 1) (anyOf 1)stringAlternativeMaximum length: 5000
feedback_option (anyOf 1) (anyOf 2)ModelAlternativeExpand Create a feedback option — response body
feedback_option (anyOf 2)nullAlternative
reasonJSONOptional
reason (anyOf 1)stringAlternativeWhy this subscription was canceled.
Known values: canceled_by_retention_policy, cancellation_requested, payment_disputed, payment_failed
reason (anyOf 2)nullAlternative

Referenced models: Create a feedback option — response body

Accept a quote — response body — application / value / deleted: True, object: application
FieldTypePresenceDescription and constraints
$objectRoot
deletedbooleanRequired within parentAlways true for a deleted object
Known values: True
idstringRequired within parentUnique identifier for the object.
Maximum length: 5000
nameJSONOptional
name (anyOf 1)stringAlternativeThe name of the application.
Maximum length: 5000
name (anyOf 2)nullAlternative
objectstringRequired within parentString representing the object's type. Objects of the same type share the same value.
Known values: application
Cancel a Setup Intent — response body — managed payments value enabled
FieldTypePresenceDescription and constraints
$objectRoot
enabledbooleanRequired within parentSet to `true` to enable [Managed Payments](https://docs.stripe.com/payments/managed-payments), Stripe's merchant of record solution, for this session.

SDK function policy ID: stripe.postcustomerscustomersubscriptions. Catalog operation: PostCustomersCustomerSubscriptions. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"Stripe-Version": "2026-09-30.endive"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.