The Customer Portal Session object 

Attributes

  • idstring

    Unique identifier for the object.

  • objectstring

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

  • configurationstringExpandable

    The configuration used by this session, describing the features available.

  • createdtimestamp

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

  • customerstring

    The ID of the customer for this session.

  • flownullable object

    Information about a specific flow for the customer to go through. See the docs to learn more about using customer portal deep links and flows.

  • livemodeboolean

    Has the value true if the object exists in live mode or the value false if the object exists in test mode.

  • localenullable enum

    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.

  • on_behalf_ofnullable stringConnect only

    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. Use the Accounts API to modify the on_behalf_of account’s branding settings, which the portal displays.

  • return_urlnullable string

    The URL to redirect customers to when they click on the portal’s link to return to your website.

  • urlstring

    The short-lived URL of the session that gives customers access to the customer portal.

The Customer Portal Session object
{
"id": "bps_1MrSjzLkdIwHu7ixex0IvU9b",
"object": "billing_portal.session",
"configuration": "bpc_1MAhNDLkdIwHu7ixckACO1Jq",
"created": 1680210639,
"customer": "cus_NciAYcXfLnqBoz",
"flow": null,
"livemode": false,
"locale": null,
"on_behalf_of": null,
"return_url": "https://example.com/account",
"url": "https://billing.stripe.com/p/session/test_YWNjdF8xTTJKVGtMa2RJd0h1N2l4LF9OY2lBYjJXcHY4a2NPck96UjBEbFVYRnU5bjlwVUF50100BUtQs3bl"
}

Create a portal session 

Creates a session of the customer portal.

Parameters

  • customerstringRequired

    The ID of an existing customer.

  • configurationstring

    The ID of an existing configuration to use for this session, describing its functionality and features. If not specified, the session uses the default configuration.

  • flow_dataobject

    Information about a specific flow for the customer to go through. See the docs to learn more about using customer portal deep links and flows.

  • localeenum

    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.

  • on_behalf_ofstringConnect only

    The 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. Use the Accounts API to modify the on_behalf_of account’s branding settings, which the portal displays.

  • return_urlstring

    The default URL to redirect customers to when they click on the portal’s link to return to your website.

Returns

Returns a portal session object.

POST /v1/billing_portal/sessions
curl https://api.stripe.com/v1/billing_portal/sessions \
-u "sk_test_BQokikJ...2HlWgH4olfQ2sk_test_BQokikJOvBiI2HlWgH4olfQ2:" \
-d customer=cus_NciAYcXfLnqBoz \
--data-urlencode return_url="https://example.com/account"
Response
{
"id": "bps_1MrSjzLkdIwHu7ixex0IvU9b",
"object": "billing_portal.session",
"configuration": "bpc_1MAhNDLkdIwHu7ixckACO1Jq",
"created": 1680210639,
"customer": "cus_NciAYcXfLnqBoz",
"flow": null,
"livemode": false,
"locale": null,
"on_behalf_of": null,
"return_url": "https://example.com/account",
"url": "https://billing.stripe.com/p/session/test_YWNjdF8xTTJKVGtMa2RJd0h1N2l4LF9OY2lBYjJXcHY4a2NPck96UjBEbFVYRnU5bjlwVUF50100BUtQs3bl"
}

Customer Portal Configuration 

Invoices 

Invoices are statements of amounts owed by a customer, and are either generated one-off, or generated periodically from a subscription.

They contain invoice items, and proration adjustments that may be caused by subscription upgrades/downgrades (if necessary).

If your invoice is configured to be billed through automatic charges, Stripe automatically finalizes your invoice and attempts payment. Note that finalizing the invoice, when automatic, does not happen immediately as the invoice is created. Stripe waits until one hour after the last webhook was successfully sent (or the last webhook timed out after failing). If you (and the platforms you may have connected to) have no webhooks configured, Stripe waits one hour after creation to finalize the invoice.

If your invoice is configured to be billed by sending an email, then based on your email settings, Stripe will email the invoice to your customer and await payment. These emails can contain a link to a hosted page to pay the invoice.

Stripe applies any customer credit on the account before determining the amount due for the invoice (i.e., the amount that will be actually charged). If the amount due for the invoice is less than Stripe’s minimum allowed charge per currency, the invoice is automatically marked paid, and we add the amount due to the customer’s credit balance which is applied to the next invoice.

More details on the customer’s credit balance are here.

Related guide: Send invoices to customers

Invoice Items 

Invoice Items represent the component lines of an invoice. When you create an invoice item with an invoice field, it is attached to the specified invoice and included as an invoice line item within invoice.lines.

Invoice Items can be created before you are ready to actually send the invoice. This can be particularly useful when combined with a subscription. Sometimes you want to add a charge or credit to a customer, but actually charge or credit the customer’s card only at the end of a regular billing cycle. This is useful for combining several charges (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals.

Related guides: Integrate with the Invoicing API, Subscription Invoices.