Skip to main content
Once you have created a metered feature, you can start transmitting events to Flexprice. Events are JSON payloads that describe usage activity and are transmitted via HTTP POST requests.

Prerequisites

  • A metered feature created in Flexprice
  • Your API key from the Admin Dashboard
  • The Event Name from your feature configuration

API Endpoints

Single Event

Bulk Events

Authentication

Include your API key in the request header:
Important: Keep your API key secure and never expose it in client-side code.

Event Payload Structure

Required Fields

Conditional Fields

Optional Fields

Single Event Examples

Basic Event (Count Aggregation)

If your feature uses Count aggregation, you only need the required fields:

Event with Properties (Sum Aggregation)

If your feature uses Sum aggregation with field credits:

Complete Event Example

cURL Examples

Single Event

cURL Event Ingestion Example

Response

Postman Event Ingestion Example

Bulk Events

Transmit multiple events in a single request for better performance:

Language Examples

JavaScript (Node.js)

Python

Go

PHP

Data Types and Best Practices

Property Values

  • Numbers: Use for Sum, Max aggregations
  • Strings: Use for Unique Count, Latest aggregations

Timestamps

  • Use ISO 8601 format in UTC
  • Example: "2025-08-22T07:05:49.441Z"
  • If omitted, server time is used

Event IDs

  • Optional but recommended for traceability
  • Should be unique within your system
  • Helps with debugging and idempotency

Common Patterns

API Usage Tracking

Storage Usage

User Activity

Error Handling

HTTP Status Codes

  • 202 Accepted: Event accepted for processing
  • 400 Bad Request: Invalid payload or missing required fields
  • 401 Unauthorized: Invalid or missing API key
  • 429 Too Many Requests: Rate limit exceeded

Common Errors

Missing required field
Invalid event_name
Invalid customer

Rate Limits

  • Single events: 1000 requests per minute
  • Bulk events: 100 requests per minute (up to 1000 events per request)
  • Response: 429 status code when exceeded

Best Practices

1. Validate Your Configuration

Before transmitting production events:
  • Verify Event Name matches your feature exactly
  • Confirm Aggregation Field exists in your events
  • Test with a small number of events first

2. Handle Failures Gracefully

3. Use Bulk Events for High Volume

When transmitting many events, use the bulk endpoint:

4. Include Relevant Metadata

Add useful properties to your events for debugging:

Next Steps

After sending events, you should:
  1. Validate Events - Verify that events are being processed correctly
  2. Connect to Billing - Set up pricing and subscriptions

Troubleshooting

”Event not found” error

  • Check that Event Name matches your feature exactly
  • Verify the feature exists and is active

”Customer not found” error

  • Ensure the customer exists in Flexprice
  • Check that external_customer_id matches exactly

”Missing required field” error

  • Verify all required fields are present
  • Check field names match exactly (case-sensitive)

Events not appearing in dashboard

  • Check the Event Debugger for processing status
  • Verify Event Name and Aggregation Field configuration
  • Ensure customer has an active subscription with the feature