Identities
Create Alias
POST
/
track#identity-create-alias
Create Alias
curl --request POST \
--url 'https://{region}.mixpanel.com/track#identity-create-alias' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'data={
"event": "$create_alias",
"properties": {
"distinct_id": "other_distinct_id",
"alias": "your_id",
"token": "YOUR_PROJECT_TOKEN"
}
}
' \
--data strict=0import requests
url = "https://{region}.mixpanel.com/track#identity-create-alias"
payload = {
"data": "{
\"event\": \"$create_alias\",
\"properties\": {
\"distinct_id\": \"other_distinct_id\",
\"alias\": \"your_id\",
\"token\": \"YOUR_PROJECT_TOKEN\"
}
}
",
"strict": "0"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
data: '{\n "event": "$create_alias",\n "properties": {\n "distinct_id": "other_distinct_id",\n "alias": "your_id",\n "token": "YOUR_PROJECT_TOKEN"\n }\n}\n',
strict: '0'
})
};
fetch('https://{region}.mixpanel.com/track#identity-create-alias', 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/track#identity-create-alias",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "data=%7B%0A%20%20%20%20%22event%22%3A%20%22%24create_alias%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22distinct_id%22%3A%20%22other_distinct_id%22%2C%0A%20%20%20%20%20%20%20%20%22alias%22%3A%20%22your_id%22%2C%0A%20%20%20%20%20%20%20%20%22token%22%3A%20%22YOUR_PROJECT_TOKEN%22%0A%20%20%20%20%7D%0A%7D%0A&strict=0",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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/track#identity-create-alias"
payload := strings.NewReader("data=%7B%0A%20%20%20%20%22event%22%3A%20%22%24create_alias%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22distinct_id%22%3A%20%22other_distinct_id%22%2C%0A%20%20%20%20%20%20%20%20%22alias%22%3A%20%22your_id%22%2C%0A%20%20%20%20%20%20%20%20%22token%22%3A%20%22YOUR_PROJECT_TOKEN%22%0A%20%20%20%20%7D%0A%7D%0A&strict=0")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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/track#identity-create-alias")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("data=%7B%0A%20%20%20%20%22event%22%3A%20%22%24create_alias%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22distinct_id%22%3A%20%22other_distinct_id%22%2C%0A%20%20%20%20%20%20%20%20%22alias%22%3A%20%22your_id%22%2C%0A%20%20%20%20%20%20%20%20%22token%22%3A%20%22YOUR_PROJECT_TOKEN%22%0A%20%20%20%20%7D%0A%7D%0A&strict=0")
.asString();require 'uri'
require 'net/http'
url = URI("https://{region}.mixpanel.com/track#identity-create-alias")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "data=%7B%0A%20%20%20%20%22event%22%3A%20%22%24create_alias%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22distinct_id%22%3A%20%22other_distinct_id%22%2C%0A%20%20%20%20%20%20%20%20%22alias%22%3A%20%22your_id%22%2C%0A%20%20%20%20%20%20%20%20%22token%22%3A%20%22YOUR_PROJECT_TOKEN%22%0A%20%20%20%20%7D%0A%7D%0A&strict=0"
response = http.request(request)
puts response.read_body1The
$create_alias event payload is only useful for projects using the Original ID Merge system and the Legacy ID Management System; it has no functionality in the Simplified ID Merge system. Please review this section of our documentation for more information.You can also use the import endpoint: https://api.mixpanel.com/import/

| Event Object property | Type | Description |
|---|---|---|
| event | String required | value must be: $create_alias |
| properties | Object required | |
| properties.distinct_id | String required | A distinct_id to be merged with the alias. |
| properties.alias | String required | A new distinct_id to be merged with the original distinct_id. Each alias can only map to one distinct_id. |
| properties.token | String required | The project token. |
Body
application/x-www-form-urlencoded
data
string<blob>
default:{
"event": "$create_alias",
"properties": {
"distinct_id": "other_distinct_id",
"alias": "your_id",
"token": "YOUR_PROJECT_TOKEN"
}
}
required
A JSON object with the required Event Object fields and any additional event properties.
If 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.
Required range:
0 <= x <= 1Response
1- All data objects provided are valid. This does not signify a valid project token or secret.0- One or more data objects in the body are invalid.
The response is of type enum<integer>.
Available options:
1, 0 Was this page helpful?
Create Alias
curl --request POST \
--url 'https://{region}.mixpanel.com/track#identity-create-alias' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'data={
"event": "$create_alias",
"properties": {
"distinct_id": "other_distinct_id",
"alias": "your_id",
"token": "YOUR_PROJECT_TOKEN"
}
}
' \
--data strict=0import requests
url = "https://{region}.mixpanel.com/track#identity-create-alias"
payload = {
"data": "{
\"event\": \"$create_alias\",
\"properties\": {
\"distinct_id\": \"other_distinct_id\",
\"alias\": \"your_id\",
\"token\": \"YOUR_PROJECT_TOKEN\"
}
}
",
"strict": "0"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
data: '{\n "event": "$create_alias",\n "properties": {\n "distinct_id": "other_distinct_id",\n "alias": "your_id",\n "token": "YOUR_PROJECT_TOKEN"\n }\n}\n',
strict: '0'
})
};
fetch('https://{region}.mixpanel.com/track#identity-create-alias', 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/track#identity-create-alias",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "data=%7B%0A%20%20%20%20%22event%22%3A%20%22%24create_alias%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22distinct_id%22%3A%20%22other_distinct_id%22%2C%0A%20%20%20%20%20%20%20%20%22alias%22%3A%20%22your_id%22%2C%0A%20%20%20%20%20%20%20%20%22token%22%3A%20%22YOUR_PROJECT_TOKEN%22%0A%20%20%20%20%7D%0A%7D%0A&strict=0",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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/track#identity-create-alias"
payload := strings.NewReader("data=%7B%0A%20%20%20%20%22event%22%3A%20%22%24create_alias%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22distinct_id%22%3A%20%22other_distinct_id%22%2C%0A%20%20%20%20%20%20%20%20%22alias%22%3A%20%22your_id%22%2C%0A%20%20%20%20%20%20%20%20%22token%22%3A%20%22YOUR_PROJECT_TOKEN%22%0A%20%20%20%20%7D%0A%7D%0A&strict=0")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
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/track#identity-create-alias")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("data=%7B%0A%20%20%20%20%22event%22%3A%20%22%24create_alias%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22distinct_id%22%3A%20%22other_distinct_id%22%2C%0A%20%20%20%20%20%20%20%20%22alias%22%3A%20%22your_id%22%2C%0A%20%20%20%20%20%20%20%20%22token%22%3A%20%22YOUR_PROJECT_TOKEN%22%0A%20%20%20%20%7D%0A%7D%0A&strict=0")
.asString();require 'uri'
require 'net/http'
url = URI("https://{region}.mixpanel.com/track#identity-create-alias")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "data=%7B%0A%20%20%20%20%22event%22%3A%20%22%24create_alias%22%2C%0A%20%20%20%20%22properties%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22distinct_id%22%3A%20%22other_distinct_id%22%2C%0A%20%20%20%20%20%20%20%20%22alias%22%3A%20%22your_id%22%2C%0A%20%20%20%20%20%20%20%20%22token%22%3A%20%22YOUR_PROJECT_TOKEN%22%0A%20%20%20%20%7D%0A%7D%0A&strict=0"
response = http.request(request)
puts response.read_body1