Billing API

Billing and subscription management endpoints for organizations and projects

Billing API

Billing endpoints manage Stripe customer creation, subscriptions, and portal sessions at both organization and project scopes.

Overview

Billing can be configured at either the organization or project level. Projects may inherit billing from their parent organization.

Organization Billing Endpoints

GET  /api/v1/organizations/{orgId}/billing
PUT  /api/v1/organizations/{orgId}/billing
POST /api/v1/organizations/{orgId}/billing/customer
POST /api/v1/organizations/{orgId}/billing/subscription
POST /api/v1/organizations/{orgId}/billing/portal
POST /api/v1/organizations/{orgId}/billing/cancel

Project Billing Endpoints

GET  /api/v1/projects/{projectId}/billing
PUT  /api/v1/projects/{projectId}/billing
POST /api/v1/projects/{projectId}/billing/customer
POST /api/v1/projects/{projectId}/billing/subscription
POST /api/v1/projects/{projectId}/billing/portal
POST /api/v1/projects/{projectId}/billing/cancel

Billing Object (Conceptual)

interface BillingSettings {
  scope_type: "organization" | "project";
  scope_id: string;
  stripe_customer_id?: string;
  subscription_status?: string; // active | canceled | past_due
  inherited?: boolean; // true if project inherits from org
}

Subscription Lifecycle

  1. Customer created (Stripe customer ID stored)
  2. Subscription initiated (plan/tier configured)
  3. Portal session available for management
  4. Cancellation endpoint stops future billing

Error Responses

StatusDescription
400 Bad RequestInvalid billing data
401 UnauthorizedMissing/invalid token
403 ForbiddenInsufficient permission
404 Not FoundScope not found

Environment Variables

VariablePurpose
STRIPE_SECRET_KEYServer-side Stripe API key
STRIPE_PUBLISHABLE_KEYClient-side Stripe key
STRIPE_WEBHOOK_SECRETVerify incoming Stripe webhooks

Next Steps

Cookie Notice

We use cookies to enhance your browsing experience.