What is Lago?
Lago is an open-source billing platform for usage-based and subscription billing. It serves as a self-hosted alternative to Stripe Billing, Chargebee, and Recurly, providing metered billing, invoicing, and payment integration.
Docker Installation
git clone https://github.com/getlago/lago.git /opt/lago
cd /opt/lago
# Configure environment
cp .env.example .env
# Edit .env with your settings:
# LAGO_API_URL=https://api.billing.example.com
# LAGO_FRONT_URL=https://billing.example.com
# DATABASE_URL, REDIS_URL, etc.
docker compose up -d
Configuration
# Access the UI at http://YOUR_IP:80
# Create your organization
# Set up billing models:
# - Subscription plans (fixed monthly/annual)
# - Usage-based pricing (per API call, per GB, etc.)
# - Hybrid models (base + usage)
# Connect payment provider:
# Settings > Integrations > Stripe
# Enter your Stripe API keys
Key Features
- Usage-based metering with real-time event ingestion
- Subscription management with plan changes and prorations
- Automated invoice generation
- Stripe and GoCardless payment integration
- Webhook notifications for billing events
- REST API for programmatic billing management
- Credit notes and refunds
- Multi-currency support
Sending Usage Events
curl -X POST https://api.billing.example.com/api/v1/events \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"transaction_id": "unique-id-123",
"external_customer_id": "customer_001",
"code": "api_calls",
"timestamp": 1710500000,
"properties": {
"calls": 150
}
}'