Engage
Query Profiles
Query user (or group) profile data and return list of users (or groups) that fit specified parameters
POST
/
engage
Query Profiles
curl --request POST \
--url https://{regionAndDomain}.com/api/query/engage \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'distinct_id=<string>' \
--data 'distinct_ids=<string>' \
--data 'data_group_id=<string>' \
--data 'where=<string>' \
--data 'output_properties=<string>' \
--data 'session_id=<string>' \
--data page=123 \
--data behaviors=123 \
--data as_of_timestamp=123 \
--data 'filter_by_cohort=<string>' \
--data include_all_users=trueimport requests
url = "https://{regionAndDomain}.com/api/query/engage"
payload = {
"distinct_id": "<string>",
"distinct_ids": "<string>",
"data_group_id": "<string>",
"where": "<string>",
"output_properties": "<string>",
"session_id": "<string>",
"page": "123",
"behaviors": "123",
"as_of_timestamp": "123",
"filter_by_cohort": "<string>",
"include_all_users": "true"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
distinct_id: '<string>',
distinct_ids: '<string>',
data_group_id: '<string>',
where: '<string>',
output_properties: '<string>',
session_id: '<string>',
page: '123',
behaviors: '123',
as_of_timestamp: '123',
filter_by_cohort: '<string>',
include_all_users: 'true'
})
};
fetch('https://{regionAndDomain}.com/api/query/engage', 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://{regionAndDomain}.com/api/query/engage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "distinct_id=%3Cstring%3E&distinct_ids=%3Cstring%3E&data_group_id=%3Cstring%3E&where=%3Cstring%3E&output_properties=%3Cstring%3E&session_id=%3Cstring%3E&page=123&behaviors=123&as_of_timestamp=123&filter_by_cohort=%3Cstring%3E&include_all_users=true",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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://{regionAndDomain}.com/api/query/engage"
payload := strings.NewReader("distinct_id=%3Cstring%3E&distinct_ids=%3Cstring%3E&data_group_id=%3Cstring%3E&where=%3Cstring%3E&output_properties=%3Cstring%3E&session_id=%3Cstring%3E&page=123&behaviors=123&as_of_timestamp=123&filter_by_cohort=%3Cstring%3E&include_all_users=true")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://{regionAndDomain}.com/api/query/engage")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("distinct_id=%3Cstring%3E&distinct_ids=%3Cstring%3E&data_group_id=%3Cstring%3E&where=%3Cstring%3E&output_properties=%3Cstring%3E&session_id=%3Cstring%3E&page=123&behaviors=123&as_of_timestamp=123&filter_by_cohort=%3Cstring%3E&include_all_users=true")
.asString();require 'uri'
require 'net/http'
url = URI("https://{regionAndDomain}.com/api/query/engage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "distinct_id=%3Cstring%3E&distinct_ids=%3Cstring%3E&data_group_id=%3Cstring%3E&where=%3Cstring%3E&output_properties=%3Cstring%3E&session_id=%3Cstring%3E&page=123&behaviors=123&as_of_timestamp=123&filter_by_cohort=%3Cstring%3E&include_all_users=true"
response = http.request(request)
puts response.read_body{
"page": 0,
"page_size": 1000,
"results": [
{
"$distinct_id": 4,
"$properties": {
"$created": "2008-12-12T11:20:47",
"$email": "example@mixpanel.com",
"$first_name": "Example",
"$last_name": "Name",
"$last_seen": "2008-06-09T23:08:40"
}
}
],
"session_id": "1234567890-EXAMPL",
"status": "ok",
"total": 1
}Query user (or group) profile data and return list of users (or groups) that fit specified parameters.
API responses will return at most
The Query API has a rate limit of 60 queries per hour and a maximum of 5 concurrent queries.
page_size records for each request. To request additional records, callers should repeat their call to the API using the same where param, but provide a session_id parameter with a value taken from the first response, and include a page parameter with a value one greater than the value of page in the response.
A caller trying to retrieve all of the records for a particular query might use an algorithm something like this:
// Get the first page of data associated with our selector expression
this_page = query_api(where=YOUR_SELECTOR_EXPRESSION)
do_something_with_response(this_page)
// If we get fewer records than the page_size returned with our results,
// then there are no more records to get. Otherwise, keep querying for additional pages.
while (length of this_page.results) >= this_page.page_size:
next_page_number = this_page.page + 1
this_page = query_api(where=YOUR_SELECTOR_EXPRESSION, session_id=this_page.session_id, page=next_page_number)
do_something_with_response(this_page)
Query Parameters
Body
application/x-www-form-urlencoded
The ID of the group key, used when querying group profiles, click here for more info.
An expression to filter users (or groups) by. See the expressions section above.
A JSON array of names of properties you want returned.
Example: output_properties=["$last_name", "$email", "Total Spent"]
This parameter can drastically reduce the amount of data returned by the API when you're not interested in all properties and can speed up queries significantly.
Response
200 - application/json
Success.
Was this page helpful?
Query Profiles
curl --request POST \
--url https://{regionAndDomain}.com/api/query/engage \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'distinct_id=<string>' \
--data 'distinct_ids=<string>' \
--data 'data_group_id=<string>' \
--data 'where=<string>' \
--data 'output_properties=<string>' \
--data 'session_id=<string>' \
--data page=123 \
--data behaviors=123 \
--data as_of_timestamp=123 \
--data 'filter_by_cohort=<string>' \
--data include_all_users=trueimport requests
url = "https://{regionAndDomain}.com/api/query/engage"
payload = {
"distinct_id": "<string>",
"distinct_ids": "<string>",
"data_group_id": "<string>",
"where": "<string>",
"output_properties": "<string>",
"session_id": "<string>",
"page": "123",
"behaviors": "123",
"as_of_timestamp": "123",
"filter_by_cohort": "<string>",
"include_all_users": "true"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
distinct_id: '<string>',
distinct_ids: '<string>',
data_group_id: '<string>',
where: '<string>',
output_properties: '<string>',
session_id: '<string>',
page: '123',
behaviors: '123',
as_of_timestamp: '123',
filter_by_cohort: '<string>',
include_all_users: 'true'
})
};
fetch('https://{regionAndDomain}.com/api/query/engage', 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://{regionAndDomain}.com/api/query/engage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "distinct_id=%3Cstring%3E&distinct_ids=%3Cstring%3E&data_group_id=%3Cstring%3E&where=%3Cstring%3E&output_properties=%3Cstring%3E&session_id=%3Cstring%3E&page=123&behaviors=123&as_of_timestamp=123&filter_by_cohort=%3Cstring%3E&include_all_users=true",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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://{regionAndDomain}.com/api/query/engage"
payload := strings.NewReader("distinct_id=%3Cstring%3E&distinct_ids=%3Cstring%3E&data_group_id=%3Cstring%3E&where=%3Cstring%3E&output_properties=%3Cstring%3E&session_id=%3Cstring%3E&page=123&behaviors=123&as_of_timestamp=123&filter_by_cohort=%3Cstring%3E&include_all_users=true")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://{regionAndDomain}.com/api/query/engage")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("distinct_id=%3Cstring%3E&distinct_ids=%3Cstring%3E&data_group_id=%3Cstring%3E&where=%3Cstring%3E&output_properties=%3Cstring%3E&session_id=%3Cstring%3E&page=123&behaviors=123&as_of_timestamp=123&filter_by_cohort=%3Cstring%3E&include_all_users=true")
.asString();require 'uri'
require 'net/http'
url = URI("https://{regionAndDomain}.com/api/query/engage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "distinct_id=%3Cstring%3E&distinct_ids=%3Cstring%3E&data_group_id=%3Cstring%3E&where=%3Cstring%3E&output_properties=%3Cstring%3E&session_id=%3Cstring%3E&page=123&behaviors=123&as_of_timestamp=123&filter_by_cohort=%3Cstring%3E&include_all_users=true"
response = http.request(request)
puts response.read_body{
"page": 0,
"page_size": 1000,
"results": [
{
"$distinct_id": 4,
"$properties": {
"$created": "2008-12-12T11:20:47",
"$email": "example@mixpanel.com",
"$first_name": "Example",
"$last_name": "Name",
"$last_seen": "2008-06-09T23:08:40"
}
}
],
"session_id": "1234567890-EXAMPL",
"status": "ok",
"total": 1
}