Subscription API

Manage subscription and billing information.

Endpoints#

MethodEndpointDescription
GET/subscriptionGet current subscription
POST/subscription/portalGet billing portal URL
GET/subscription/invoicesList invoices
GET/subscription/usageGet usage against plan limits

Subscription Object#

1{ 2 "id": "sub_abc123", 3 "status": "active", 4 "plan": { 5 "id": "pro", 6 "name": "Pro", 7 "price": 19, 8 "interval": "month" 9 }, 10 "currentPeriod": { 11 "start": "2024-01-01T00:00:00Z", 12 "end": "2024-01-31T23:59:59Z" 13 }, 14 "cancelAtPeriodEnd": false, 15 "features": { 16 "projects": 10, 17 "apiCalls": 10000, 18 "agentInvocations": 1000, 19 "skillApplications": 500, 20 "teamMembers": 1, 21 "prioritySupport": true 22 }, 23 "createdAt": "2024-01-01T00:00:00Z" 24}

Get Subscription#

GET /subscription

Example Request#

curl https://api.bootspring.dev/v1/subscription \ -H "Authorization: Bearer bs_xxx"

Response#

1{ 2 "data": { 3 "id": "sub_abc123", 4 "status": "active", 5 "plan": { 6 "id": "pro", 7 "name": "Pro", 8 "price": 19, 9 "interval": "month", 10 "currency": "usd" 11 }, 12 "currentPeriod": { 13 "start": "2024-01-01T00:00:00Z", 14 "end": "2024-01-31T23:59:59Z" 15 }, 16 "cancelAtPeriodEnd": false, 17 "paymentMethod": { 18 "type": "card", 19 "last4": "4242", 20 "brand": "visa", 21 "expiresAt": "2025-12" 22 }, 23 "features": { 24 "projects": 10, 25 "apiCalls": 10000, 26 "agentInvocations": 1000, 27 "skillApplications": 500, 28 "contextGenerations": 500, 29 "teamMembers": 1, 30 "prioritySupport": true, 31 "customAgents": false, 32 "sso": false 33 }, 34 "usage": { 35 "projects": { "used": 3, "limit": 10 }, 36 "apiCalls": { "used": 5420, "limit": 10000 }, 37 "agentInvocations": { "used": 342, "limit": 1000 } 38 }, 39 "createdAt": "2024-01-01T00:00:00Z" 40 } 41}

Subscription Statuses#

StatusDescription
activeSubscription is active and paid
trialingIn free trial period
past_duePayment failed, grace period
canceledSubscription canceled
unpaidPayment failed, access restricted

Get Billing Portal#

POST /subscription/portal

Generates a URL to the Stripe billing portal where users can manage their subscription.

Request Body#

FieldTypeRequiredDescription
returnUrlstringNoURL to redirect after portal

Example Request#

1curl -X POST https://api.bootspring.dev/v1/subscription/portal \ 2 -H "Authorization: Bearer bs_xxx" \ 3 -H "Content-Type: application/json" \ 4 -d '{ 5 "returnUrl": "https://bootspring.dev/dashboard/settings" 6 }'

Response#

1{ 2 "data": { 3 "url": "https://billing.stripe.com/session/xxx", 4 "expiresAt": "2024-01-15T11:00:00Z" 5 } 6}

List Invoices#

GET /subscription/invoices

Query Parameters#

ParameterTypeDescription
limitintegerNumber of invoices (default: 10)
statusstringFilter: paid, open, void

Example Request#

curl https://api.bootspring.dev/v1/subscription/invoices \ -H "Authorization: Bearer bs_xxx"

Response#

1{ 2 "data": [ 3 { 4 "id": "inv_abc123", 5 "number": "INV-2024-001", 6 "status": "paid", 7 "amount": 1900, 8 "currency": "usd", 9 "description": "Pro Plan - January 2024", 10 "pdfUrl": "https://pay.stripe.com/invoice/xxx/pdf", 11 "paidAt": "2024-01-01T00:05:00Z", 12 "periodStart": "2024-01-01T00:00:00Z", 13 "periodEnd": "2024-01-31T23:59:59Z", 14 "createdAt": "2024-01-01T00:00:00Z" 15 } 16 ] 17}

Get Usage vs Limits#

GET /subscription/usage

Example Request#

curl https://api.bootspring.dev/v1/subscription/usage \ -H "Authorization: Bearer bs_xxx"

Response#

1{ 2 "data": { 3 "plan": "pro", 4 "period": { 5 "start": "2024-01-01T00:00:00Z", 6 "end": "2024-01-31T23:59:59Z" 7 }, 8 "metrics": { 9 "projects": { 10 "used": 3, 11 "limit": 10, 12 "percentage": 30 13 }, 14 "apiCalls": { 15 "used": 5420, 16 "limit": 10000, 17 "percentage": 54.2 18 }, 19 "agentInvocations": { 20 "used": 342, 21 "limit": 1000, 22 "percentage": 34.2 23 }, 24 "skillApplications": { 25 "used": 89, 26 "limit": 500, 27 "percentage": 17.8 28 }, 29 "contextGenerations": { 30 "used": 156, 31 "limit": 500, 32 "percentage": 31.2 33 } 34 }, 35 "resetAt": "2024-02-01T00:00:00Z" 36 } 37}

Plan Comparison#

FeatureFreeProTeamEnterprise
Price$0$19/mo$49/user/moCustom
Projects11050Unlimited
API Calls/mo1,00010,00050,000Custom
Agent Invocations/mo501,0005,000Custom
Team Members11UnlimitedUnlimited
Priority SupportNoYesYesYes
Custom AgentsNoNoYesYes
SSONoNoNoYes
SLANoNo99.9%99.99%

Upgrade Subscription#

Upgrading is done through the billing portal:

1// Get portal URL 2const { data } = await fetch('/api/subscription/portal', { 3 method: 'POST', 4 headers: { 5 'Authorization': `Bearer ${apiKey}`, 6 'Content-Type': 'application/json', 7 }, 8 body: JSON.stringify({ 9 returnUrl: window.location.href, 10 }), 11}).then(r => r.json()); 12 13// Redirect to portal 14window.location.href = data.url;

Cancel Subscription#

Cancellation is also done through the billing portal. The subscription remains active until the end of the current billing period.

Check Cancellation Status#

1{ 2 "status": "active", 3 "cancelAtPeriodEnd": true, 4 "currentPeriod": { 5 "end": "2024-01-31T23:59:59Z" 6 } 7}

Webhooks#

Subscribe to billing events:

EventDescription
subscription.createdNew subscription started
subscription.updatedSubscription plan changed
subscription.canceledSubscription canceled
invoice.paidInvoice payment successful
invoice.payment_failedInvoice payment failed

See Webhooks for setup.

Errors#

CodeDescription
no_subscriptionUser has no subscription
subscription_canceledSubscription is canceled
payment_requiredPayment method needed
portal_errorFailed to create portal session