Skip to main content
In this guide you’ll create a customer portal session for a customer and redirect them to it. By the end, a customer who clicks “Manage subscription” in your app lands in the portal already signed in, with no second login. Create a session at the moment the customer asks for it. Sessions are short-lived, so a URL minted ahead of time and stored is usually dead by the time it’s used. Always mint a fresh one per request.

Prerequisites

Steps

1

Create the session

Call POST /v1/customers/{customer_id}/portal-sessions. There is no request body: what the customer can do in the portal comes from your portal settings, not from this call.
2

Redirect the customer

Send the customer to url and nothing else.
The URL signs the customer in, so don’t log it or store it.
3

React to what they do

The customer’s session is now theirs. Anything they change emits the same webhook as the equivalent API call: customer.subscription.updated on a plan change or scheduled cancellation, customer.subscription.deleted on a cancellation, invoice.paid when a recovery payment succeeds.There is no redirect back to you unless you’ve set a return URL in your portal settings, and the customer may close the tab at any point. Treat webhooks as the only reliable signal that something changed.

Errors

Next steps

  • Customer portal covers what the portal does and how to configure what customers can change.
  • Manage customers shows how to create and look up the customer_id this endpoint needs.
  • Webhooks explains how to receive the events a portal action emits.