Partner portal and payout requests
Give referrers a hosted page for their earnings, and let them request a payout that you review and pay yourself.
The partner portal is a hosted page where a referrer signs in, sees what they earned and asks to be paid. It is part of the referral program for projects that keep their own billing (Referrals with your own billing).
BillStack moves no money for payout requests. There is no Stripe Connect and no transfer. A payout request is a record: a referrer asks, you approve, you pay them yourself (bank transfer, PayPal, anything), then you mark the request paid with your payment reference.
Who can sign in
A referrer is either:
- a partner: the owner of a partner code (
partner: { email, name }), identified by email; or - a customer referrer: one of your registered customers with a referral code. Customer referrers can sign in by email too when BillStack holds their email and they have a referral code or a credit.
The portal serves the live environment only. Test keys cannot mint portal sessions (409 LIVE_ONLY).
Turn it on
The portal is off by default. Enable it in the program settings (Referrals > Settings), with the API (PUT .../referrals/program with partnerPortalEnabled: true), the SDK, or the MCP tool set_partner_portal_settings.
| Setting | Meaning |
|---|---|
partnerPortalEnabled | Gate for sign-in, host-minted sessions and payout requests. While off, every portal route answers 404. |
minPayoutAmount | Smallest total a referrer may request per currency, in minor units. null means no minimum. |
The portal lives at:
https://billing.w3dev.app/partners/{teamSlug}/{projectSlug}Link to it from your product or your partner onboarding emails. Pages carry noindex, a no-referrer policy and X-Frame-Options: DENY; the portal cannot be embedded in an iframe (use the referral embed for that).
Sign-in
Both paths end with the same thing: a session cookie that lasts 7 days. BillStack stores only a hash of the session.
Emailed magic link
The referrer enters their email on the portal login page. If the email belongs to a referrer of this program, BillStack emails a single-use link that expires after 15 minutes. The page always answers "check your email" and the API always answers { "data": { "sent": true } }, whatever the email, so the login cannot be used to find out who is a partner. Links are rate limited per email (3 per 15 minutes) and per IP (10 per 15 minutes).
The link opens a landing page with a Continue button. The token is spent only when the button is pressed (a POST), so an email scanner that opens the link does not use it up.
Host-minted session
For customer referrers who are already signed in to your product, skip the email. Mint a sign-in URL from your server and redirect the user to it:
curl -X POST "https://billing.w3dev.app/api/billstack/v2/teams/{teamId}/projects/{projectId}/referrals/partner-portal/sessions" \
-H "Authorization: Bearer <live-private-api-key>" \
-H "Content-Type: application/json" \
-d '{ "customerExternalId": "user_123" }'{
"data": {
"url": "https://billing.w3dev.app/partners/acme/web/verify?token=...",
"expiresAt": "2026-10-21T12:15:00.000Z"
},
"meta": { "requestId": "..." }
}The URL is single use and expires after 15 minutes. Mint it at the moment of the click; never email or store it. The same call is available as client.partnerPortal.createSession("user_123") in the SDK. Errors: 404 CUSTOMER_NOT_FOUND, 404 PORTAL_DISABLED, 409 LIVE_ONLY. IAM action: referral:CreatePartnerSession.
Earnings gate
Until a referrer has earned something, the portal shows a locked screen: their code and share link, and nothing else. No balances, credits, referrals or payout form are returned, not even through the API. The portal unlocks for a referrer when earned > 0 in at least one currency.
Balances
All amounts are integer minor units, and currencies are never mixed. Per currency:
| Field | Meaning |
|---|---|
earned | Sum of the referrer's applied ledger entries, with reversals netted out, floored at 0. |
reserved | Total of payout requests that are requested or approved. |
paid | Total of payout requests marked paid. |
available | earned - reserved - paid, capped by the credits that are still payable, floored at 0. This is what can be requested. |
pending | Credits still pending, approved or applying. Display only; never payable. |
A credit that has a pending or applied reversal is not payable.
Payout request lifecycle
requested -> approved -> paid
| |
+-> rejected <-+ requested -> cancelled (by the referrer)| Status | Who | Effect |
|---|---|---|
requested | Referrer | Reserves every payable credit of one currency. One open request per referrer and currency. |
approved | You | Marks the request as accepted. No money moves. |
rejected | You | Needs a note the referrer can read. Releases the credits so the referrer can ask again. |
paid | You | You paid outside BillStack. Needs your externalReference (a bank transfer id, for example). |
cancelled | Referrer | Only while requested. Releases the credits. |
Every status change is stored with who made it and any note. A request carries the payoutDetails the referrer typed (up to 2048 bytes, for example their bank or PayPal details). Treat it as personal data.
The request form rejects:
| Code | Status | Meaning |
|---|---|---|
PAYOUTS_LOCKED | 403 | Nothing earned yet. |
PAYOUT_BELOW_MINIMUM | 422 | available is below minPayoutAmount. |
PAYOUT_NOTHING_AVAILABLE | 422 | available is 0 in that currency. |
PAYOUT_ALREADY_PENDING | 409 | A request for that currency is already open. |
A request is created with an idempotencyKey; repeating it returns the same request (200) and reserves nothing twice. Keys are scoped to the referrer, so two referrers can use the same key.
Only referral rewards are payable. Manual and goodwill credits are not. A customer referrer whose program pays rewards as Stripe balance (payoutMethod: stripe_balance) has already received that value, so it never counts as available cash; use payoutMethod: ledger_only for programs that pay out through the portal. A credit that was partly refunded stays payable for the part that was not reversed.
Reversals
If a refund or dispute reverses a credit that sits behind a request:
- Before paid: approving fails with
409 PAYOUT_CREDIT_REVERSED. Reject the request; the referrer can then ask again for the amount that is still valid. - After paid: the request stays
paid, the portal and the admin views show a "reversed after paid" warning with the reversed amount, and apayout.credit_reversedevent is sent. BillStack does not claw money back; settle it with the referrer in your next payout.
Review payouts
- Dashboard: Referrals > Payouts. Filter by status and currency, approve, reject (note required) or mark paid (external reference required), open the audit trail, and export CSV.
- API: see Referral payout requests.
- SDK:
client.referrals.payouts.{list,get,approve,reject,markPaid}. - MCP:
list_payout_requests,get_payout_request,approve_payout_request,reject_payout_request,mark_payout_paid,set_partner_portal_settings. - Agents: load the operate referrals skill.
IAM actions: referral:ListPayouts (list, get, export) and referral:ReviewPayout (approve, reject, mark paid). referral:* covers both.
Webhooks
Subscribe an outbound webhook endpoint to react to the lifecycle:
| Event | Sent when |
|---|---|
payout.requested | A referrer asked to be paid. |
payout.approved | You approved the request. |
payout.rejected | You rejected it and the credits were released. |
payout.paid | You marked it paid. |
payout.cancelled | The referrer cancelled it. |
payout.credit_reversed | A credit behind a paid request was reversed afterwards. |
The payload is { "payout": { ... } } with the request id, status, currency, amount, the referrer, externalReference and timestamps. Events are sent after the change is saved; a failed publish is logged and never undoes the change.
Security notes
- Sign-in tokens and session tokens are stored only as hashes. The cookie is
HttpOnly,SameSite=LaxandSecurein production. - Every portal write is a
POSTwith a JSON body from the BillStack origin; anything else is refused. - Never put a partner session URL in a log, an analytics event or an email you send yourself.
- Keep the private API key that mints sessions on your server only.