// open source billing infrastructure
Usage-based metering and billing for SaaS. Self-hosted on your infra. Any pricing model. Python/FastAPI. 100% test coverage.
Currently being built with AI. Join the waitlist to get notified when we launch.
Every component chosen for production reliability, async performance, and developer experience.
Pure pay-as-you-go. Define a metric, create a plan with usage charges, subscribe a customer, and start sending events. bxb meters everything and generates invoices automatically.
$ curl -X POST https://api.boxbilling.com/v1/billable_metrics \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{
"name": "API Requests",
"code": "api_requests",
"aggregation_type": "sum",
"field_name": "tokens"
}'$ curl -X POST https://api.boxbilling.com/v1/plans \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{
"name": "Pay As You Go",
"code": "payg",
"interval": "monthly",
"amount_cents": 0,
"charges": [{
"billable_metric_code": "api_requests",
"charge_model": "standard",
"properties": { "amount": "0.001" }
}]
}'$ curl -X POST https://api.boxbilling.com/v1/subscriptions \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{
"customer_id": "cus_9a4b2",
"plan_code": "payg"
}'$ curl -X POST https://api.boxbilling.com/v1/events \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{
"transaction_id": "txn_8f3a1",
"customer_id": "cus_9a4b2",
"code": "api_requests",
"properties": { "tokens": 2340 }
}'$ curl https://api.boxbilling.com/v1/customers/cus_9a4b2/invoices \
-H "Authorization: Bearer $BXB_API_KEY"{
"total_amount_cents": 2340, // 2,340,000 tokens × $0.001
"currency": "USD",
"status": "finalized"
} Charge a recurring base fee plus metered usage on top. The most common model for SaaS — a monthly platform fee with overage charges when usage exceeds included amounts.
$ curl -X POST https://api.boxbilling.com/v1/plans \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{
"name": "Pro",
"code": "pro",
"interval": "monthly",
"amount_cents": 4900,
"charges": [{
"billable_metric_code": "api_requests",
"charge_model": "graduated",
"properties": {
"graduated_ranges": [
{ "from": 0, "to": 100000, "per_unit": "0" },
{ "from": 100001, "to": null, "per_unit": "0.0005" }
]
}
}]
}'$ curl -X POST https://api.boxbilling.com/v1/subscriptions \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{ "customer_id": "cus_9a4b2", "plan_code": "pro" }'# Send events exactly as before — bxb tracks everything
$ curl -X POST https://api.boxbilling.com/v1/events \
-d '{ "customer_id": "cus_9a4b2", "code": "api_requests", "properties": { "tokens": 250000 } }'{
"fees": [
{ "type": "subscription", "amount_cents": 4900 },
{ "type": "charge", "amount_cents": 7500,
"units": "150k tokens over 100k free tier" }
],
"total_amount_cents": 12400, // $49 + $75 overage
"currency": "USD"
} The full picture. Start with a free trial, apply a coupon code for a discount, charge a subscription base, and meter usage on top. All managed through the API.
$ curl -X POST https://api.boxbilling.com/v1/coupons \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{
"name": "Launch20",
"code": "LAUNCH20",
"discount_type": "percentage",
"discount_value": 20,
"duration": "recurring",
"duration_in_months": 3
}'$ curl -X POST https://api.boxbilling.com/v1/applied_coupons \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{
"customer_id": "cus_9a4b2",
"coupon_code": "LAUNCH20"
}'$ curl -X POST https://api.boxbilling.com/v1/subscriptions \
-H "Authorization: Bearer $BXB_API_KEY" \
-d '{
"customer_id": "cus_9a4b2",
"plan_code": "pro",
"trial_period_days": 14
}'# Customer can use the product during trial.
# Usage events are tracked but not billed until trial ends. {
"fees": [
{ "type": "subscription", "amount_cents": 4900 },
{ "type": "charge", "amount_cents": 7500 }
],
"subtotal_cents": 12400,
"coupons": [
{ "code": "LAUNCH20", "discount_cents": -2480 }
],
"total_amount_cents": 9920, // $124 - 20% = $99.20
"currency": "USD"
} Automatic, zero-config syncing. bxb pushes customers, subscriptions, invoices, and revenue events to the analytics tools your finance team already uses.
Subscription analytics and revenue reporting. Customer, subscription, and invoice data is pushed to ChartMogul automatically for MRR, churn, LTV, and cohort analysis.
Real-time revenue dashboards and forecasting. bxb pushes billing events automatically so Baremetrics can calculate MRR, ARR, trial conversions, and revenue forecasts.
Subscription financial metrics and retention analytics. bxb automatically syncs revenue recognition, churn analysis, and benchmarking data against industry peers.