Track Every Transaction,
Bill Every Second
Capture usage events in real-time with sub-second latency. Our metering API handles millions of events per day, aggregates them instantly, and applies your custom rating logic.
- Ingest millions of usage events per second
- Custom aggregation rules and rating engines
- Automatic deduplication and error handling
// Record usage with idempotency
await earnbill.usage.record({
idempotency_key: "evt_abc123",
customer_id: "cust_7yxz123",
metric: "compute_hours",
quantity: 42.5,
metadata: {
instance_type: "gpu_v100",
region: "us-east-1",
project_id: "proj_ml_training"
},
timestamp: "2024-12-29T10:30:00Z"
});
// Query usage in real-time
const usage = await earnbill.usage.query({
customer_id: "cust_7yxz123",
metric: "compute_hours",
start_date: "2024-12-01",
end_date: "2024-12-31"
});
// Create invoice for parent entity
const invoice = await earnbill.invoices.create({
entity_id: "ent_parent_corp",
billing_type: "consolidated",
line_items: [
{
description: "Subsidiary A - Usage",
quantity: 5000,
unit_price: 0.08,
entity_id: "ent_subsidiary_a"
},
{
description: "Subsidiary B - Usage",
quantity: 3200,
unit_price: 0.08,
entity_id: "ent_subsidiary_b"
}
],
currency: "USD",
tax_calculation: "automatic"
});
Complex Hierarchies,
Simple API
Manage parent-child relationships, wholesaler-reseller networks, and independent business entities through a single unified API. Consolidate or separate billing with ease.
- Unlimited hierarchy depth and complexity
- Flexible cost allocation and chargebacks
- Multi-currency, multi-lingual invoicing
From Flat Rate to
Quantum Computing
Support any pricing model: flat, tiered, volume, package, graduated, per-unit, hybrid, or custom. Mix and match models within a single plan.
- Pre-built pricing models for any industry
- Custom rating engines with business logic
- Dynamic pricing based on real-time conditions
// Create complex hybrid pricing
const plan = await earnbill.plans.create({
name: "Enterprise AI Platform",
components: [
{
name: "Base Platform Fee",
pricing_model: "flat",
amount: 999
},
{
name: "API Calls",
pricing_model: "graduated",
tiers: [
{ up_to: 10000, price: 0 },
{ up_to: 100000, price: 0.01 },
{ up_to: null, price: 0.005 }
]
},
{
name: "GPU Compute",
pricing_model: "per_unit",
unit_price: 2.50,
unit: "hour"
}
]
});
// Webhooks for real-time events
const handleWebhook = async (req, res) => {
const event = earnbill.webhooks.verify(
req.body,
req.headers['earnbill-signature']
);
switch (event.type) {
case 'invoice.payment_succeeded':
await fulfillOrder(event.data);
break;
case 'subscription.updated':
await updateAccess(event.data);
break;
case 'usage.threshold_exceeded':
await notifyCustomer(event.data);
break;
}
res.json({ received: true });
};
Built for Developers,
Loved by Enterprises
RESTful APIs, comprehensive SDKs, webhook events, sandbox environments, and detailed documentation. Everything you need to integrate in hours, not weeks.
- SDKs for Node.js, Python, Ruby, PHP, .NET, Go
- Full sandbox environment for testing
- Webhook events for all billing actions
Enterprise-Grade Security
Bank-level security with comprehensive compliance certifications
SOC 2 Type II
Audited security controls
ISO 27001
Information security certified
PCI DSS
Payment card compliant
GDPR Ready
Privacy by design
Data Encryption
AES-256 encryption at rest, TLS 1.3 in transit. All API keys encrypted with hardware security modules.
Access Control
Role-based access control, SSO integration, API key scoping, and comprehensive audit logs.
Infrastructure
Multi-region deployment, automatic failover, daily backups, and 99.99% uptime SLA.
Get Started in Minutes
Follow these steps to integrate EarnBill into your application
Sign Up & Get API Keys
Create your account and generate API keys from the dashboard. Use test mode for development.
# Install the SDK
npm install @earnbill/node-sdk
Initialize the Client
Configure the SDK with your API key and environment.
const EarnBill = require('@earnbill/node-sdk');
const earnbill = new EarnBill({
apiKey: process.env.EARNBILL_API_KEY,
environment: 'test' // or 'production'
});
Create a Customer
Set up your first customer account.
const customer = await earnbill.customers.create({
email: '[email protected]',
name: 'Sample Company',
metadata: {
internal_id: 'acme_123'
}
});
Define a Pricing Plan
Create a pricing plan with your billing model.
const plan = await earnbill.plans.create({
name: 'Professional Plan',
billing_cycle: 'monthly',
base_price: 99.00,
currency: 'USD'
});
Create a Subscription
Subscribe the customer to the plan.
const subscription = await earnbill.subscriptions.create({
customer_id: customer.id,
plan_id: plan.id,
start_date: new Date()
});
Record Usage
Track customer usage in real-time.
await earnbill.usage.record({
subscription_id: subscription.id,
metric: 'api_calls',
quantity: 100,
timestamp: new Date()
});
Handle Webhooks
Listen for billing events in your application.
app.post('/webhooks/earnbill', async (req, res) => {
const event = earnbill.webhooks.verify(
req.body,
req.headers['earnbill-signature']
);
// Handle the event
console.log('Received event:', event.type);
res.sendStatus(200);
});
Comprehensive API Reference
Complete documentation for all endpoints, with examples in multiple languages
Core Resources
Advanced Features
Ready to Build with EarnBill?
Start integrating in minutes with our comprehensive APIs and developer tools