Billing portal sessions

A billing portal session signs a customer in to the billing portal, where they manage their subscriptions, payment methods and invoices.

The BillingPortalSession object

Name
object
Type
"billing_portal_session",
Description
The object's type.
Name
id
Type
string,
Description
Unique identifier for the object.
Name
live
Type
boolean,
Description
true if the object is live, or false if it's in a sandbox.
Name
created_at
Type
integer,
Description
When the object was created, in milliseconds since the Unix epoch.
Name
customer
Type
string,
Description
The customer the session signs in.
Name
expires_at
Type
integer,
Description
When url expires if unused, as a Unix timestamp in milliseconds.
Name
flow
Type
object or null,
Description
The change the portal opens to, if any.
Properties
Name
return_url
Type
string or null,
Description
The page the portal links back to.
Name
subscription
Type
string or null,
Description
The subscription the portal opens to.
Name
url
Type
string,
Description
The link that signs the customer in to the portal. It works once, until expires_at.

The BillingPortalSession object

{
  "object": "billing_portal_session",
  "live": false,
  "id": "bps_mtQlgwyyOBwHfy3Gf8wQK1",
  "created_at": 1750000000000,
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "subscription": "sub_nBAYX0s957u697jpsclt34",
  "return_url": "https://example.com/account",
  "flow": {
    "type": "change_plan",
    "subscription": "sub_nBAYX0s957u697jpsclt34",
    "price": "price_dz1NVvl5CSogERkeA9Ng67",
    "quantity": null,
    "proration_behavior": null,
    "apply_at": null
  },
  "url": "https://checkout.biaspay.com/account/merch_r2hlY67u6g9cIKxY5yAeG4/session/KNRVqEY12hd715TVsnBmbKxIakji-aK5yZnVbhvCiA0",
  "expires_at": 1750000300000
}

Create a billing portal session

Create a session when a customer signed in to your site asks to manage their billing, then redirect them to its url. The link works once and expires 5 minutes after it’s created.

With subscription, the portal opens to that subscription. With a flow, it opens to confirming a plan change you choose, on an active or trialing subscription with one item.

Required parameters

Name
customer
Type
string,
Description
The customer to sign in.

Optional parameters

Name
subscription
Type
string,
Description
The subscription the portal opens to. Defaults to flow.subscription.
Name
return_url
Type
string or null,
Description
The page the portal links back to.
Name
flow
Type
object,
Description
Opens the portal to a specific change, which the customer confirms.
Properties

Returns

Returns the billing portal session object.

Create a billing portal session

const session = await bias.billingPortal.sessions.create({
  customer: "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  return_url: "https://example.com/account"
});

Response example

{
  "object": "billing_portal_session",
  "live": false,
  "id": "bps_mtQlgwyyOBwHfy3Gf8wQK1",
  "created_at": 1750000000000,
  "customer": "cus_aB4DEXqbFGOlpEOxwp0Fx1",
  "subscription": "sub_nBAYX0s957u697jpsclt34",
  "return_url": "https://example.com/account",
  "flow": {
    "type": "change_plan",
    "subscription": "sub_nBAYX0s957u697jpsclt34",
    "price": "price_dz1NVvl5CSogERkeA9Ng67",
    "quantity": null,
    "proration_behavior": null,
    "apply_at": null
  },
  "url": "https://checkout.biaspay.com/account/merch_r2hlY67u6g9cIKxY5yAeG4/session/KNRVqEY12hd715TVsnBmbKxIakji-aK5yZnVbhvCiA0",
  "expires_at": 1750000300000
}