Service Accounts API
Manage service accounts for programmatic access to Mixpanel APIs.
Base URL
https://mixpanel.com/api/app
Authentication
Use Service Account credentials with HTTP Basic Auth.
List Service Accounts
Get all service accounts for your organization.
Your Mixpanel organization ID
Example Request
curl "https://mixpanel.com/api/app/organizations/123/service-accounts" \
-u SERVICE_ACCOUNT_USERNAME:SERVICE_ACCOUNT_SECRET
Response
{
"status": "ok",
"results": [
{
"id": 12345,
"username": "api-bot",
"last_used": "2024-01-15T10:30:00Z",
"expires": "2025-01-15T10:30:00Z",
"creator": 789,
"created": "2024-01-01T09:00:00Z",
"user": 12345
}
]
}
Create Service Account
Create a new service account for your organization.
Your Mixpanel organization ID
A descriptive name for the service account
The service account’s roleOptions: owner, admin, analyst, consumer
Expiration date and time in ISO formatExample: 2025-12-31T23:59:59Z
List of projects to add the service account to
Role for this project: owner, admin, analyst, consumer
Example Request
curl "https://mixpanel.com/api/app/organizations/123/service-accounts" \
-X POST \
-u SERVICE_ACCOUNT_USERNAME:SERVICE_ACCOUNT_SECRET \
-H "Content-Type: application/json" \
-d '{
"username": "data-pipeline-bot",
"role": "admin",
"expires": "2025-12-31T23:59:59Z",
"projects": [
{"id": 456, "role": "admin"},
{"id": 789, "role": "analyst"}
]
}'
Response
{
"status": "ok",
"results": {
"id": 12345,
"username": "data-pipeline-bot",
"token": "SECRET_TOKEN_SAVE_THIS",
"last_used": null,
"expires": "2025-12-31T23:59:59Z",
"creator": 789,
"created": "2024-01-15T10:30:00Z",
"user": 12345
}
}
The token (secret) is only returned once during creation. Store it securely - it cannot be retrieved later.
Get Service Account
Retrieve details of a specific service account.
Your Mixpanel organization ID
Example Request
curl "https://mixpanel.com/api/app/organizations/123/service-accounts/12345" \
-u SERVICE_ACCOUNT_USERNAME:SERVICE_ACCOUNT_SECRET
Delete Service Account
Remove a service account from your organization.
Your Mixpanel organization ID
The service account ID to delete
Example Request
curl "https://mixpanel.com/api/app/organizations/123/service-accounts/12345" \
-X DELETE \
-u SERVICE_ACCOUNT_USERNAME:SERVICE_ACCOUNT_SECRET
Add Service Account to Projects
Add one or more service accounts to one or more projects.
Your Mixpanel organization ID
List of projects and roles
Array of service account IDs to add
Example Request
curl "https://mixpanel.com/api/app/organizations/123/service-accounts/add-to-project" \
-X POST \
-u SERVICE_ACCOUNT_USERNAME:SERVICE_ACCOUNT_SECRET \
-H "Content-Type: application/json" \
-d '{
"projects": [
{"id": 456, "role": "admin"},
{"id": 789, "role": "analyst"}
],
"service_account_ids": [12345, 67890]
}'
Remove Service Account from Projects
Your Mixpanel organization ID
List of projects to remove from
Service account IDs to remove from this project
Example Request
curl "https://mixpanel.com/api/app/organizations/123/service-accounts/remove-from-project" \
-X POST \
-u SERVICE_ACCOUNT_USERNAME:SERVICE_ACCOUNT_SECRET \
-H "Content-Type: application/json" \
-d '{
"projects": [
{"id": 456, "service_account_ids": [12345]},
{"id": 789, "service_account_ids": [12345, 67890]}
]
}'
Best Practices
Create service accounts for specific purposes
Use dedicated service accounts for different integrations:
data-pipeline-bot: For data exports
ci-cd-bot: For CI/CD integrations
analytics-dashboard: For custom dashboards
Grant only the minimum required permissions:# Good: Specific role for specific purpose
{
"username": "readonly-reporter",
"projects": [{"id": 123, "role": "consumer"}]
}
Always set expiration dates for security:{
"expires": "2025-12-31T23:59:59Z"
}
Rotate credentials regularly
Rotate service account credentials periodically:# 1. Create new service account
# 2. Update applications to use new credentials
# 3. Delete old service account