Skip to content

API reference

API: Billing

Markdown version

MethodPathWhat it doesScope
GET/v1/billingThe organization's plan, subscription, seats and this month's usage against the plan's allowance (AI credits)billing:read
POST/v1/billing/cancelCancel the subscription at the end of the period (owners). Asks why: a reason from the list, and optional words. The workspace goes back to Free when the period ends; until then it can be undone (web app only)billing:write
POST/v1/billing/checkoutStart a Stripe checkout for a paid plan (owners). Returns the checkout URL to open; the plan applies when Stripe confirms the subscription (web app only)billing:write
GET/v1/billing/invoicesInvoices from Stripe, newest first, with tax shown separately (owners)billing:write
GET/v1/billing/invoices/:id/pdfA short-lived link to one invoice's PDF (owners)billing:write
POST/v1/billing/planChange to another paid plan or billing interval now, prorated (owners). Moving to a smaller plan asks why: a reason from the list, and optional words (web app only)billing:write
POST/v1/billing/portalShort-lived links to Stripe's customer portal: update the payment method, invoices, billing details (owners; cancelling is POST /v1/billing/cancel) (web app only)billing:write
GET/v1/billing/pricesPlan prices for a location, before sales tax (we sell to businesses in the United States; tax is added at checkout where it applies)billing:read
POST/v1/billing/resumeKeep the subscription: undo a cancel that hasn't happened yet (owners) (web app only)billing:write
GET/v1/billing/run-costsWhat runs cost before you start them: credits per unit and the most one AI request can cost; with billing access, credits left this month, today's AI spend and budget, and what an agent's runs or your agent's requests cost on averagemarketing:read
POST/v1/billing/seats/syncSet the subscription's quantity to the current sites (per-site plans), prorated on the next invoice (owners, in the app; also runs daily) (web app only)billing:write
POST/v1/billing/upgrade-linkFor agents: suggest a paid plan to the organization's owners. Returns a link to the billing page with the plan filled in, for an owner to review and pay; nothing is bought here, and the owners are notified (naming the key or app that asked)agents:write
GET/v1/billing/upgrade-link/checkWhether an agent suggested this plan to the organization in the last 7 days (the billing page checks before showing it)billing:read

Examples

GET /v1/billing

The organization's plan, subscription, seats and this month's usage against the plan's allowance (AI credits)

curl -s "https://api.tendbrook.com/v1/billing" \
  -H "Authorization: Bearer $EC_API_KEY"
const res = await fetch(`https://api.tendbrook.com/v1/billing`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.EC_API_KEY}` },
});
const data = await res.json();

GET /v1/billing/invoices

Invoices from Stripe, newest first, with tax shown separately (owners)

curl -s "https://api.tendbrook.com/v1/billing/invoices" \
  -H "Authorization: Bearer $EC_API_KEY"
const res = await fetch(`https://api.tendbrook.com/v1/billing/invoices`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.EC_API_KEY}` },
});
const data = await res.json();

GET /v1/billing/invoices/$ID/pdf

A short-lived link to one invoice's PDF (owners)

curl -s "https://api.tendbrook.com/v1/billing/invoices/$ID/pdf" \
  -H "Authorization: Bearer $EC_API_KEY"
const res = await fetch(`https://api.tendbrook.com/v1/billing/invoices/${id}/pdf`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.EC_API_KEY}` },
});
const data = await res.json();

GET /v1/billing/prices

Plan prices for a location, before sales tax (we sell to businesses in the United States; tax is added at checkout where it applies)

curl -s "https://api.tendbrook.com/v1/billing/prices" \
  -H "Authorization: Bearer $EC_API_KEY"
const res = await fetch(`https://api.tendbrook.com/v1/billing/prices`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.EC_API_KEY}` },
});
const data = await res.json();

GET /v1/billing/run-costs

What runs cost before you start them: credits per unit and the most one AI request can cost; with billing access, credits left this month, today's AI spend and budget, and what an agent's runs or your agent's requests cost on average

curl -s "https://api.tendbrook.com/v1/billing/run-costs" \
  -H "Authorization: Bearer $EC_API_KEY"
const res = await fetch(`https://api.tendbrook.com/v1/billing/run-costs`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.EC_API_KEY}` },
});
const data = await res.json();

POST /v1/billing/upgrade-link

For agents: suggest a paid plan to the organization's owners. Returns a link to the billing page with the plan filled in, for an owner to review and pay; nothing is bought here, and the owners are notified (naming the key or app that asked)

curl -s -X POST "https://api.tendbrook.com/v1/billing/upgrade-link" \
  -H "Authorization: Bearer $EC_API_KEY" \
  -H "content-type: application/json" \
  -d '{}'
const res = await fetch(`https://api.tendbrook.com/v1/billing/upgrade-link`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.EC_API_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({}), // fields: see the OpenAPI schema
});
const data = await res.json();

Whether an agent suggested this plan to the organization in the last 7 days (the billing page checks before showing it)

curl -s "https://api.tendbrook.com/v1/billing/upgrade-link/check" \
  -H "Authorization: Bearer $EC_API_KEY"
const res = await fetch(`https://api.tendbrook.com/v1/billing/upgrade-link/check`, {
  method: "GET",
  headers: { authorization: `Bearer ${process.env.EC_API_KEY}` },
});
const data = await res.json();

Request and response schemas: https://www.tendbrook.com/openapi.json. All resources: API reference.

Send feedback

Tell us what's broken, confusing or missing on this page, or an idea. It goes to the team that builds the product.
Please don't include passwords or card numbers.
Only to reply about this. Never added to any mailing list.