Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Authentication

The billing API supports two authentication methods: JWT Bearer tokens and API keys.

JWT Bearer Token

For most integrations, use a short-lived JWT signed with HS256:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

JWTs must include:

  • sub — customer or user ID
  • exp — expiration timestamp (max 1 hour for customer tokens, 8 hours for admin tokens)
  • scopecustomer or admin

The JWT signing secret is configured via JWT_SECRET environment variable.

API Keys

Long-lived API keys are supported for server-to-server integrations:

X-API-Key: bsk_live_xxxxxxxxxxxxxxxxxxxx

API keys are validated in constant time to prevent timing attacks. Prefix bsk_live_ for production, bsk_test_ for sandbox.

Route Security

Route prefixRequired scope
GET /healthNone (public)
GET /openapi.jsonNone (public)
/v1/*customer or admin
/admin/v1/*admin only

Environment Variables

VariableDescription
JWT_SECRETHMAC-SHA256 secret for JWT signing/verification
API_KEY_HASHSHA-256 hex of the valid API key
STRIPE_WEBHOOK_SECRETStripe webhook signing secret (whsec_...)