Skip to main content
#How To Create A UniBee Billable Metric

1. Overview

The Billing Metric module allows you to define and track billable business metrics such as API requests, storage usage, or AI token consumption.
The redesigned interface introduces template-based configuration, real-time previews, and clear contextual guidance to make metric setup faster and more intuitive.

🎯 Key Benefits

  • Lower learning curve – friendly field names and contextual explanations
  • Faster onboarding – quick-start templates for common billing use cases
  • Instant validation – live event and aggregation previews
  • Standardized model – consistent flow: Event β†’ Metric β†’ Aggregation β†’ Billing

2. Navigation

Access this module from the sidebar:
Product β†’ Billable Metric
The main list view displays all existing metrics, including:
  • Metric Name & Code
  • Aggregation Type (Count / Sum / Max / Unique)
  • Charge Type (Charge Metered / Charge Recurring)
  • Last Updated
  • Actions (✏️ Edit / πŸ—‘ Delete)

3. Create a New Metric

Click β€œ+ New Metric” to open the metric creation page.

3.1 Quick Templates

Predefined templates are provided for common billing scenarios.
Selecting a template will auto-fill key fields, but you can freely modify them.
TemplatePurposeAggregationUnit
API RequestsTrack API callsCountrequests
LLM TokensTrack token usageSumtokens
Worker DurationTrack task durationSumms
Storage GBTrack storage usageMaxGB
Emails SentTrack sent emailsCountemails
Unique UsersTrack active usersUniqueusers
CustomFully blank configurationanycustom

3.2 Basic Information

FieldDescriptionRequired
NameHuman-readable name (e.g. API Requests)βœ…
Code / SlugUnique identifier generated from the name (editable)βœ…
DescriptionOptional explanation of the metric purpose
Metric TypeLimit / Charge Metered / Charge Recurringβœ…
UnitUnit of measure (e.g. requests, tokens, GB, ms)βœ…
πŸ’‘ The Slug auto-generates from the Name and must be unique.

3.3 Event & Aggregation

FieldDescription
AggregationDefines how data is summarized: Count / Sum / Max / Min / Unique Count
Value PropertyNumeric field path, required for Sum/Max/Min types
Distinct ByUsed for Unique Count (e.g. user_id)
Labels to Group BySplit usage by dimensions (e.g. region, plan, customer_id)

Right-Side Preview Panel

  • Event Example: Live JSON event structure based on your form inputs
  • Aggregation Preview: Displays example calculations (e.g. 1 + 2 + 3 = 6 or max(10, 20, 30) = 30)
  • Quick Snippet: Auto-generated cURL / SDK example for developer use
  • Test It: Simulate an event and preview real-time calculation results
Highlight the right-side panels in color (Event Example – green, Aggregation Preview – blue, Quick Snippet – yellow).

4. API Integration β€” New Merchant Metric Event

Developers can send event data to UniBee Event API for automatic metric aggregation and billing.

Endpoint

⌘I