Usage-based billing lets you charge customers based on what they actually consume rather than a flat subscription price. This model is common for API products, compute services, messaging platforms, and any product where usage varies between customers.
mavi pay provides a complete metering and billing pipeline: you define meters, ingest usage events via API, and mavi pay calculates charges at the end of each billing cycle.
A meter defines what you are measuring. Each meter has a name, a unit (e.g., "API calls", "messages", "GB"), and an aggregation method.
Create meters in your dashboard under Usage Billing > Meters or via the API.
| Field | Description |
|---|---|
| Name | Human-readable name (e.g., "API Requests"). |
| Event name | The identifier used when ingesting events (e.g., api_request). |
| Unit | The unit of measurement (e.g., "requests", "messages", "GB"). |
| Aggregation | How events are counted: sum, count, or max. |
Events are the raw usage data points. Each event has a timestamp, a customer ID, a meter event name, and an optional numeric value.
At the end of each billing cycle (monthly by default), mavi pay aggregates all events for each customer, calculates the total usage per meter, applies your pricing tiers, and creates an invoice.
Send usage events to the mavi pay API as they occur in your application. Events are processed asynchronously and do not block your application.
POST https://api.mavifinans.sh/api/v1/usage/events
{
"events": [
{
"customer_id": "cus_xxxxxxxx",
"event_name": "api_request",
"timestamp": "2026-03-30T12:00:00Z",
"value": 1
}
]
}Include your API key in the Authorization header:
curl -X POST https://api.mavifinans.sh/api/v1/usage/events \
-H "Authorization: Bearer <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"customer_id": "cus_xxxxxxxx",
"event_name": "api_request",
"timestamp": "2026-03-30T12:00:00Z",
"value": 1
}
]
}'You can send events individually or in batches of up to 1,000 events per request. Batching is recommended for high-volume applications.
When you attach a meter to a product, you define how usage translates to charges:
A flat rate per unit of usage. For example, EUR 0.001 per API request.
Different rates for different usage brackets. For example:
| Tier | Range | Price per unit |
|---|---|---|
| 1 | 0 -- 10,000 requests | EUR 0.002 |
| 2 | 10,001 -- 100,000 requests | EUR 0.001 |
| 3 | 100,001+ requests | EUR 0.0005 |
You can include a number of free units per billing cycle. Only usage above the included amount is charged. This is useful for freemium models where a base tier includes a usage allowance.
From the dashboard, you can: