API Reference
Manage subscriptions, check entitlements, and view usage.
Endpoints
Get Current Subscription
GET /v1/billing/subscriptionResponse:
{
"id": "sub_123",
"plan": "pro",
"status": "active",
"currentPeriodStart": "2024-01-01T00:00:00Z",
"currentPeriodEnd": "2024-02-01T00:00:00Z",
"cancelAtPeriodEnd": false
}Check Entitlement
GET /v1/billing/entitlement?product=sendResponse:
{
"hasAccess": true,
"product": "send",
"limits": {
"apiCalls": 10000,
"emails": 5000
},
"usage": {
"apiCalls": 1234,
"emails": 567
}
}Get Usage
GET /v1/billing/usage?period=currentResponse:
{
"period": {
"start": "2024-01-01T00:00:00Z",
"end": "2024-02-01T00:00:00Z"
},
"usage": {
"apiCalls": 1234,
"emails": 567,
"storage": 104857600
}
}List Invoices
GET /v1/billing/invoices?limit=10Response:
{
"data": [
{
"id": "inv_123",
"amount": 2000,
"currency": "usd",
"status": "paid",
"createdAt": "2024-01-01T00:00:00Z",
"pdfUrl": "https://..."
}
],
"pagination": {
"hasMore": false
}
}Create Checkout Session
For client-side subscription flows:
POST /v1/billing/checkoutRequest:
{
"priceId": "price_pro",
"successUrl": "https://your-app.com/success",
"cancelUrl": "https://your-app.com/cancel"
}Response:
{
"url": "https://checkout.stripe.com/..."
}Webhooks
Subscribe to billing events:
| Event | Description |
|---|---|
subscription.created | New subscription started |
subscription.updated | Subscription changed |
subscription.canceled | Subscription canceled |
invoice.paid | Payment successful |
invoice.failed | Payment failed |
Cross-Domain Usage
For subdomains (send.dev, transcribe.dev, etc.):
// Report usage from subdomain
await fetch('https://do.dev/api/billing/usage', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
},
body: JSON.stringify({
product: 'send',
usageType: 'email_send',
quantity: 1,
}),
});