Billing API
Full billing dashboard backend for the LVNG platform. Query credit balances and burn rates, view aggregated usage charts, configure auto-reload, manage payment methods, download invoices, and set up spending alerts. All endpoints require JWT authentication.
Base path: /api/v2/billing
Balance & Usage
Query current credit balance, burn rate, and aggregated usage data for charts.
/api/v2/billing/balanceAuthenticatedGet current credit balance, included and purchased credits, and the burn rate (average credits per hour over the last 24 hours).
Request
400">curl -X 400">GET https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/balance \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": {
400">class="text-emerald-400">"balance": 4250.00,
400">class="text-emerald-400">"included_credits": 5000,
400">class="text-emerald-400">"purchased_credits": 2000,
400">class="text-emerald-400">"burn_rate_per_hour": 12.50,
400">class="text-emerald-400">"updated_at": 400">class="text-emerald-400">"2026-04-01T12:00:00.000Z"
}
}/api/v2/billing/usage-chartAuthenticatedGet aggregated usage data for dashboard charts, broken down by day and model.
Query Parameters
startstringrequiredStart date in ISO 8601 format.
endstringrequiredEnd date in ISO 8601 format.
granularitystringAggregation granularity: "day" (default) or "week".
Request
400">curl -X 400">GET 400">class="text-emerald-400">"https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/usage-chart?start=2026-03-01&end=2026-04-01&granularity=day" \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": {
400">class="text-emerald-400">"daily_usage": [
{ 400">class="text-emerald-400">"date": 400">class="text-emerald-400">"2026-03-01", 400">class="text-emerald-400">"credits": 45.20, 400">class="text-emerald-400">"requests": 120 },
{ 400">class="text-emerald-400">"date": 400">class="text-emerald-400">"2026-03-02", 400">class="text-emerald-400">"credits": 38.10, 400">class="text-emerald-400">"requests": 95 }
],
400">class="text-emerald-400">"model_breakdown": [
{ 400">class="text-emerald-400">"model": 400">class="text-emerald-400">"claude-sonnet", 400">class="text-emerald-400">"credits": 520, 400">class="text-emerald-400">"requests": 1800 },
{ 400">class="text-emerald-400">"model": 400">class="text-emerald-400">"claude-haiku", 400">class="text-emerald-400">"credits": 85, 400">class="text-emerald-400">"requests": 3200 }
]
}
}Auto-Reload
Configure automatic credit top-up when your balance drops below a threshold.
/api/v2/billing/auto-reloadAuthenticatedGet current auto-reload configuration.
Request
400">curl -X 400">GET https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/auto-reload \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": {
400">class="text-emerald-400">"enabled": true,
400">class="text-emerald-400">"threshold_credits": 500,
400">class="text-emerald-400">"reload_amount": 5000,
400">class="text-emerald-400">"payment_method_id": 400">class="text-emerald-400">"pm_abc123",
400">class="text-emerald-400">"updated_at": 400">class="text-emerald-400">"2026-03-15T10:00:00.000Z"
}
}/api/v2/billing/auto-reloadAuthenticatedCreate or update auto-reload configuration. Upserts on user_id.
Body Parameters
enabledbooleanWhether auto-reload is active. Defaults to false.
threshold_creditsnumberCredit balance threshold that triggers a reload. Must be non-negative. Defaults to 500.
reload_amountnumberNumber of credits to add on reload. Must be positive. Defaults to 5000.
payment_method_idstringUUID of the payment method to charge.
Request
400">curl -X 400">POST https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/auto-reload \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY" \
-H 400">class="text-emerald-400">"Content-Type: application/json" \
-d '{
400">class="text-emerald-400">"enabled": true,
400">class="text-emerald-400">"threshold_credits": 1000,
400">class="text-emerald-400">"reload_amount": 10000,
400">class="text-emerald-400">"payment_method_id": 400">class="text-emerald-400">"pm_abc123"
}'Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": {
400">class="text-emerald-400">"user_id": 400">class="text-emerald-400">"a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
400">class="text-emerald-400">"enabled": true,
400">class="text-emerald-400">"threshold_credits": 1000,
400">class="text-emerald-400">"reload_amount": 10000,
400">class="text-emerald-400">"payment_method_id": 400">class="text-emerald-400">"pm_abc123",
400">class="text-emerald-400">"updated_at": 400">class="text-emerald-400">"2026-04-01T12:00:00.000Z"
}
}Spending Alerts
Create alerts to be notified when spending exceeds a threshold over a given period. Optionally set a hard cap to block usage.
/api/v2/billing/alertsAuthenticatedCreate a spending alert for a given period.
Body Parameters
periodstringrequiredAlert period: "daily", "weekly", or "monthly".
threshold_creditsnumberrequiredCredit threshold that triggers the alert. Must be positive.
hard_capbooleanIf true, blocks usage when threshold is reached. Defaults to false.
workspace_idstringScope alert to a specific workspace.
Request
400">curl -X 400">POST https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/alerts \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY" \
-H 400">class="text-emerald-400">"Content-Type: application/json" \
-d '{
400">class="text-emerald-400">"period": 400">class="text-emerald-400">"daily",
400">class="text-emerald-400">"threshold_credits": 500,
400">class="text-emerald-400">"hard_cap": false
}'Response 201
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": {
400">class="text-emerald-400">"id": 400">class="text-emerald-400">"alert_abc123",
400">class="text-emerald-400">"user_id": 400">class="text-emerald-400">"a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11",
400">class="text-emerald-400">"period": 400">class="text-emerald-400">"daily",
400">class="text-emerald-400">"threshold_credits": 500,
400">class="text-emerald-400">"hard_cap": false,
400">class="text-emerald-400">"workspace_id": null,
400">class="text-emerald-400">"created_at": 400">class="text-emerald-400">"2026-04-01T12:00:00.000Z"
}
}/api/v2/billing/alertsAuthenticatedList all spending alerts for the authenticated user.
Request
400">curl -X 400">GET https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/alerts \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": [
{
400">class="text-emerald-400">"id": 400">class="text-emerald-400">"alert_abc123",
400">class="text-emerald-400">"period": 400">class="text-emerald-400">"daily",
400">class="text-emerald-400">"threshold_credits": 500,
400">class="text-emerald-400">"hard_cap": false,
400">class="text-emerald-400">"workspace_id": null,
400">class="text-emerald-400">"created_at": 400">class="text-emerald-400">"2026-04-01T12:00:00.000Z"
}
]
}/api/v2/billing/alerts/:idAuthenticatedDelete a spending alert.
Path Parameters
idstringrequiredUUID of the alert to delete.
Request
400">curl -X 400">DELETE https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/alerts/alert_abc123 \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"message": 400">class="text-emerald-400">"Alert deleted"
}Invoices
List and download billing invoices.
/api/v2/billing/invoicesAuthenticatedList all invoices for the authenticated user, ordered by period end date (newest first).
Request
400">curl -X 400">GET https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/invoices \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": [
{
400">class="text-emerald-400">"id": 400">class="text-emerald-400">"inv_abc123",
400">class="text-emerald-400">"period_start": 400">class="text-emerald-400">"2026-03-01",
400">class="text-emerald-400">"period_end": 400">class="text-emerald-400">"2026-03-31",
400">class="text-emerald-400">"subscription_amount": 49.00,
400">class="text-emerald-400">"credits_included": 5000,
400">class="text-emerald-400">"credits_used": 6200,
400">class="text-emerald-400">"overage_credits": 1200,
400">class="text-emerald-400">"overage_amount": 12.00,
400">class="text-emerald-400">"total_amount": 61.00,
400">class="text-emerald-400">"status": 400">class="text-emerald-400">"paid",
400">class="text-emerald-400">"created_at": 400">class="text-emerald-400">"2026-04-01T00:00:00.000Z"
}
]
}/api/v2/billing/invoices/:id/downloadAuthenticatedDownload invoice data as a JSON file. Returns with Content-Disposition header for file download.
Path Parameters
idstringrequiredUUID of the invoice.
Request
400">curl -X 400">GET https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/invoices/inv_abc123/download \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY" \
-o invoice.jsonResponse 200
{
400">class="text-emerald-400">"invoice_id": 400">class="text-emerald-400">"inv_abc123",
400">class="text-emerald-400">"period_start": 400">class="text-emerald-400">"2026-03-01",
400">class="text-emerald-400">"period_end": 400">class="text-emerald-400">"2026-03-31",
400">class="text-emerald-400">"subscription_amount": 49.00,
400">class="text-emerald-400">"credits_included": 5000,
400">class="text-emerald-400">"credits_used": 6200,
400">class="text-emerald-400">"overage_credits": 1200,
400">class="text-emerald-400">"overage_amount": 12.00,
400">class="text-emerald-400">"total_amount": 61.00,
400">class="text-emerald-400">"status": 400">class="text-emerald-400">"paid",
400">class="text-emerald-400">"created_at": 400">class="text-emerald-400">"2026-04-01T00:00:00.000Z"
}Payment Methods
Manage payment methods on file. Stripe integration ready.
/api/v2/billing/payment-methodsAuthenticatedAdd a payment method. Currently supports card type with brand, last four digits, and expiration.
Body Parameters
brandstringrequiredCard brand (e.g. "visa", "mastercard").
last_fourstringrequiredLast 4 digits of the card number.
exp_monthnumberrequiredExpiration month (1-12).
exp_yearnumberrequiredExpiration year (must not be in the past).
is_defaultbooleanSet as default payment method. Defaults to false.
Request
400">curl -X 400">POST https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/payment-methods \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY" \
-H 400">class="text-emerald-400">"Content-Type: application/json" \
-d '{
400">class="text-emerald-400">"brand": 400">class="text-emerald-400">"visa",
400">class="text-emerald-400">"last_four": 400">class="text-emerald-400">"4242",
400">class="text-emerald-400">"exp_month": 12,
400">class="text-emerald-400">"exp_year": 2028,
400">class="text-emerald-400">"is_default": true
}'Response 201
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": {
400">class="text-emerald-400">"id": 400">class="text-emerald-400">"pm_abc123",
400">class="text-emerald-400">"400">type": 400">class="text-emerald-400">"card",
400">class="text-emerald-400">"brand": 400">class="text-emerald-400">"visa",
400">class="text-emerald-400">"last_four": 400">class="text-emerald-400">"4242",
400">class="text-emerald-400">"exp_month": 12,
400">class="text-emerald-400">"exp_year": 2028,
400">class="text-emerald-400">"is_default": true,
400">class="text-emerald-400">"created_at": 400">class="text-emerald-400">"2026-04-01T12:00:00.000Z"
}
}/api/v2/billing/payment-methodsAuthenticatedList all payment methods for the authenticated user.
Request
400">curl -X 400">GET https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/payment-methods \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"data": [
{
400">class="text-emerald-400">"id": 400">class="text-emerald-400">"pm_abc123",
400">class="text-emerald-400">"400">type": 400">class="text-emerald-400">"card",
400">class="text-emerald-400">"brand": 400">class="text-emerald-400">"visa",
400">class="text-emerald-400">"last_four": 400">class="text-emerald-400">"4242",
400">class="text-emerald-400">"exp_month": 12,
400">class="text-emerald-400">"exp_year": 2028,
400">class="text-emerald-400">"is_default": true,
400">class="text-emerald-400">"created_at": 400">class="text-emerald-400">"2026-04-01T12:00:00.000Z"
}
]
}/api/v2/billing/payment-methods/:idAuthenticatedRemove a payment method. Verifies ownership before deletion.
Path Parameters
idstringrequiredUUID of the payment method.
Request
400">curl -X 400">DELETE https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/payment-methods/pm_abc123 \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"message": 400">class="text-emerald-400">"Payment method deleted"
}Swarm Compute
Get swarm compute billing totals for a workspace.
/api/v2/billing/swarm-computeAuthenticatedGet swarm compute billing totals for a workspace over a date range. Defaults to the current calendar month.
Query Parameters
workspace_idstringrequiredUUID of the workspace.
startstringStart date (ISO 8601). Defaults to first of current month.
endstringEnd date (ISO 8601). Defaults to now.
Request
400">curl -X 400">GET 400">class="text-emerald-400">"https:400">class="text-zinc-500">//api.lvng.ai/api/v2/billing/swarm-compute?workspace_id=ws_abc123&start=2026-03-01&end=2026-04-01" \
-H 400">class="text-emerald-400">"Authorization: Bearer YOUR_API_KEY"Response 200
{
400">class="text-emerald-400">"success": true,
400">class="text-emerald-400">"total_compute_credits": 1250,
400">class="text-emerald-400">"total_tasks": 48,
400">class="text-emerald-400">"by_agent": [
{ 400">class="text-emerald-400">"agent_id": 400">class="text-emerald-400">"agt_001", 400">class="text-emerald-400">"agent_name": 400">class="text-emerald-400">"Research Agent", 400">class="text-emerald-400">"credits": 800, 400">class="text-emerald-400">"tasks": 30 },
{ 400">class="text-emerald-400">"agent_id": 400">class="text-emerald-400">"agt_002", 400">class="text-emerald-400">"agent_name": 400">class="text-emerald-400">"Data Processor", 400">class="text-emerald-400">"credits": 450, 400">class="text-emerald-400">"tasks": 18 }
]
}