BillStack Docs

API Overview

Authentication, base URLs, error handling, and conventions for the BillStack REST API

Base URL

All BillStack API endpoints follow this pattern:

https://your-billstack.com/api/billstack/teams/{teamId}/projects/{projectId}/...

Team-level endpoints (Stripe connection, API keys) omit the /projects/{projectId} segment:

https://your-billstack.com/api/billstack/teams/{teamId}/...

Authentication

BillStack supports two authentication methods:

API Key (for external SaaS apps)

Include your API key in the Authorization header:

curl https://your-billstack.com/api/billstack/teams/{teamId}/projects/{projectId}/customers \
  -H "Authorization: Bearer bs_a1b2c3d4..."

API keys are prefixed with bs_ and can be scoped to specific projects and permissions. See Create API Keys for details.

Dashboard users authenticate via BetterAuth session cookies. This is handled automatically by the browser — no manual header is needed.

Team-level endpoints (Stripe connection, API key management) require session authentication only and cannot be accessed with API keys.

Request Format

  • All request bodies must be JSON with Content-Type: application/json
  • Query parameters use standard URL encoding
  • IDs use BillStack prefixes (pc_, pp_, pri_, ps_) — not raw Stripe IDs

Response Format

All responses return JSON. Successful responses include the resource directly:

{
  "customer": {
    "id": "pc_xxx",
    "email": "jane@example.com",
    "name": "Jane Doe",
    "stripeCustomerId": "cus_xxx",
    "createdAt": "2026-03-30T12:00:00Z"
  }
}

List responses include an array:

{
  "customers": [
    { "id": "pc_xxx", "email": "jane@example.com" },
    { "id": "pc_yyy", "email": "john@example.com" }
  ]
}

Error Responses

Errors return an appropriate HTTP status code with a JSON body:

{
  "error": "Customer not found"
}
Status CodeMeaning
400Bad request — invalid or missing parameters
401Unauthorized — missing or invalid API key / session
403Forbidden — insufficient permissions or scopes
404Not found — resource doesn't exist or belongs to another project
409Conflict — resource already exists (e.g., duplicate email)
500Internal server error

Pagination

List endpoints support pagination via query parameters:

ParameterTypeDefaultDescription
limitnumber50Maximum items to return
offsetnumber0Number of items to skip
curl ".../customers?limit=25&offset=50" \
  -H "Authorization: Bearer bs_..."

ID Prefixes

ResourcePrefixExample
Customerpc_pc_a1b2c3d4
Productpp_pp_e5f6g7h8
Pricepri_pri_i9j0k1l2
Subscriptionps_ps_m3n4o5p6

Each resource also stores its corresponding Stripe ID (e.g., stripeCustomerId, stripeProductId).

Endpoints

SectionEndpoints
CustomersCRUD operations for project-scoped customers
Products & PricesManage products and their pricing
SubscriptionsList, view, cancel, and resume subscriptions
CheckoutCreate Stripe Checkout sessions
PortalGenerate customer portal access tokens
AnalyticsMRR, churn, customer growth, webhook stats
ReferralsReferral codes, application, and configuration

On this page