Ingestion API
Events
Track user events and behaviors
POST
Events
Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mixpanel/docs/llms.txt
Use this file to discover all available pages before exploring further.
Track Events
Events represent user actions in your application. Use the Ingestion API to send events to Mixpanel for analysis.Import Events
The Import API provides server-side event tracking with full validation and detailed error reporting.Your Mixpanel project ID (required when using service account authentication)
When set to
1 (recommended), Mixpanel validates the batch and returns errors per event that failed.Options: 0 or 1The content type of the request body.Options:
application/json: Standard JSON arrayapplication/x-ndjson: Newline-delimited JSON
Compression method for the request body.Options:
gzipRequest Body
The name of the event (e.g., “Signed Up”, “Purchase Complete”)
Event properties object
Example Request
Response
HTTP status code (200 for success)
Number of events successfully imported
Status message (“OK” for success)
Array of failed events (only present when strict=1 and some events failed)
Track Events (Client-Side)
The Track API is designed for client-side event tracking using your project token.If set to
1, uses the IP address of the request to determine geolocationIf set to
1, returns a verbose JSON response instead of simple 1 or 0Request Body
The name of the event
Event properties
Example Request
Response
Returns1 for success, 0 for failure.
Best Practices
Always use $insert_id for deduplication
Always use $insert_id for deduplication
This ensures events aren’t duplicated if a request is retried:
Use server-side tracking when possible
Use server-side tracking when possible
The Import API provides:
- Better validation and error reporting
- More secure (credentials not exposed to clients)
- Support for historical data imports
Batch events for better performance
Batch events for better performance
Send up to 2000 events per request:
Use meaningful event names
Use meaningful event names
Use clear, consistent naming:
- Good: “Signed Up”, “Purchase Completed”, “Video Played”
- Bad: “event1”, “action”, “e”
Include relevant context in properties
Include relevant context in properties
Add properties that help analyze the event:
Common Errors
Invalid timestamp
Invalid timestamp
Error:
'properties.time' is invalid: must be specified as seconds since epochSolution: Ensure timestamps are in seconds (not milliseconds) or milliseconds (with 13 digits)Missing required fields
Missing required fields
Error: Various validation errorsSolution: Ensure all required fields are present:
eventnameproperties.distinct_idproperties.timeproperties.$insert_id(for /import)
Payload too large
Payload too large
Error:
request exceeds max limit of 2097152 bytesSolution:- Reduce batch size (max 2000 events)
- Use gzip compression
- Split into multiple requests
Events