Batch Update Group Profiles
Send a batch of group profile updates
curl --request POST \
--url 'https://{region}.mixpanel.com/groups#group-batch-update' \
--header 'Content-Type: application/json' \
--data '
"[\n {\n \"$token\": \"YOUR_PROJECT_TOKEN\",\n \"$group_key\": \"Company\",\n \"$group_id\": \"Mixpanel\",\n \"$set\": {\n \"Address\": \"1313 Mockingbird Lane\"\n }\n },\n {\n \"$token\": \"YOUR_PROJECT_TOKEN\",\n \"$group_key\": \"Company\",\n \"$group_id\": \"Wayne Enterprises\",\n \"$set_once\": {\n \"Address\": \"Wayne Tower, Gotham City\"\n }\n }\n]\n"
'import requests
url = "https://{region}.mixpanel.com/groups#group-batch-update"
payload = "[
{
\"$token\": \"YOUR_PROJECT_TOKEN\",
\"$group_key\": \"Company\",
\"$group_id\": \"Mixpanel\",
\"$set\": {
\"Address\": \"1313 Mockingbird Lane\"
}
},
{
\"$token\": \"YOUR_PROJECT_TOKEN\",
\"$group_key\": \"Company\",
\"$group_id\": \"Wayne Enterprises\",
\"$set_once\": {
\"Address\": \"Wayne Tower, Gotham City\"
}
}
]
"
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify('[\n {\n "$token": "YOUR_PROJECT_TOKEN",\n "$group_key": "Company",\n "$group_id": "Mixpanel",\n "$set": {\n "Address": "1313 Mockingbird Lane"\n }\n },\n {\n "$token": "YOUR_PROJECT_TOKEN",\n "$group_key": "Company",\n "$group_id": "Wayne Enterprises",\n "$set_once": {\n "Address": "Wayne Tower, Gotham City"\n }\n }\n]\n')
};
fetch('https://{region}.mixpanel.com/groups#group-batch-update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{region}.mixpanel.com/groups#group-batch-update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('[
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "Company",
"$group_id": "Mixpanel",
"$set": {
"Address": "1313 Mockingbird Lane"
}
},
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "Company",
"$group_id": "Wayne Enterprises",
"$set_once": {
"Address": "Wayne Tower, Gotham City"
}
}
]
'),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{region}.mixpanel.com/groups#group-batch-update"
payload := strings.NewReader("\"[\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Mixpanel\\\",\\n \\\"$set\\\": {\\n \\\"Address\\\": \\\"1313 Mockingbird Lane\\\"\\n }\\n },\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Wayne Enterprises\\\",\\n \\\"$set_once\\\": {\\n \\\"Address\\\": \\\"Wayne Tower, Gotham City\\\"\\n }\\n }\\n]\\n\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{region}.mixpanel.com/groups#group-batch-update")
.header("Content-Type", "application/json")
.body("\"[\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Mixpanel\\\",\\n \\\"$set\\\": {\\n \\\"Address\\\": \\\"1313 Mockingbird Lane\\\"\\n }\\n },\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Wayne Enterprises\\\",\\n \\\"$set_once\\\": {\\n \\\"Address\\\": \\\"Wayne Tower, Gotham City\\\"\\n }\\n }\\n]\\n\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://{region}.mixpanel.com/groups#group-batch-update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "\"[\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Mixpanel\\\",\\n \\\"$set\\\": {\\n \\\"Address\\\": \\\"1313 Mockingbird Lane\\\"\\n }\\n },\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Wayne Enterprises\\\",\\n \\\"$set_once\\\": {\\n \\\"Address\\\": \\\"Wayne Tower, Gotham City\\\"\\n }\\n }\\n]\\n\""
response = http.request(request)
puts response.read_body1Query Parameters
If present and equal to 0, Mixpanel will not perform geolocation parsing using the IP address of the request. We recommend setting the ip to "0" when making requests from the server-side to prevent the unintentional effect of overwriting your profile's geolocation with your server location. Defaults to 1 which would use the IP address of the request to update profile geolocation.
0 <= x <= 1If present and equal to 1, Mixpanel will validate the provided records and return a JSON object with per-record error messages for records that fail validation.
0 <= x <= 1If present and equal to 1, Mixpanel will respond with a JSON Object describing the success or failure of the tracking call. The returned object will have two keys: status, with the value 1 on success and 0 on failure, and error, with a string-valued error message if the request wasn't successful. This is useful for debugging during implementation.
0 <= x <= 1Body
A JSON list of update objects, each with a $token, $group_key, $group_id, and an operation.
Response
1- One or more objects provided are valid. This does not signify a valid project token or secret.0- No data objects in the body are valid.
The response is of type enum<integer>.
1, 0 Was this page helpful?
curl --request POST \
--url 'https://{region}.mixpanel.com/groups#group-batch-update' \
--header 'Content-Type: application/json' \
--data '
"[\n {\n \"$token\": \"YOUR_PROJECT_TOKEN\",\n \"$group_key\": \"Company\",\n \"$group_id\": \"Mixpanel\",\n \"$set\": {\n \"Address\": \"1313 Mockingbird Lane\"\n }\n },\n {\n \"$token\": \"YOUR_PROJECT_TOKEN\",\n \"$group_key\": \"Company\",\n \"$group_id\": \"Wayne Enterprises\",\n \"$set_once\": {\n \"Address\": \"Wayne Tower, Gotham City\"\n }\n }\n]\n"
'import requests
url = "https://{region}.mixpanel.com/groups#group-batch-update"
payload = "[
{
\"$token\": \"YOUR_PROJECT_TOKEN\",
\"$group_key\": \"Company\",
\"$group_id\": \"Mixpanel\",
\"$set\": {
\"Address\": \"1313 Mockingbird Lane\"
}
},
{
\"$token\": \"YOUR_PROJECT_TOKEN\",
\"$group_key\": \"Company\",
\"$group_id\": \"Wayne Enterprises\",
\"$set_once\": {
\"Address\": \"Wayne Tower, Gotham City\"
}
}
]
"
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify('[\n {\n "$token": "YOUR_PROJECT_TOKEN",\n "$group_key": "Company",\n "$group_id": "Mixpanel",\n "$set": {\n "Address": "1313 Mockingbird Lane"\n }\n },\n {\n "$token": "YOUR_PROJECT_TOKEN",\n "$group_key": "Company",\n "$group_id": "Wayne Enterprises",\n "$set_once": {\n "Address": "Wayne Tower, Gotham City"\n }\n }\n]\n')
};
fetch('https://{region}.mixpanel.com/groups#group-batch-update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{region}.mixpanel.com/groups#group-batch-update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('[
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "Company",
"$group_id": "Mixpanel",
"$set": {
"Address": "1313 Mockingbird Lane"
}
},
{
"$token": "YOUR_PROJECT_TOKEN",
"$group_key": "Company",
"$group_id": "Wayne Enterprises",
"$set_once": {
"Address": "Wayne Tower, Gotham City"
}
}
]
'),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{region}.mixpanel.com/groups#group-batch-update"
payload := strings.NewReader("\"[\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Mixpanel\\\",\\n \\\"$set\\\": {\\n \\\"Address\\\": \\\"1313 Mockingbird Lane\\\"\\n }\\n },\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Wayne Enterprises\\\",\\n \\\"$set_once\\\": {\\n \\\"Address\\\": \\\"Wayne Tower, Gotham City\\\"\\n }\\n }\\n]\\n\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{region}.mixpanel.com/groups#group-batch-update")
.header("Content-Type", "application/json")
.body("\"[\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Mixpanel\\\",\\n \\\"$set\\\": {\\n \\\"Address\\\": \\\"1313 Mockingbird Lane\\\"\\n }\\n },\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Wayne Enterprises\\\",\\n \\\"$set_once\\\": {\\n \\\"Address\\\": \\\"Wayne Tower, Gotham City\\\"\\n }\\n }\\n]\\n\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://{region}.mixpanel.com/groups#group-batch-update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "\"[\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Mixpanel\\\",\\n \\\"$set\\\": {\\n \\\"Address\\\": \\\"1313 Mockingbird Lane\\\"\\n }\\n },\\n {\\n \\\"$token\\\": \\\"YOUR_PROJECT_TOKEN\\\",\\n \\\"$group_key\\\": \\\"Company\\\",\\n \\\"$group_id\\\": \\\"Wayne Enterprises\\\",\\n \\\"$set_once\\\": {\\n \\\"Address\\\": \\\"Wayne Tower, Gotham City\\\"\\n }\\n }\\n]\\n\""
response = http.request(request)
puts response.read_body1