Skip to main content
The hosted Customer Portal can’t be restyled. To give customers billing pages inside your own app, build them on the Customer Portal API: the same API the hosted portal uses, scoped to one signed-in customer. Your backend creates a customer session with your access token. The session’s token then calls the Customer Portal API on behalf of that one customer.

Create a customer session

Create the session on your server, for the signed-in user:
  • The token starts with polar_mst_ and expires after one hour (expires_at). Create a new one when it runs out.
  • For a team customer, pass member_id or external_member_id to act as a specific member. Without it, the session is for the customer’s owner. What a member can do depends on their role.
  • The token only grants access to that customer’s data, so it’s safe to use in the browser. Your access token never is.
Creating customer sessions is API only. Not available from the CLI or MCP server.
The examples use the sandbox and API version 2026-10.

Call the Customer Portal API

Use the session token as the bearer token. With the SDKs, create a second client with it:
What the API covers: See the Customer Portal API group in the API reference for every endpoint.

Portal settings apply here too

Your portal settings are enforced in this API, not only in the hosted portal. With Enable subscription plan changes off, for example, a plan change through the Customer Portal API fails with 403. Hide those actions in your UI when the matching setting is off. The exception is Show metered usage: it only hides the hosted Usage page. The meters endpoints keep working. Your backend isn’t limited by these settings. The merchant endpoints, like Update Subscription, work whatever the portal allows.

Recover failed payments

When a renewal fails, the customer needs a working default payment method. Two ways to give them one in your app:
  • A new card. Open the Embedded Payment Method with the session token. The card is attached and becomes the default unless you pass setAsDefault: false. Card details never touch your servers.
  • A saved card. Set default_payment_method_id with Update Customer to switch to a card the customer already saved.
Either way, Polar retries past-due orders as soon as the default payment method changes. See Failed payments.

Learn more