Billing API
Stripe-backed org billing: read billing state, initialize a subscription checkout, open the Stripe customer portal, and start checkouts for Warrant-licensed products.
Token tier: sessions only — API keys are rejected
The billing service rejects sk_live_ / sk_test_ API
keys entirely (verified live). Authenticate with a kses_ session
token or an RS256 JWT. This is by design: payment actions are tied to a human
org member, not a machine credential.
Endpoints
| Method | Path | SDK (client.billing) |
|---|---|---|
| GET | /v1/orgs/{org_id}/billing | get |
| POST | /v1/orgs/{org_id}/billing/init | init |
| POST | /v1/orgs/{org_id}/billing/portal | portal |
| POST | /v1/checkout/warrant-product | createWarrantCheckout |
SDK Examples
// Construct the client with a session token (API keys are rejected here)
const billing = await client.billing.get(orgId);
console.log(billing.plan, billing.status);
// Start a subscription checkout — redirect the user to the returned URL
const { checkout_url } = await client.billing.init(orgId, {
plan_code: 'pro',
});
// Open the Stripe customer portal for self-service management
const portal = await client.billing.portal(orgId);
let billing = client.billing().get(org_id).await?;
let session = client.billing().init(org_id, &BillingInitRequest {
plan_code: "pro".into(),
}).await?;
Redirect URLs are origin-checked
Checkout/portal redirect URLs must be on .kapable.ai /
.kapable.run / localhost — arbitrary origins
are refused.