Organize users into groups and manage group properties
curl --request POST \
--url https://api.mixpanel.com/groups \
--header 'Content-Type: application/json' \
--data '
{
"$token": "<string>",
"$group_key": "<string>",
"$group_id": "<string>",
"$set": {},
"$set_once": {},
"$unset": [
{}
],
"$union": {},
"$remove": {},
"$delete": "<string>"
}
'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.
https://api.mixpanel.com/groups
curl https://api.mixpanel.com/groups \
--data-urlencode data='[
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "mixpanel_inc",
"$set": {
"name": "Mixpanel Inc",
"industry": "Analytics",
"employees": 350,
"plan": "enterprise"
}
}
]'
curl https://api.mixpanel.com/groups \
--data-urlencode data='[
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "mixpanel_inc",
"$set_once": {
"created_date": "2024-01-01",
"founding_year": 2009
}
}
]'
curl https://api.mixpanel.com/groups \
--data-urlencode data='[
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "mixpanel_inc",
"$unset": ["temp_field", "old_data"]
}
]'
curl https://api.mixpanel.com/groups \
--data-urlencode data='[
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "mixpanel_inc",
"$union": {
"products": ["analytics", "data-warehouse"],
"integrations": ["salesforce", "hubspot"]
}
}
]'
curl https://api.mixpanel.com/groups \
--data-urlencode data='[
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "mixpanel_inc",
"$remove": {
"integrations": "deprecated_tool"
}
}
]'
curl https://api.mixpanel.com/groups \
--data-urlencode data='[
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "old_company",
"$delete": ""
}
]'
import requests
import json
data = [
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "company_1",
"$set": {"plan": "enterprise"}
},
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "company_2",
"$set": {"plan": "professional"}
},
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "company_3",
"$set": {"status": "active"}
}
]
response = requests.post(
'https://api.mixpanel.com/groups',
data={'data': json.dumps(data)}
)
print(response.text)
import requests
import uuid
import time
# Track event with group association
event = {
"event": "Purchase",
"properties": {
"time": int(time.time()),
"distinct_id": "user123",
"$insert_id": str(uuid.uuid4()),
"company": "mixpanel_inc", # Links user to group
"amount": 99.99
}
}
response = requests.post(
'https://api.mixpanel.com/import',
auth=('SERVICE_ACCOUNT', 'SECRET'),
params={'project_id': 'PROJECT_ID', 'strict': '1'},
json=[event]
)
Define group keys in project settings
company: For B2B SaaS productsorganization: For enterprise customersteam: For team-based featuresworkspace: For workspace-based productsUse consistent group identifiers
# Good: Consistent IDs
"$group_id": "company_12345"
# Bad: Inconsistent IDs
# Sometimes "company_12345", sometimes "12345"
Store group-level metrics as properties
{
"$set": {
"total_users": 150,
"monthly_usage": 50000,
"plan": "enterprise",
"seats_purchased": 200
}
}
Update group properties when they change
# When a company upgrades
update_group({
"$set": {
"plan": "enterprise",
"upgrade_date": "2024-01-15"
}
})
# Set up company profile
data = [{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "company",
"$group_id": "acme_corp",
"$set": {
"name": "Acme Corporation",
"industry": "Technology",
"employees": 500,
"plan": "enterprise",
"mrr": 5000,
"seats": 100
}
}]
# Track user action with company association
event = {
"event": "Feature Used",
"properties": {
"distinct_id": "user@acme.com",
"company": "acme_corp",
"feature": "advanced_analytics"
}
}
# Track workspace-level metrics
data = [{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "workspace",
"$group_id": "ws_12345",
"$set": {
"name": "Marketing Team",
"members_count": 15,
"storage_used_gb": 250,
"plan": "professional"
}
}]
curl --request POST \
--url https://api.mixpanel.com/groups \
--header 'Content-Type: application/json' \
--data '
{
"$token": "<string>",
"$group_key": "<string>",
"$group_id": "<string>",
"$set": {},
"$set_once": {},
"$unset": [
{}
],
"$union": {},
"$remove": {},
"$delete": "<string>"
}
'