Prerequisites
- A Fluxrate account (sign up here)
- Your backend can make HTTP requests (any language)
Step 1 — Create a Meter
A meter defines what usage you want to track. Head to Dashboard → Features and create your first meter feature, or use the API:
curl -X POST https://api.fluxrate.co/api/v1/features \
-H "Content-Type: application/json" \
-H "Cookie: access_token=<your_token>" \
-d '{
"name": "API Calls",
"lookup_key": "api_calls",
"type": "meter",
"meter_name": "api_calls",
"property_name": "call_count",
"aggregation_type": "SUM",
"unit": "calls"
}'
Note the meter_token from the response — you’ll need it to send usage events.
Step 2 — Create a Plan
Plans define what customers pay. Create a usage-based plan that charges per API call:
curl -X POST https://api.fluxrate.co/api/v1/plans \
-H "Content-Type: application/json" \
-H "Cookie: access_token=<your_token>" \
-d '{
"name": "Starter",
"lookup_id": "starter",
"type": "USAGE",
"billing_interval": "month",
"currency": "USD"
}'
Then add the charge to the plan:
curl -X POST https://api.fluxrate.co/api/v1/plans/<plan_id>/charges \
-H "Content-Type: application/json" \
-H "Cookie: access_token=<your_token>" \
-d '{
"type": "USAGE",
"meter_id": "<your_meter_id>",
"unit_price": 0.001,
"display_name": "API Call Charge"
}'
Step 3 — Create a Customer
curl -X POST https://api.fluxrate.co/api/v1/customers \
-H "Content-Type: application/json" \
-H "Cookie: access_token=<your_token>" \
-d '{
"name": "Acme Corp",
"email": "billing@acme.com",
"external_id": "acme-corp-001"
}'
Step 4 — Subscribe the Customer
curl -X POST https://api.fluxrate.co/api/v1/subscriptions \
-H "Content-Type: application/json" \
-H "Cookie: access_token=<your_token>" \
-d '{
"customer_id": "<customer_id>",
"plan_id": "<plan_id>",
"billing_interval": "month",
"start_date": "2025-01-01T00:00:00Z"
}'
Step 5 — Generate an API Key
Go to Dashboard → API Keys and create a key with usage.write scope. This key is used to send usage events from your backend.
curl -X POST https://api.fluxrate.co/api/v1/api-keys \
-H "Content-Type: application/json" \
-H "Cookie: access_token=<your_token>" \
-d '{
"name": "Production SDK Key",
"scopes": ["usage.write"]
}'
Copy the returned API key — it is shown only once.
Step 6 — Track Usage Events
Send usage events from your backend using the SDK endpoint. Authenticate with your API key:
curl -X POST https://api.fluxrate.co/api/v1/sdk/track \
-H "Content-Type: application/json" \
-H "X-API-Key: org_live_<your_key>" \
-d '{
"meter_token": "<meter_token>",
"customer_external_id": "acme-corp-001",
"quantity": 150,
"idempotency_key": "req_unique_abc123"
}'
Always pass an idempotency_key to prevent duplicate events if your request retries.
Step 7 — Wait for the Invoice
When the subscription billing period ends, Fluxrate automatically:
- Calculates usage from all tracked events
- Creates a DRAFT invoice
- Waits 1 hour (grace period) for manual review
- Finalizes the invoice to OPEN status
- Emails the customer (if SMTP is configured)
You can also manually generate an invoice at any time:
curl -X POST https://api.fluxrate.co/api/v1/subscriptions/<subscription_id>/generate-invoice \
-H "Cookie: access_token=<your_token>"
You’re Ready! 🎉
Explore Plans
Fixed, usage, and hybrid pricing
Usage Analytics
Query and visualize usage data
API Reference
Full endpoint documentation