What is Event Ingestion?
When you have a Metered Feature in Flexprice (such as API calls, storage usage, or credits consumed), you need to inform Flexprice when and how much your customers are utilizing that feature. This is accomplished by transmitting events - JSON payloads that describe usage activity.How It Works
- Create a Metered Feature - Define what you want to track (e.g., “model.usage”, “api.calls”)
- Send Events - Your application transmits usage data to Flexprice via API
- Validate Events - Verify that events are being processed correctly
- Connect to Billing - Link the feature to a pricing plan and customer subscription
- Automatic Invoicing - Flexprice calculates charges and generates invoices
Key Concepts
Event
A JSON payload containing usage information:- Who used the feature (
external_customer_id
) - What feature was used (
event_name
) - How much was used (
properties
) - When it happened (
timestamp
)
Aggregation
How Flexprice combines multiple events into a single quantity for billing (see Aggregation Overview for detailed explanations):- Count - Number of events
- Sum - Total of a numeric property
- Average - Mean value of a numeric property
- Count Unique - Number of distinct values
- Latest - Most recent value
- Sum with Multiplier - Sum with rate conversion
- Max - Highest value seen (supports bucketing)
- Weighted Sum - Time-weighted sum for capacity billing
Usage Reset
How usage accumulates over time:- Periodic - Resets each billing cycle (e.g., monthly API calls)
- Cumulative - Keeps growing (e.g., total storage used)
Quick Start
Follow these steps to get started with event ingestion:- Create Your First Metered Feature - Set up what you want to track
- Send Your First Event - Learn how to send usage data
- Validate and Debug - Ensure events are working correctly
- Connect to Billing - Turn usage into invoices
Common Use Cases
- API Usage - Track API calls, requests, or tokens consumed
- Storage - Monitor file storage, database usage, or bandwidth
- AI/ML - Count model inferences, training hours, or data processed
- User Activity - Track logins, feature usage, or time spent
- Compute Resources - Monitor CPU time, memory usage, or GPU hours
What You’ll Learn
This guide will walk you through the complete event ingestion workflow, from setting up your first metered feature to viewing charges on customer invoices. By the end, you’ll understand:- How to configure metered features correctly
- The exact format for sending events
- How to verify that events are being processed
- How usage flows into billing and invoicing
- Common pitfalls and how to avoid them
Related Documentation
- Features Overview - Learn about different feature types
- Plans - Understand pricing plan configuration
- Subscriptions - Manage customer subscriptions
- Invoices - View and manage billing