Skip to main content

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:
Projects with India Data Residency must use api-in.mixpanel.com or events will be rejected.

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:
Body:

Required Properties

Common Optional Properties

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

  1. Navigate to Project Settings
  2. Under Access Keys, find your Project Secret
Keep your API secret confidential. Never expose it in client-side code or public repositories.

Example: Import with Python

User Profile Updates: /engage

The /engage endpoint updates user profile properties.

Endpoint

Set Profile Properties

Profile Operations

Example: Multiple Operations

Identity Management

Simplified ID Merge

Link an anonymous user to a known user ID:
This merges all events from device_xyz into the user_123 profile.

Best Practices

Include a unique $insert_id for each event to prevent duplicates:
Mixpanel will reject duplicate events with the same $insert_id within 24 hours.
By default, Mixpanel uses the request IP for geolocation. For server-side tracking:Pass the client IP:
Skip geolocation:
Send multiple events in a single request to improve performance:
  • Maximum 2000 events per batch
  • Reduces network overhead
  • Improves throughput
Mixpanel has rate limits to ensure service reliability:
  • 60 requests per hour for the /import endpoint per project
  • 2000 events per request maximum batch size
Implement exponential backoff for retries:
Always check the API response:Success Response:
Error Response:

Common Issues & Troubleshooting

  1. Check project token: Verify you’re using the correct token
  2. Verify data residency: Ensure you’re using the correct API endpoint
  3. Check timestamp: Events older than 5 days won’t be accepted by /track
  4. Look for errors: Check the API response for error messages
  5. View Events page: Check the Events view in Mixpanel
  • For /import endpoint: Verify your API secret is correct
  • Check that you’re using Basic Auth with the API secret
  • Ensure the API secret hasn’t been regenerated
  • Your batch is too large (>2000 events)
  • Split into smaller batches
  • Individual events might be too large (>2MB)
  • If tracking from a server, pass the client’s IP in the ip property
  • Set ip to "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