Skip to content

Stripe: Create a portal session

Stripe billingPortal.postBillingPortalSessions: arguments, response, policy and SDK examples.

← Billing portal operations · Get started

Operation stripe.postbillingportalsessions

Provider route: POST /v1/billing_portal/sessions. 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["billingPortal"]["postBillingPortalSessions"]>[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.billingPortal.postBillingPortalSessions(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.billing_portal.post_billing_portal_sessions(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
headersobjectOptionalAdditional keys: not allowed
headers.Idempotency-KeystringOptionalMinimum length: 1
Maximum length: 255
bodyobjectOptionalAdditional keys: not allowed
body.configurationstringOptionalThe ID of an existing [configuration](https://docs.stripe.com/api/customer_portal/configurations) to use for this session, describing its functionality and features. If not specified, the session uses the default configuration.
Maximum length: 5000
body.customerstringOptionalThe ID of an existing customer.
Maximum length: 5000
body.customer_accountstringOptionalThe ID of an existing account.
Maximum length: 5000
body.expandarrayOptionalSpecifies which fields in the response should be expanded.
body.expand[]stringEach itemMaximum length: 5000
body.flow_dataobjectOptionalInformation about a specific flow for the customer to go through. See the [docs](https://docs.stripe.com/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows.
body.flow_data.after_completionobjectOptional
body.flow_data.after_completion.hosted_confirmationobjectOptional
body.flow_data.after_completion.hosted_confirmation.custom_messagestringOptionalMaximum length: 500
body.flow_data.after_completion.redirectobjectOptional
body.flow_data.after_completion.redirect.return_urlstringRequired within parent
body.flow_data.after_completion.typestringRequired within parentOne of: hosted_confirmation, portal_homepage, redirect
body.flow_data.subscription_cancelobjectOptional
body.flow_data.subscription_cancel.retentionobjectOptional
body.flow_data.subscription_cancel.retention.coupon_offerobjectRequired within parent
body.flow_data.subscription_cancel.retention.coupon_offer.couponstringRequired within parentMaximum length: 5000
body.flow_data.subscription_cancel.retention.typestringRequired within parentOne of: coupon_offer
body.flow_data.subscription_cancel.subscriptionstringRequired within parentMaximum length: 5000
body.flow_data.subscription_updateobjectOptional
body.flow_data.subscription_update.subscriptionstringRequired within parentMaximum length: 5000
body.flow_data.subscription_update_confirmobjectOptional
body.flow_data.subscription_update_confirm.discountsarrayOptional
body.flow_data.subscription_update_confirm.discounts[]objectEach item
body.flow_data.subscription_update_confirm.discounts[].couponstringOptionalMaximum length: 5000
body.flow_data.subscription_update_confirm.discounts[].promotion_codestringOptionalMaximum length: 5000
body.flow_data.subscription_update_confirm.itemsarrayRequired within parent
body.flow_data.subscription_update_confirm.items[]objectEach item
body.flow_data.subscription_update_confirm.items[].idstringRequired within parentMaximum length: 5000
body.flow_data.subscription_update_confirm.items[].pricestringOptionalMaximum length: 5000
body.flow_data.subscription_update_confirm.items[].quantityintegerOptional
body.flow_data.subscription_update_confirm.subscriptionstringRequired within parentMaximum length: 5000
body.flow_data.typestringRequired within parentOne of: customer_update, payment_method_update, subscription_cancel, subscription_update, subscription_update_confirm
body.localestringOptionalThe 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.
One of: 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
body.on_behalf_ofstringOptionalThe `on_behalf_of` account to use for this session. 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.
body.return_urlstringOptionalThe default URL to redirect customers to when they click on the portal’s link to return to your website.

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

FieldTypePresenceDescription and constraints
$ModelRootExpand Create a portal session — response body

Referenced models: Create a portal session — response body

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

Create a portal session — response body
FieldTypePresenceDescription and constraints
$objectRootThe 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)
configurationJSONRequired within parentThe configuration used by this session, describing the features available.
configuration (anyOf 1)stringAlternativeMaximum length: 5000
configuration (anyOf 2)ModelAlternativeExpand Create a portal configuration — response body
createdJSONRequired within parent
created (anyOf 1)integerAlternativeTime at which the object was created. Measured in seconds since the Unix epoch.
Format: unix-time
created (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
customerstringRequired within parentThe ID of the customer for this session.
Maximum length: 5000
customer_accountJSONOptional
customer_account (anyOf 1)stringAlternativeThe ID of the account for this session.
Maximum length: 5000
customer_account (anyOf 2)nullAlternative
flowJSONOptional
flow (anyOf 1)JSONAlternativeInformation about a specific flow for the customer to go through. See the [docs](https://docs.stripe.com/customer-management/portal-deep-links) to learn more about using customer portal deep links and flows.
flow (anyOf 1) (anyOf 1)ModelAlternativeExpand Create a portal session — response body — flow value after completion, customer update, subscription cancel, subscription update, subscription update confirm, type
flow (anyOf 2)nullAlternative
idstringRequired within parentUnique identifier for the object.
Maximum length: 5000
livemodebooleanRequired within parentIf the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
localeJSONOptional
locale (anyOf 1)stringAlternativeThe 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.
Known values: 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
locale (anyOf 2)nullAlternative
objectstringRequired within parentString representing the object's type. Objects of the same type share the same value.
Known values: billing_portal.session
on_behalf_ofJSONOptional
on_behalf_of (anyOf 1)stringAlternativeThe 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.
Maximum length: 5000
on_behalf_of (anyOf 2)nullAlternative
return_urlJSONOptional
return_url (anyOf 1)stringAlternativeThe URL to redirect customers to when they click on the portal's link to return to your website.
Maximum length: 5000
return_url (anyOf 2)nullAlternative
urlstringRequired within parentThe short-lived URL of the session that gives customers access to the customer portal.
Maximum length: 5000

Referenced models: Create a portal configuration — response body, Create a portal session — response body — flow value after completion, customer update, subscription cancel, subscription update, subscription update confirm, type

Create a portal configuration — response body
FieldTypePresenceDescription and constraints
$objectRootA portal configuration describes the functionality and behavior you embed in a portal session. Related guide: [Configure the customer portal](/customer-management/configure-portal).
activebooleanRequired within parentWhether the configuration is active and can be used to create portal sessions.
applicationJSONOptional
application (anyOf 1)JSONAlternativeID of the Connect Application that created the configuration.
application (anyOf 1) (anyOf 1)stringAlternativeMaximum length: 5000
application (anyOf 1) (anyOf 2)ModelAlternativeExpand PostApplicationFeesIdRefund — response body — application / object: application
application (anyOf 1) (anyOf 3)ModelAlternativeExpand Accept a quote — response body — application / value / deleted: True, object: application
application (anyOf 2)nullAlternative
business_profileModelRequired within parentExpand Create a portal configuration — response body — business profile
createdJSONRequired within parent
created (anyOf 1)integerAlternativeTime at which the object was created. Measured in seconds since the Unix epoch.
Format: unix-time
created (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
default_return_urlJSONOptional
default_return_url (anyOf 1)stringAlternativeThe 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.
Maximum length: 5000
default_return_url (anyOf 2)nullAlternative
featuresModelRequired within parentExpand Create a portal configuration — response body — features
idstringRequired within parentUnique identifier for the object.
Maximum length: 5000
is_defaultbooleanRequired within parentWhether 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.
livemodebooleanRequired within parentIf the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
login_pageModelRequired within parentExpand Create a portal configuration — response body — login page
metadataJSONOptional
metadata (anyOf 1)objectAlternativeSet 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.
Additional keys: see wildcard field
metadata (anyOf 1).*stringAdditional keysMaximum length: 500
metadata (anyOf 2)nullAlternative
nameJSONOptional
name (anyOf 1)stringAlternativeThe name of the configuration.
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: billing_portal.configuration
updatedJSONRequired within parent
updated (anyOf 1)integerAlternativeTime at which the object was last updated. Measured in seconds since the Unix epoch.
Format: unix-time
updated (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$

Referenced models: PostApplicationFeesIdRefund — response body — application / object: application, Accept a quote — response body — application / value / deleted: True, object: application, Create a portal configuration — response body — business profile, Create a portal configuration — response body — features, Create a portal configuration — response body — login page

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
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

SDK function policy ID: stripe.postbillingportalsessions. Catalog operation: PostBillingPortalSessions. 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.