Legacy Customer portal
The hosted billing page your customers open to manage subscriptions and invoices, for Stripe and Razorpay.
Legacy (v1) API. This page describes the Stripe-first legacy API. It stays supported for existing integrations but is frozen: new features ship only in v2. Prefer v2 for new work: Customer portal and admin links.
The customer portal is a hosted page at https://billing.w3dev.app/portal/{token}. You create a short-lived session on your server and redirect the customer to its portalUrl. No customer sign-in is needed; the token is the credential, so treat the URL like a password and never log it.
For session creation basics and admin links, see Customer portal and admin links. The endpoint reference is Portal sessions.
What the customer can do
This page describes BillStack's own hosted portal at /portal/{token}. The v2 portal route (POST .../v2/.../portal) opens the provider's portal instead and supports Stripe only; for a customer with accounts at several providers it opens the pinned region's account (see Multi-provider v2). To give a Razorpay customer a portal, create the session with the routes below.
The portal shows one pane per payment provider the customer has an account with. A customer with both Stripe and Razorpay sees a Stripe | Razorpay switch (Stripe is the default); a customer with one provider sees that provider directly.
| Capability | Stripe | Razorpay |
|---|---|---|
| List subscriptions | Yes | Yes |
| Cancel at period end | Yes | Yes |
| Resume a cancelled subscription | Yes | No |
| List invoices | Yes | Yes (links to the Razorpay hosted invoice page) |
| Manage payment methods | Yes | No |
Razorpay subscriptions are shown only when BillStack has recorded them for the customer (checkout or a webhook created the provider account link). Razorpay cannot list subscriptions by customer, so BillStack reads each known subscription id. A customer sees at most 10 Razorpay subscriptions and 20 invoices per subscription.
A Razorpay cancel always takes effect at the end of the current billing cycle. A subscription that does not belong to the customer answers 404, the same as an unknown one.
To change or cancel a subscription from your own server instead, use the v2 subscription management routes.
Projects with external billing
When the project keeps its own billing (referrals-only mode), mutations are blocked, so the customer cannot cancel. Listing subscriptions and invoices still works, and the referral view is shown.
Razorpay credentials
BillStack uses the project's Razorpay connection (or, for older projects, its legacy provider config). The Razorpay key id and secret never leave the server. If Razorpay is unreachable, the pane shows a retry; the API answers 502 PROVIDER_UNAVAILABLE.
Create a session
curl -X POST "https://billing.w3dev.app/api/billstack/teams/{teamId}/projects/{projectId}/portal/by-external-id" \
-H "Authorization: Bearer <private-api-key>" \
-H "Content-Type: application/json" \
-d '{ "externalId": "user_123" }'{
"sessionId": "ps_...",
"token": "...",
"portalUrl": "https://billing.w3dev.app/portal/...",
"expiresAt": "2026-06-12T12:00:00.000Z"
}Redirect the customer to portalUrl. The response also carries url, a deprecated alias of portalUrl kept for older SDK versions.
With the SDK
const session = await client.portal.create({ customerId });
redirect(session.portalUrl);Since @billstack/sdk 0.4.1, portal.create() returns { sessionId, token, portalUrl, expiresAt }. Earlier versions typed the result as { url }, which the server never returned, so session.url was undefined. url is still filled (same value as portalUrl) but deprecated: read portalUrl.
Partner portal
Referrers have their own hosted page for earnings and payout requests. It is separate from this portal: see Partner portal and payout requests.