Authentication
Mixpanel APIs support multiple authentication methods depending on the endpoint you’re using.Authentication Methods
Service Account
Service accounts provide programmatic access to Mixpanel APIs. This is the recommended method for server-to-server integrations. Use Cases:- Import API
- Query API
- Management APIs (Annotations, Lexicon, etc.)
You can create service accounts in Project Settings > Service Accounts.
Project Secret
Project secrets are used for certain API endpoints that require project-level authentication. Use Cases:- Import API
- Raw Event Export API
- Data Pipelines API
Project Token
Project tokens are used for client-side event tracking. Use Cases:- Track API (client-side event tracking)
- Engage API (user profile updates)
Your project token can be found in Project Settings > Project Details.
OAuth Token
OAuth tokens are used for GDPR and user-specific operations. Use Cases:- GDPR API (data retrieval and deletion)
Finding Your Credentials
Service Account Credentials
- Navigate to Project Settings
- Click Service Accounts
- Create a new service account or view existing ones
- Copy the username and secret
Project Secret
- Navigate to Project Settings
- Click Project Details
- Find your API Secret
Project Token
- Navigate to Project Settings
- Click Project Details
- Find your Project Token
Security Best Practices
Never expose secrets in client-side code
Never expose secrets in client-side code
Project secrets and service account credentials should only be used in server-side code. Use project tokens for client-side tracking.
Rotate credentials regularly
Rotate credentials regularly
Regularly rotate your service account credentials and project secrets to maintain security.
Use environment variables
Use environment variables
Store credentials in environment variables or secure secret management systems, never in source code.
Limit service account permissions
Limit service account permissions
Create service accounts with the minimum required permissions for their specific use case.
Quick Reference
| API | Auth Method | Credential Location |
|---|---|---|
| Import Events | Service Account or Project Secret | Project Settings |
| Track Events | Project Token | Project Settings |
| Query API | Service Account | Project Settings > Service Accounts |
| Export API | Project Secret | Project Settings |
| GDPR API | OAuth Token | OAuth flow |
| Management APIs | Service Account | Project Settings > Service Accounts |