Skip to main content
GET
/
api
/
app
/
organizations
/
{organizationId}
/
service-accounts
Service Accounts
curl --request GET \
  --url https://mixpanel.com/api/app/organizations/{organizationId}/service-accounts \
  --header 'Content-Type: application/json' \
  --data '
{
  "username": "<string>",
  "role": "<string>",
  "expires": "<string>",
  "projects": [
    {
      "id": 123,
      "service_account_ids": [
        {}
      ]
    }
  ],
  "service_account_ids": [
    {}
  ]
}
'

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.
organizationId
integer
required
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.
organizationId
integer
required
Your Mixpanel organization ID
username
string
required
A descriptive name for the service account
role
string
The service account’s roleOptions: owner, admin, analyst, consumer
expires
string
Expiration date and time in ISO formatExample: 2025-12-31T23:59:59Z
projects
array
List of projects to add the service account to

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.
organizationId
integer
required
Your Mixpanel organization ID
serviceAccountId
integer
required
The service account 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.
organizationId
integer
required
Your Mixpanel organization ID
serviceAccountId
integer
required
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.
organizationId
integer
required
Your Mixpanel organization ID
projects
array
required
List of projects and roles
service_account_ids
array
required
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

organizationId
integer
required
Your Mixpanel organization ID
projects
array
required
List of projects to remove from

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

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 service account credentials periodically:
# 1. Create new service account
# 2. Update applications to use new credentials
# 3. Delete old service account

Build docs developers (and LLMs) love