Billing
Read your balance, credit grants, and invoices. Reads only — no money moves through this API.
What your organization has, what it owes, and what it bought. Reads only.
| Endpoint | Scope | Token owner's role |
|---|---|---|
GET /billing/balance | billing:read | Admin |
GET /billing/grants | billing:read | Admin |
GET /billing/invoices | billing:read | Admin |
GET /billing/invoices/{id} | billing:read | Admin |
Billing is admin-only: the token owner must currently be an organization
Admin (403 insufficient_scope otherwise). Payments, payment methods,
credit purchases and billing-mode changes are handled in the portal.
Credit amounts are integer nano-USD (*_nanousd, 10⁻⁹ USD — exact),
with a convenience *_usd number alongside; invoices carry integer
cents in their own currency. Balances and invoices are views of the
same record as Usage; if an API response and an
issued invoice ever disagree, the invoice governs.
Python examples share this setup:
import os
import requests
BASE = "https://portal.<domain>/api/v1/mgmt"
s = requests.Session()
s.headers["Authorization"] = f"Bearer {os.environ['TF_PAT']}"Retrieve the balance
GET /api/v1/mgmt/billing/balanceThe organization's prepaid credit wallet — the balance every inference request is checked against.
| Field | Type | Notes |
|---|---|---|
available_nanousd | integer | Credit available, in nano-USD. |
available_usd | number | The same amount in USD, for display. |
currency | string | Always USD. |
wallet_present | boolean | false when the organization has never been granted credit. |
curl https://portal.<domain>/api/v1/mgmt/billing/balance \
-H "Authorization: Bearer $TF_PAT"{
"available_nanousd": 1835617883000,
"available_usd": 1835.617883,
"currency": "USD",
"wallet_present": true
}If billing data is temporarily unavailable the call is 502 upstream_unavailable — retry.
List credit grants
GET /api/v1/mgmt/billing/grantsEvery credit movement on the organization — grants, top-ups, refunds — newest first. Paginated.
| Field | Type | Notes |
|---|---|---|
id | string | A stable id for the row (grant_…). |
created_at | string | |
source | string | Where the credit came from, e.g. stripe (a top-up), signup, promo, admin_grant, refund. Treat it as an open set. |
memo | string | Human description. |
amount_nanousd | integer | Negative for refunds and reversals. |
amount_usd | number | The same amount in USD. |
reference | string | null | The payment reference for a top-up, when there is one. |
curl https://portal.<domain>/api/v1/mgmt/billing/grants \
-H "Authorization: Bearer $TF_PAT"{
"data": [
{
"id": "grant_9f2c41d07a5b3e18",
"created_at": "2026-09-01T12:00:00Z",
"source": "stripe",
"memo": "Credit top-up",
"amount_nanousd": 2000000000000,
"amount_usd": 2000,
"reference": "pi_3P…"
},
{
"id": "grant_1ab07c3de4f59260",
"created_at": "2026-03-02T09:41:17Z",
"source": "signup",
"memo": "Starter credit",
"amount_nanousd": 25000000000,
"amount_usd": 25,
"reference": null
}
],
"has_more": false,
"next_cursor": null
}List invoices
GET /api/v1/mgmt/billing/invoicesPaginated, newest first.
| Field | Type | Notes |
|---|---|---|
id | string | Opaque id. |
stripe_invoice_id | string | The payment provider's invoice id. |
amount_cents | integer | Invoice total in cents of currency. |
currency | string | |
status | string | The invoice status reported by the payment provider, e.g. open or paid. |
period_start, period_end | string | null | The billed period. |
pdf_url | string | null | The provider-hosted PDF, once issued. |
created_at | string |
curl https://portal.<domain>/api/v1/mgmt/billing/invoices \
-H "Authorization: Bearer $TF_PAT"{
"data": [
{
"id": "f0e1d2c3-b4a5-4968-8776-5a4b3c2d1e0f",
"stripe_invoice_id": "in_1Q…",
"amount_cents": 421193,
"currency": "usd",
"status": "paid",
"period_start": "2026-08-01T00:00:00Z",
"period_end": "2026-09-01T00:00:00Z",
"pdf_url": "https://…/invoice.pdf",
"created_at": "2026-09-01T02:00:00Z"
}
],
"has_more": false,
"next_cursor": null
}Retrieve an invoice
GET /api/v1/mgmt/billing/invoices/{id}Returns one invoice — the same object as a list row. An id that is not one
of your organization's invoices returns 404.
curl https://portal.<domain>/api/v1/mgmt/billing/invoices/f0e1d2c3-b4a5-4968-8776-5a4b3c2d1e0f \
-H "Authorization: Bearer $TF_PAT"Reconcile usage with billing
- Pull the period from
GET /usagewithfrom/toset to the invoice'speriod_start/period_end. - When the invoice's
currencyisusd, compare the usagetotals.cost_nanousdwith the invoice'samount_centsdirectly (1 cent = 10,000,000 nano-USD). - Between invoices, watch
GET /billing/balancefall as usage accrues.
Both sides are the same record, so this is a check, not a fix-up — if
they disagree, contact support. Quote the X-Request-Id of both responses.
Errors specific to billing
| Status | Code | When |
|---|---|---|
| 403 | insufficient_scope | Token lacks billing:read, or the owner is not currently an Admin. |
| 404 | not_found | Invoice absent or in another organization. |
| 422 | unsupported_filter | Any query parameter other than limit/cursor on the lists. |
| 502 | upstream_unavailable | Billing data (balance, grants) is temporarily unavailable. Retry. |