Skip to content

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 pathIAM actionPurpose
GET P/referrals/payoutsreferral:ListPayoutsList payout requests, newest first.
GET P/referrals/payouts/{payoutId}referral:ListPayoutsOne request with its audit trail.
POST P/referrals/payouts/{payoutId}/approvereferral:ReviewPayoutApprove a requested payout.
POST P/referrals/payouts/{payoutId}/rejectreferral:ReviewPayoutReject a requested or approved payout.
POST P/referrals/payouts/{payoutId}/mark-paidreferral:ReviewPayoutRecord that an approved payout was paid.
GET P/referrals/payouts/export.csvreferral:ListPayoutsCSV export. Payout details are not included.
POST P/referrals/partner-portal/sessionsreferral:CreatePartnerSessionMint a partner portal sign-in URL.

List

GET P/referrals/payouts?status=&currency=&limit=&cursor=

  • status: requested, approved, paid, rejected or cancelled.
  • currency: a 3-letter code. limit: 1 to 100. cursor: pass nextCursor back.
{
  "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

EndpointBody
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

StatusCodeMeaning
404PAYOUT_NOT_FOUNDUnknown id, or another project's id.
409PAYOUT_INVALID_TRANSITIONThe request is not in a status that allows this action. Re-read it.
409PAYOUT_CREDIT_REVERSEDA reserved credit was reversed; reject instead of approving. details lists the credit ids.
400INVALID_FILTER, INVALID_REQUESTBad 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.

StatusCodeMeaning
404CUSTOMER_NOT_FOUNDNo customer with that externalId in the project.
404PORTAL_DISABLEDpartnerPortalEnabled is off.
409LIVE_ONLYA 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 pathPurpose
POST /loginBody { email }. Always 200 { data: { sent: true } }.
POST /verifyBody { token }. Spends the token, sets the session cookie, returns { redirect, expiresAt }. 400 INVALID_TOKEN when used, expired or unknown.
POST /logoutRevokes the session.
GET /meThe dashboard. While locked: unlocked: false, codes only, no amounts.
GET /payoutsThe caller's own payout requests (same filters as the admin list).
POST /payoutsBody { currency, payoutDetails?, idempotencyKey }. 201 created, 200 replay.
POST /payouts/{payoutId}/cancelCancel 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");