Base URL
Authentication
All requests require authentication using an API key in the request header:Endpoints
Single Event
Send a single event to Flexprice. Endpoint:POST /events
Headers:
- Status:
202 Accepted
- Body:
Bulk Events
Send multiple events in a single request for better performance. Endpoint:POST /events/bulk
Headers:
- Status:
202 Accepted
- Body:
Request Fields
Required Fields
Field | Type | Description | Example |
---|---|---|---|
event_name | string | Must exactly match your feature’s Event Name | "model.usage" |
external_customer_id | string | Your identifier for the customer | "cust_123" |
Conditional Fields
Field | Type | When Required | Description | Example |
---|---|---|---|---|
properties | object | For Sum, Max, Latest, Unique Count | Contains values to aggregate | {"credits": 2} |
properties.<field> | number/string | When aggregation field is set | Exact field name from feature config | 2 or "user_123" |
Optional Fields
Field | Type | Description | Example |
---|---|---|---|
event_id | string | Your unique identifier for the event | "evt_abc123" |
timestamp | string | ISO 8601 UTC timestamp | "2025-08-22T07:05:49.441Z" |
source | string | Origin of the event | "api" , "worker" |
Data Types
Property Values
-
Numbers: Use for Sum, Max aggregations
-
Strings: Use for Unique Count, Latest aggregations
Timestamps
- Format: ISO 8601 UTC
- Example:
"2025-08-22T07:05:49.441Z"
- Default: Server time if omitted
Examples
Basic Event (Count Aggregation)
Event with Properties (Sum Aggregation)
Complete Event
Bulk Events
Language Examples
JavaScript (Node.js)
Python
Go
PHP
Error Responses
HTTP Status Codes
Status | Description |
---|---|
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 |
Error Response Format
Common Error Messages
Missing Required Field
Invalid Event Name
Invalid Customer
Invalid JSON
Rate Limit Exceeded
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
Rate Limit Headers
When approaching rate limits, responses include headers:Best Practices
1. Error Handling
Implement proper error handling with retries:2. Bulk Events for High Volume
Use bulk events when sending many events:3. Idempotency
Use event_id for idempotency:4. Timestamps
Include timestamps for historical events:Validation
Event Name Validation
- Must match a feature’s Event Name exactly
- Case-sensitive
- Cannot be changed after feature creation
Customer Validation
- external_customer_id must exist in Flexprice
- Customer must be active
Property Validation
- Aggregation field must exist for Sum, Max, Latest, Unique Count
- Data types must match aggregation function requirements
Testing
Test Endpoint
For testing purposes, you can use the same endpoints with test data:Validation Checklist
Before sending production events:- Feature exists and is active
- Event Name matches exactly
- Customer exists in Flexprice
- Required properties are included
- Data types are correct
- API key has proper permissions
Support
For API-related issues:- Check error messages for specific details
- Verify your request format matches the examples
- Test with a simple event first
- Contact support with specific error details and examples