GET
/segments/:id/users/View user segment
You can return all users assigned to a specific user segment.
| Attributes | Type | Required | Description |
|---|---|---|---|
| id | integer | yes | A unique identifier for the users' segment which is given by User.com automatically. |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X GET -H "Authorization: Token <your_64_char_api_key>"
-H "Accept: */*; version=2"
"https://<your_app_subdomain>.user.com/api/public/segments/:id/users/"
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://<your_app_subdomain>.user.com/api/public/segments/:id/users/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/segments/:id/users/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Accept: */*; version=2",
"authorization: Token <your_64_char_api_key>"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import http.client
conn = http.client.HTTPSConnection("<your_app_subdomain>.user.com")
headers = { 'authorization': "Token <your_64_char_api_key>", "Accept": "*/*; version=2" }
conn.request("GET", "/api/public/segments/:id/users/", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Response
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"first_seen": null,
"city": null,
"linkedin_url": null,
"unsubscribed": true,
"timezone": null,
"browser": null,
"score": 0,
"name": "John Doe",
"last_seen": null,
"country": null,
"google_url": null,
"resolution": null,
"tags": [],
"id": 18260675,
"updated_at": "2017-05-29T10:08:59.526309Z",
"last_ip": null,
"last_contacted": null,
"region": null,
"status": "visitor",
"gravatar_url": null,
"created_at": "2017-05-29T10:08:59.526286Z",
"browser_language": null,
"gender": "unknown",
"email": "example@email.com",
"twitter_url": null,
"page_views": 0,
"phone_number": null,
"facebook_url": null,
"chat_id": "Chat ID is deprecated and will be removed in future",
"attributes": [
{
"id": 2092,
"name_std": "an_attribute",
"value": "Value for the attribute",
"name": "An Attribute"
}
],
"notifications": true,
"key": "rQ8mdQ8W6I5t",
"lists": [],
"os_type": null
},
{
"first_seen": null,
"city": null,
"linkedin_url": null,
"unsubscribed": false,
"timezone": null,
"browser": null,
"score": 0,
"name": "Jane Doe",
"last_seen": null,
"country": null,
"google_url": null,
"resolution": null,
"tags": [],
"id": 20901703,
"updated_at": "2017-06-13T12:51:30.924647Z",
"last_ip": null,
"last_contacted": null,
"region": null,
"status": "visitor",
"gravatar_url": null,
"created_at": "2017-06-13T12:22:38.748373Z",
"browser_language": null,
"gender": "unknown",
"email": "example@email.org",
"twitter_url": null,
"page_views": 0,
"phone_number": null,
"facebook_url": null,
"chat_id": "Chat ID is deprecated and will be removed in future",
"attributes": [],
"notifications": true,
"key": "xSoYQG00fg9z",
"lists": [],
"os_type": null
}
]
}