Quick Start
This guide walks you through creating a product, customer, subscription, and generating your first invoice. It assumes you’ve already installed RustBill via the installer.
1. Authenticate
Log in with the default admin credentials to get a session cookie:
curl -X POST http://localhost:3001/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@rustbill.local", "password": "admin123"}' \
-c cookies.txtAll subsequent requests use -b cookies.txt for session auth.
2. Create a Product
curl -X POST http://localhost:3001/api/products \
-b cookies.txt \
-H "Content-Type: application/json" \
-d '{
"name": "Pro Plan",
"productType": "saas",
"price": "49.99",
"status": "active"
}'3. Create a Customer
curl -X POST http://localhost:3001/api/customers \
-b cookies.txt \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corp",
"email": "billing@acme.com",
"company": "Acme Corporation",
"tier": "professional"
}'4. Create a Pricing Plan
curl -X POST http://localhost:3001/api/billing/plans \
-b cookies.txt \
-H "Content-Type: application/json" \
-d '{
"productId": "<product-uuid>",
"name": "Pro Monthly",
"pricingModel": "flat",
"billingCycle": "monthly",
"basePrice": "49.99",
"currency": "USD"
}'5. Create a Subscription
curl -X POST http://localhost:3001/api/billing/subscriptions \
-b cookies.txt \
-H "Content-Type: application/json" \
-d '{
"customerId": "<customer-uuid>",
"planId": "<plan-uuid>",
"billingCycle": "monthly"
}'6. Generate an Invoice
Invoices are auto-generated by the subscription lifecycle cron job. You can also create one manually:
curl -X POST http://localhost:3001/api/billing/invoices \
-b cookies.txt \
-H "Content-Type: application/json" \
-d '{
"customerId": "<customer-uuid>",
"subscriptionId": "<subscription-uuid>",
"lineItems": [
{
"description": "Pro Plan - Monthly",
"quantity": 1,
"unitPrice": "49.99"
}
]
}'What’s Next
- Set up payment providers for real payment processing
- Configure webhooks to receive billing events
- Explore the full API Reference
Last updated on