HTTP API Ingestion
Mixpanel’s HTTP API provides direct access to ingest events and user profile data. Use the API when:- You need to send data from a language without an SDK
- You want full control over the data being sent
- You’re building a custom integration
- You need to import historical data
API Endpoints
Mixpanel provides different API endpoints based on your project’s data residency:| Data Residency | Base URL |
|---|---|
| US (default) | https://api.mixpanel.com |
| EU | https://api-eu.mixpanel.com |
| India | https://api-in.mixpanel.com |
Track Events: /track
The /track endpoint ingests events in real-time. Use this for events that occurred within the last 5 days.
Endpoint
Request Format
Headers:Required Properties
| Property | Type | Description |
|---|---|---|
event | String | The name of the event |
properties.token | String | Your Mixpanel project token |
properties.distinct_id | String | Unique identifier for the user |
Common Optional Properties
| Property | Type | Description |
|---|---|---|
properties.time | Number | Unix timestamp (milliseconds) when event occurred |
properties.$insert_id | String | Unique ID to deduplicate events |
properties.ip | String | IP address for geolocation (use 0 to skip) |
properties.$device_id | String | Device identifier for anonymous tracking |
Example: Track Event with cURL
Example: Track Event with Python
Batch Tracking
You can send multiple events in a single request:Maximum batch size is 2000 events per request.
Import Historical Events: /import
The /import endpoint is designed for importing events older than 5 days. It requires authentication with your API secret.
Endpoint
Authentication
Use HTTP Basic Auth with your API secret:Find Your API Secret
- Navigate to Project Settings
- Under Access Keys, find your Project Secret
Example: Import with Python
User Profile Updates: /engage
The /engage endpoint updates user profile properties.
Endpoint
Set Profile Properties
Profile Operations
| Operation | Description |
|---|---|
$set | Set properties (overwrites existing) |
$set_once | Set properties only if they don’t exist |
$add | Increment numeric properties |
$append | Append to list properties |
$union | Add to list only if not present |
$remove | Remove from list properties |
$unset | Delete properties |
$delete | Delete the entire profile |
Example: Multiple Operations
Identity Management
Simplified ID Merge
Link an anonymous user to a known user ID:device_xyz into the user_123 profile.
Best Practices
Use $insert_id to Prevent Duplicates
Use $insert_id to Prevent Duplicates
Include a unique Mixpanel will reject duplicate events with the same
$insert_id for each event to prevent duplicates:$insert_id within 24 hours.Handle IP Address for Geolocation
Handle IP Address for Geolocation
By default, Mixpanel uses the request IP for geolocation. For server-side tracking:Pass the client IP:Skip geolocation:
Batch Requests for Performance
Batch Requests for Performance
Send multiple events in a single request to improve performance:
- Maximum 2000 events per batch
- Reduces network overhead
- Improves throughput
Handle Rate Limits
Handle Rate Limits
Mixpanel has rate limits to ensure service reliability:
- 60 requests per hour for the
/importendpoint per project - 2000 events per request maximum batch size
Validate Responses
Validate Responses
Always check the API response:Success Response:Error Response:
Common Issues & Troubleshooting
Events not appearing in Mixpanel
Events not appearing in Mixpanel
- Check project token: Verify you’re using the correct token
- Verify data residency: Ensure you’re using the correct API endpoint
- Check timestamp: Events older than 5 days won’t be accepted by
/track - Look for errors: Check the API response for error messages
- View Events page: Check the Events view in Mixpanel
401 Unauthorized errors
401 Unauthorized errors
413 Request Entity Too Large
413 Request Entity Too Large
- Your batch is too large (>2000 events)
- Split into smaller batches
- Individual events might be too large (>2MB)
Geolocation is wrong
Geolocation is wrong
- If tracking from a server, pass the client’s IP in the
ipproperty - Set
ipto"0"to skip geolocation - See geolocation best practices
API Reference
For complete API documentation, see:Next Steps
Best Practices
Learn implementation best practices
View SDKs
Use our SDKs for easier implementation