---
title: "Create a portal session"
method: POST
path: "/v1/billing_portal/sessions"
---

# Create a portal session

`POST /v1/billing_portal/sessions`

Creates a session of the customer portal.

## Response `200`

Successful response.

- BillingPortalSession — The Billing customer portal is a Stripe-hosted UI for subscription and billing management. A portal configuration describes the functionality and features that you want to provide to your customers through the portal. A portal session describes the instantiation of the customer portal for a particular customer. By visiting the session's URL, the customer can manage their subscriptions and billing details. For security reasons, sessions are short-lived and will expire if the customer does not visit the URL. Create sessions on-demand when customers intend to manage their subscriptions and billing details. Related guide: [Customer management](/customer-management)
  - `configuration` union, required — The configuration used by this session, describing the features available.
    - string
    - BillingPortalConfiguration — A portal configuration describes the functionality and behavior you embed in a portal session. Related guide: [Configure the customer portal](/customer-management/configure-portal).
      - `active` boolean, required — Whether the configuration is active and can be used to create portal sessions.
      - `application` union — ID of the Connect Application that created the configuration.
        - string
        - Application
          - `id` string, required — Unique identifier for the object.
          - `name` string, nullable — The name of the application.
          - `object` 'application', required — String representing the object's type. Objects of the same type share the same value.
        - DeletedApplication
          - `deleted` true, required — Always true for a deleted object
          - `id` string, required — Unique identifier for the object.
          - `name` string, nullable — The name of the application.
          - `object` 'application', required — String representing the object's type. Objects of the same type share the same value.
      - `business_profile` PortalBusinessProfile, required
        - `headline` string, nullable — The messaging shown to customers in the portal.
        - `privacy_policy_url` string, nullable — A link to the business’s publicly available privacy policy.
        - `terms_of_service_url` string, nullable — A link to the business’s publicly available terms of service.
      - `created` integer, required — Time at which the object was created. Measured in seconds since the Unix epoch.
      - `default_return_url` string, nullable — The default URL to redirect customers to when they click on the portal's link to return to your website. This can be [overridden](https://docs.stripe.com/api/customer_portal/sessions/create#create_portal_session-return_url) when creating the session.
      - `features` PortalFeatures, required
        - `customer_update` PortalCustomerUpdate, required
          - `allowed_updates` string[], required — The types of customer updates that are supported. When empty, customers are not updateable.
          - `enabled` boolean, required — Whether the feature is enabled.
        - `invoice_history` PortalInvoiceList, required
          - `enabled` boolean, required — Whether the feature is enabled.
        - `payment_method_update` PortalPaymentMethodUpdate, required
          - `enabled` boolean, required — Whether the feature is enabled.
          - `payment_method_configuration` string, nullable — The [Payment Method Configuration](/api/payment_method_configurations) to use for this portal session. When specified, customers will be able to update their payment method to one of the options specified by the payment method configuration. If not set, the default payment method configuration is used.
        - `subscription_cancel` PortalSubscriptionCancel, required
          - `cancellation_reason` PortalSubscriptionCancellationReason, required
            - `enabled` boolean, required — Whether the feature is enabled.
            - `options` string[], required — Which cancellation reasons will be given as options to the customer.
          - `enabled` boolean, required — Whether the feature is enabled.
          - `mode` 'at_period_end' | 'immediately', required — Whether to cancel subscriptions immediately or at the end of the billing period.
          - `proration_behavior` 'always_invoice' | 'create_prorations' | 'none', required — Whether to create prorations when canceling subscriptions. Possible values are `none` and `create_prorations`.
        - `subscription_update` PortalSubscriptionUpdate, required
          - `billing_cycle_anchor` 'now' | 'unchanged', nullable — Determines the value to use for the billing cycle anchor on subscription updates. Valid values are `now` or `unchanged`, and the default value is `unchanged`. Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). For more information, see the billing cycle [documentation](https://docs.stripe.com/billing/subscriptions/billing-cycle).
          - `default_allowed_updates` string[], required — The types of subscription updates that are supported for items listed in the `products` attribute. When empty, subscriptions are not updateable.
          - `enabled` boolean, required — Whether the feature is enabled.
          - `products` PortalSubscriptionUpdateProduct[], nullable — The list of up to 10 products that support subscription updates.
            - `adjustable_quantity` PortalSubscriptionUpdateProductAdjustableQuantity, required
              - …
            - `prices` string[], required — The list of price IDs which, when subscribed to, a subscription can be updated.
            - `product` string, required — The product ID.
          - `proration_behavior` 'always_invoice' | 'create_prorations' | 'none', required — Determines how to handle prorations resulting from subscription updates. Valid values are `none`, `create_prorations`, and `always_invoice`. Defaults to a value of `none` if you don't set it during creation.
          - `schedule_at_period_end` PortalResourceScheduleUpdateAtPeriodEnd, required
            - `conditions` PortalResourceScheduleUpdateAtPeriodEndCondition[], required — List of conditions. When any condition is true, an update will be scheduled at the end of the current period.
              - …
          - `trial_update_behavior` 'continue_trial' | 'end_trial', required — Determines how handle updates to trialing subscriptions. Valid values are `end_trial` and `continue_trial`. Defaults to a value of `end_trial` if you don't set it during creation.
      - `id` string, required — Unique identifier for the object.
      - `is_default` boolean, required — Whether the configuration is the default. If `true`, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session.
      - `livemode` boolean, required — If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
      - `login_page` PortalLoginPage, required
        - `enabled` boolean, required — If `true`, a shareable `url` will be generated that will take your customers to a hosted login page for the customer portal. If `false`, the previously generated `url`, if any, will be deactivated.
        - `url` string, nullable — A shareable URL to the hosted portal login page. Your customers will be able to log in with their [email](https://docs.stripe.com/api/customers/object#customer_object-email) and receive a link to their customer portal.
      - `metadata` object, nullable — Set 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.
      - `name` string, nullable — The name of the configuration.
      - `object` 'billing_portal.configuration', required — String representing the object's type. Objects of the same type share the same value.
      - `updated` integer, required — Time at which the object was last updated. Measured in seconds since the Unix epoch.
  - `created` integer, required — Time at which the object was created. Measured in seconds since the Unix epoch.
  - `customer` string, required — The ID of the customer for this session.
  - `customer_account` string, nullable — The ID of the account for this session.
  - `flow` PortalFlowsFlow
    - `after_completion` PortalFlowsFlowAfterCompletion, required
      - `hosted_confirmation` PortalFlowsAfterCompletionHostedConfirmation
        - `custom_message` string, nullable — A custom message to display to the customer after the flow is completed.
      - `redirect` PortalFlowsAfterCompletionRedirect
        - `return_url` string, required — The URL the customer will be redirected to after the flow is completed.
      - `type` 'hosted_confirmation' | 'portal_homepage' | 'redirect', required — The specified type of behavior after the flow is completed.
    - `subscription_cancel` PortalFlowsFlowSubscriptionCancel
      - `retention` PortalFlowsRetention
        - `coupon_offer` PortalFlowsCouponOffer
          - `coupon` string, required — The ID of the coupon to be offered.
        - `type` 'coupon_offer', required — Type of retention strategy that will be used.
      - `subscription` string, required — The ID of the subscription to be canceled.
    - `subscription_update` PortalFlowsFlowSubscriptionUpdate
      - `subscription` string, required — The ID of the subscription to be updated.
    - `subscription_update_confirm` PortalFlowsFlowSubscriptionUpdateConfirm
      - `discounts` PortalFlowsSubscriptionUpdateConfirmDiscount[], nullable — The coupon or promotion code to apply to this subscription update.
        - `coupon` string, nullable — The ID of the coupon to apply to this subscription update.
        - `promotion_code` string, nullable — The ID of a promotion code to apply to this subscription update.
      - `items` PortalFlowsSubscriptionUpdateConfirmItem[], required — The [subscription item](https://docs.stripe.com/api/subscription_items) to be updated through this flow. Currently, only up to one may be specified and subscriptions with multiple items are not updatable.
        - `id` string, nullable — The ID of the [subscription item](https://docs.stripe.com/api/subscriptions/object#subscription_object-items-data-id) to be updated.
        - `price` string, nullable — The price the customer should subscribe to through this flow. The price must also be included in the configuration's [`features.subscription_update.products`](https://docs.stripe.com/api/customer_portal/configuration#portal_configuration_object-features-subscription_update-products).
        - `quantity` integer — [Quantity](https://docs.stripe.com/subscriptions/quantities) for this item that the customer should subscribe to through this flow.
      - `subscription` string, required — The ID of the subscription to be updated.
    - `type` 'payment_method_update' | 'subscription_cancel' | 'subscription_update' | 'subscription_update_confirm', required — Type of flow that the customer will go through.
  - `id` string, required — Unique identifier for the object.
  - `livemode` boolean, required — If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
  - `locale` 'auto' | 'bg' | 'cs' | 'da' | 'de' | 'el' | 'en' | 'en-AU' | 'en-CA' | 'en-GB' | 'en-IE' | 'en-IN' | 'en-NZ' | 'en-SG' | 'es' | 'es-419' | 'et' | 'fi' | 'fil' | 'fr' | 'fr-CA' | 'hr' | 'hu' | 'id' | 'it' | 'ja' | 'ko' | 'lt' | 'lv' | 'ms' | 'mt' | 'nb' | 'nl' | 'pl' | 'pt' | 'pt-BR' | 'ro' | 'ru' | 'sk' | 'sl' | 'sv' | 'th' | 'tr' | 'vi' | 'zh' | 'zh-HK' | 'zh-TW', nullable — The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customer’s `preferred_locales` or browser’s locale is used.
  - `object` 'billing_portal.session', required — String representing the object's type. Objects of the same type share the same value.
  - `on_behalf_of` string, nullable — The account for which the session was created on behalf of. When specified, only subscriptions and invoices with this `on_behalf_of` account appear in the portal. For more information, see the [docs](https://docs.stripe.com/connect/separate-charges-and-transfers#settlement-merchant). Use the [Accounts API](https://docs.stripe.com/api/accounts/object#account_object-settings-branding) to modify the `on_behalf_of` account's branding settings, which the portal displays.
  - `return_url` string, nullable — The URL to redirect customers to when they click on the portal's link to return to your website.
  - `url` string, required — The short-lived URL of the session that gives customers access to the customer portal.

## Other responses

- `default` — Error response.

---

[API](https://skmtc.net/stripe/apis/stripe-api.md) · [All operations](https://skmtc.net/stripe/apis/stripe-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/stripe/stripe-api/versions/707de00b0616/schema)
