Billable Units
Define what you charge for — API calls, tokens, sessions, storage, or any custom metric — with Aforo's billable units system.
Billable Units
Billable Units (internally called metrics) define what you charge for. They are the atomic measurement unit that your usage events report against and your rate plans price.
Every charge in Aforo traces back to a billable unit — whether that's an API call, an LLM token, an active session, GB of storage, or a custom dimension you define.
Built-in Templates
Aforo ships with pre-built templates for each product type:
Standard API
AI Agent
MCP Server
Agentic API
Aggregation Types
Custom Billable Units
Create a custom unit when a template doesn't fit your pricing model:
- Go to Catalog → Billable Units
- Click + New Billable Unit
- Set:
- Name — e.g. "Compute Minutes"
- Unit Label — e.g. "minutes"
- Aggregation — how events roll up (COUNT, SUM, UNIQUE, etc.)
- Event Field — the numeric field from your event payload to aggregate
- Product Types — which product types can use this unit
You cannot change a unit's aggregation type after it has been used in a rate plan. Create a new unit if you need a different aggregation method.
Filtering
Custom units support filter conditions to narrow which events count. For example, only count API calls where status_code < 400:
{
"filterConditions": [
{
"field": "status_code",
"operator": "LESS_THAN",
"value": "400"
}
]
}
Supported operators: EQUALS, NOT_EQUALS, GREATER_THAN, LESS_THAN, CONTAINS, NOT_CONTAINS, IN, NOT_IN
Product Associations
Billable units can be associated with multiple products (M:N relationship). A unit like "Input Tokens" can price both your AI Agent product and your Agentic API product.
Deletion Protection
Like products, billable units are protected from deletion when used in active rate plans. The check returns ALLOW, WARN, or BLOCK — and BLOCK requires migrating subscribers before proceeding.
Bulk Operations
Bulk Create from Templates
curl -X POST https://catalog.aforo.ai/api/v1/metrics/bulk \
-H "Authorization: Bearer $AFORO_API_KEY" \
-H "X-Tenant-Id: $TENANT_ID" \
-d '{ "productType": "AI_AGENT" }'
This seeds all 8 standard templates for AI Agent in one call.
Export / Import
Export all active units for backup or migration:
curl https://catalog.aforo.ai/api/v1/metrics/export \
-H "Authorization: Bearer $AFORO_API_KEY" \
-H "X-Tenant-Id: $TENANT_ID" > units.json
Import into another tenant with skipDuplicates: true to avoid conflicts.