Referral payout requests and partner sessions
Review referral payout requests, mint partner portal sign-in URLs, and the public partner portal endpoints.
Guide: Partner portal and payout requests. BillStack moves no money for any of these endpoints; mark-paid only records a payment you made yourself.
Prefix P = https://billing.w3dev.app/api/billstack/v2/teams/{teamId}/projects/{projectId}. Authenticate with a private API key or a signed-in project session. Success is { data, meta }, errors are { error: { code, message }, meta }.
Review endpoints
| Method and path | IAM action | Purpose |
|---|---|---|
GET P/referrals/payouts | referral:ListPayouts | List payout requests, newest first. |
GET P/referrals/payouts/{payoutId} | referral:ListPayouts | One request with its audit trail. |
POST P/referrals/payouts/{payoutId}/approve | referral:ReviewPayout | Approve a requested payout. |
POST P/referrals/payouts/{payoutId}/reject | referral:ReviewPayout | Reject a requested or approved payout. |
POST P/referrals/payouts/{payoutId}/mark-paid | referral:ReviewPayout | Record that an approved payout was paid. |
GET P/referrals/payouts/export.csv | referral:ListPayouts | CSV export. Payout details are not included. |
POST P/referrals/partner-portal/sessions | referral:CreatePartnerSession | Mint a partner portal sign-in URL. |
List
GET P/referrals/payouts?status=¤cy=&limit=&cursor=
status:requested,approved,paid,rejectedorcancelled.currency: a 3-letter code.limit: 1 to 100.cursor: passnextCursorback.
{
"data": {
"items": [
{
"id": "por_...",
"status": "requested",
"subjectKind": "partner_email",
"partnerEmail": "pat@example.com",
"customerId": null,
"currency": "usd",
"amount": 12500,
"payoutDetails": { "paypal": "pat@example.com" },
"externalReference": null,
"adminNote": null,
"requestedAt": "2026-10-21T10:00:00.000Z",
"decidedAt": null,
"paidAt": null,
"reversedAfterPaid": false,
"reversedAmount": 0
}
],
"nextCursor": null
},
"meta": { "requestId": "..." }
}amount is in minor units. reversedAfterPaid is true when a credit behind a paid request was reversed later; reversedAmount is how much.
Get
Returns { request, transitions }. Each transition records the status change, who made it (actorKind) and any note.
Approve, reject, mark paid
| Endpoint | Body |
|---|---|
approve | { "note"?: string } (max 2000 characters) |
reject | { "note": string } required, 1 to 2000 characters. The referrer sees it. Releases the reserved credits. |
mark-paid | { "externalReference": string, "note"?: string }. externalReference is required, up to 255 characters. |
All three return { payout }.
Errors
| Status | Code | Meaning |
|---|---|---|
| 404 | PAYOUT_NOT_FOUND | Unknown id, or another project's id. |
| 409 | PAYOUT_INVALID_TRANSITION | The request is not in a status that allows this action. Re-read it. |
| 409 | PAYOUT_CREDIT_REVERSED | A reserved credit was reversed; reject instead of approving. details lists the credit ids. |
| 400 | INVALID_FILTER, INVALID_REQUEST | Bad query string or body. |
Partner sessions
POST P/referrals/partner-portal/sessions with { "customerExternalId": "user_123" } returns 201:
{
"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 in 15 minutes; the response is Cache-Control: private, no-store. Needs a live key.
| Status | Code | Meaning |
|---|---|---|
| 404 | CUSTOMER_NOT_FOUND | No customer with that externalId in the project. |
| 404 | PORTAL_DISABLED | partnerPortalEnabled is off. |
| 409 | LIVE_ONLY | A test key was used. |
Public partner portal endpoints
These back the hosted portal pages. They take no API key; they authenticate with the portal session cookie and refuse any write whose Origin is not BillStack's own. They are documented for completeness; integrate with the sign-in URL above instead of calling them from your server.
Base: https://billing.w3dev.app/api/partners/{teamSlug}/{projectSlug}
| Method and path | Purpose |
|---|---|
POST /login | Body { email }. Always 200 { data: { sent: true } }. |
POST /verify | Body { token }. Spends the token, sets the session cookie, returns { redirect, expiresAt }. 400 INVALID_TOKEN when used, expired or unknown. |
POST /logout | Revokes the session. |
GET /me | The dashboard. While locked: unlocked: false, codes only, no amounts. |
GET /payouts | The caller's own payout requests (same filters as the admin list). |
POST /payouts | Body { currency, payoutDetails?, idempotencyKey }. 201 created, 200 replay. |
POST /payouts/{payoutId}/cancel | Cancel a requested payout. |
Create errors: 403 PAYOUTS_LOCKED, 422 PAYOUT_BELOW_MINIMUM, 422 PAYOUT_NOTHING_AVAILABLE, 409 PAYOUT_ALREADY_PENDING, 409 IDEMPOTENCY_CONFLICT (same key, different values).
SDK
const { data } = await client.referrals.payouts.list({ status: "requested" });
await client.referrals.payouts.approve(data.items[0].id);
await client.referrals.payouts.markPaid(id, { externalReference: "wire-2026-10-21-001" });
const { data: session } = await client.partnerPortal.createSession("user_123");