Addon Price UBB Configuration
In BillHive, usage-based billing configuration lives directly on addon prices with Per Unit Pricing or Volume Pricing models. There is no separate “metered feature” entity — the addon price itself defines how usage events are aggregated and billed.
Why Addon Price?
The addon price is the natural home for UBB configuration because:
- Pricing model (Per Unit, Volume) is defined at the addon price level
- Price, quantity (included units), and currency are already on the addon price
- Keeping aggregation config here avoids an extra linking step and simplifies setup
UBB Configuration Fields
When editing an addon price with Per Unit Pricing or Volume Pricing, a Usage-Based Billing configuration section appears with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
| Event Type | string | Yes | The usage event type to aggregate (e.g., api_call, storage_usage, message_sent) |
| Aggregation Method | enum | Yes | How to combine events: SUM, COUNT, MIN, MAX, or AVG |
| Aggregation Property | string | Conditional | The event property to aggregate. Required for SUM, MIN, MAX, AVG. Not needed for COUNT. |
| Filters | JSON | No | Key-value conditions to narrow the event stream (e.g., {"environment": "production"}) |
The addon price’s existing fields handle the pricing side:
| Existing Field | UBB Role |
|---|---|
| Quantity | Included quantity — units bundled at no extra charge |
| Price | Overage unit price — per-unit charge for consumption beyond included quantity |
Aggregation Methods
| Method | Description | Use Case | Aggregation Property |
|---|---|---|---|
| COUNT | Counts the number of matching events | API calls, messages, logins | Not required |
| SUM | Totals values of the specified property | Data transfer, tokens, minutes | Required |
| MIN | Minimum value observed during the period | Lowest balance, min utilization | Required |
| MAX | Maximum value observed during the period | Peak storage, high water mark | Required |
| AVG | Mean across all values | Average compute, avg response time | Required |
Filter Conditions
Filters narrow the aggregation to specific subsets of the usage event stream. Filters are specified as a JSON object where keys are event property names and values are the required values.
Examples
Bill only production API calls:
{"environment": "production"}Bill premium-tier storage:
{"tier": "premium"}Bill specific endpoint usage:
{"endpoint": "/v1/translate", "method": "POST"}Multiple key-value pairs are combined with AND logic — all conditions must match.
Configuration Walkthrough
Step 1: Create or Edit an Addon Price
- Navigate to Catalogue > Addons
- Select or create an addon
- Add or edit an addon price with Per Unit Pricing or Volume Pricing model
Step 2: Configure UBB Fields
When the pricing model is Per Unit or Volume, the Usage-Based Billing section appears in the addon price form:
- Event Type — Enter the event type that your application sends (e.g.,
api_call). This must match theevent_typefield in your usage events. - Aggregation Method — Select how events should be combined (COUNT, SUM, MIN, MAX, AVG)
- Aggregation Property — For SUM/MIN/MAX/AVG, specify which event property to aggregate (e.g.,
total_tokens,gb_used). This field is hidden for COUNT. - Filters — Optionally enter a JSON object to filter events (e.g.,
{"region": "us-east"})
Step 3: Set Pricing
Use the standard addon price fields:
- Quantity = Included quantity (units bundled at no extra charge). Set to
0for pure pay-as-you-go. - Price = Overage unit price (per-unit charge beyond included quantity)
Example Configurations
API Calls (COUNT-based)
| Field | Value |
|---|---|
| Event Type | api_call |
| Aggregation | COUNT |
| Agg Property | (not needed) |
| Filters | {"environment": "production"} |
| Quantity (included) | 10,000 |
| Price (overage) | $0.005 |
Result: First 10,000 production API calls free, then $0.005 per call.
Token Processing (SUM-based)
| Field | Value |
|---|---|
| Event Type | llm_request |
| Aggregation | SUM |
| Agg Property | total_tokens |
| Filters | (none) |
| Quantity (included) | 0 |
| Price (overage) | $0.00003 |
Result: Pure PAYG — every token is billed at $0.00003.
Peak Storage (MAX-based)
| Field | Value |
|---|---|
| Event Type | storage_snapshot |
| Aggregation | MAX |
| Agg Property | gb_used |
| Filters | {"tier": "premium"} |
| Quantity (included) | 50 |
| Price (overage) | $0.10 |
Result: First 50 GB included, overage billed at peak usage × $0.10/GB.
Multiple UBB Addons Per Subscription
A subscription can have multiple addon prices with UBB configuration, each tracking a different usage dimension independently. For example:
| Addon Price | Event Type | Aggregation | Included | Overage |
|---|---|---|---|---|
| API Calls | api_call | COUNT | 10,000 | $0.005 |
| Storage | storage_snapshot | MAX(gb_used) | 50 GB | $0.10 |
| Bandwidth | data_transfer | SUM(bytes) | 100 GB | $0.08 |
Each produces a separate usage aggregation record and invoice line item.
Billing Formula
At billing cycle end, BillHive computes for each UBB-configured addon price:
raw_quantity = AGGREGATE(matching events in billing period)
billable_qty = max(0, raw_quantity - included_quantity)
charge_amount = billable_qty × overage_unit_priceAutomatic Billing at Renewal
When a subscription renews, BillHive automatically computes usage aggregations and includes them in the renewal order as Addon order items with usage metadata. This section describes how addon price UBB configuration flows through to the order and invoice.
How Aggregations Become Order Items
During the renewal flow, the compute-usage-aggregations step evaluates each UBB-configured addon price on the subscription. For each addon price with billable usage (overage quantity > 0), an aggregation record is created and then added to the renewal order as an Addon order item with isMeteredUsage: true in its options.
Each order item is constructed from the aggregation as follows:
| Order Item Field | Source |
|---|---|
itemId | The addon price’s addonPriceId |
type | Addon (with isMeteredUsage: true in options) |
quantity | billableQuantity from the aggregation (overage after subtracting included quantity) |
amount | Computed charge amount (billableQuantity × overage unit price) |
options | Metadata object containing aggregation details (raw quantity, included quantity, aggregation method, event type, billing period) |
Aggregation Status Lifecycle
Each usage aggregation record has a status field that tracks its progress through billing:
| Status | Meaning |
|---|---|
COMPUTED | Aggregation has been calculated but not yet included in an order |
BILLED | Aggregation has been added to a renewal order; order_id is populated |
When the renewal order is created, the system updates each included aggregation record:
- Sets
statusfromCOMPUTEDtoBILLED - Sets
order_idto the newly created renewal order ID
This status tracking ensures aggregations are never double-billed and provides a clear audit trail linking each usage charge back to its order.
Example Flow
- Subscription has an addon price for API calls: COUNT aggregation on
api_callevents, 10,000 included, $0.005 overage - During the billing period, 15,000
api_callevents are ingested - At renewal, aggregation computes: raw = 15,000, included = 10,000, billable = 5,000, amount = $25.00
- Aggregation record is created with
status = COMPUTED - Renewal order is created with an Addon item (
isMeteredUsage: true):itemId= addon price ID, quantity = 5,000, amount = $25.00 - Aggregation record is updated:
status = BILLED,order_id= renewal order ID - Invoice is generated from the order, including the $25.00 usage line item
Best Practices
- Match event types exactly — The event type on the addon price must match the
event_typefield in your usage events exactly (case-sensitive) - Use COUNT for simple metering — When you just need to count occurrences, COUNT is simplest and doesn’t require an aggregation property
- Use SUM with quantity fallback — If no aggregation property is specified for SUM, BillHive falls back to summing the event’s
quantityfield - Keep filters simple — Use flat key-value JSON filters. Complex nested conditions are not supported.
- Test with Compute Now — Use the “Compute Now” button on the subscription’s Usage tab to preview aggregation results before the billing cycle runs