Legacy BillingQL
Run bounded, read-only billing queries from the REST API or TypeScript SDK.
Legacy (v1) API. This page describes the Stripe-first legacy API. It is still supported. v2 has its own query routes: POST /api/billstack/v2/teams/{teamId}/stripe-account/query reads the team's synced Stripe account copy with the same datasets, and POST /api/billstack/v2/teams/{teamId}/projects/{projectId}/query reads the project's canonical records (no payments dataset; invoices only where canonical invoices are enabled). See the v2 API.
BillingQL is a small SQL-like language for read-only queries over BillStack
billing data. It is available through the REST API, the TypeScript SDK, the
dashboard query workbench, and the query_billing_data MCP tool.
Request
Send a POST request to one of these endpoints:
/api/billstack/teams/{teamId}/query
/api/billstack/teams/{teamId}/projects/{projectId}/query{
"query": "SELECT invoices.invoice_id, invoices.amount, invoices.status FROM invoices WHERE invoices.status = :status LIMIT 50",
"parameters": { "status": "paid" },
"mode": "execute"
}mode can be validate, explain, or execute. Queries are limited to 500
rows and must use explicit fields. Supported datasets are customers,
subscriptions, invoices, products, prices, and payments. Payments
are currently team-scope only.
Invoice dates are ISO-8601 strings and invoice amounts are integer minor units
from the mirror's stored Stripe total. The result includes a stable column
description, rows, rowCount, truncated, and warnings.
Invoice example
SELECT invoices.invoice_id,
invoices.invoice_number,
invoices.customer_id,
invoices.invoice_date,
invoices.amount,
invoices.currency,
invoices.status,
invoices.paid,
invoices.hosted_invoice_url,
invoices.invoice_pdf
FROM invoices
WHERE invoices.invoice_date >= :from
AND invoices.invoice_date <= :to
ORDER BY invoices.invoice_date DESC
LIMIT 100Use ISO values such as 2026-01-01T00:00:00.000Z for from and to.
Data freshness
BillingQL reads the BillStack mirror. It does not fall back to live Stripe requests. During a first sync or backfill, results can be incomplete until the mirror catches up; the dashboard displays that caveat alongside the query workbench.