Skip to content

Billing Rail

Usage metering and invoicing endpoints.

The Billing rail provides:

  • Usage metering
  • Invoice generation
  • Payment processing
  • Subscription management

Integrated with Stripe for payment processing.

POST /v1/billing/usage
const usage = await iof.billing.recordUsage({
workspaceId: "ws_123",
metric: "api_calls",
quantity: 1000,
timestamp: new Date(),
});
GET /v1/billing/usage
const usage = await iof.billing.getUsage({
workspaceId: "ws_123",
metric: "api_calls",
startDate: "2024-01-01",
endDate: "2024-01-31",
});

Response:

{
"metric": "api_calls",
"total": 45000,
"breakdown": [
{ "date": "2024-01-15", "quantity": 1500 },
{ "date": "2024-01-16", "quantity": 2000 }
]
}
POST /v1/billing/invoices
const invoice = await iof.billing.createInvoice({
workspaceId: "ws_123",
period: {
start: "2024-01-01",
end: "2024-01-31",
},
});

Response:

{
"id": "inv_abc",
"workspaceId": "ws_123",
"status": "draft",
"subtotal": 500,
"tax": 50,
"total": 550,
"lineItems": [
{ "description": "API Calls (45,000)", "amount": 450 },
{ "description": "Contracts (100)", "amount": 50 }
]
}
GET /v1/billing/invoices/:id
const invoice = await iof.billing.getInvoice("inv_abc");
POST /v1/billing/invoices/:id/pay
const payment = await iof.billing.payInvoice("inv_abc", {
paymentMethod: "pm_card_123",
});
MetricDescriptionUnit
api_callsAPI requestsCount
contractsContracts createdCount
kyc_checksKYC verificationsCount
storageData storageGB
StatusDescription
draftNot yet sent
openAwaiting payment
paidSuccessfully paid
voidCancelled
overduePast due date
EventDescription
billing.usage.recordedUsage recorded
billing.invoice.createdInvoice created
billing.invoice.paidInvoice paid
billing.invoice.overdueInvoice overdue