Update segment definition
curl --request PATCH \
--url https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Example segment",
"query": {
"logic": "AND",
"criteria": [
{
"logic": "OR",
"criteria": [
{
"field": "paxadults",
"operator": ">",
"value": "3"
},
{
"field": "farecode",
"operator": "=",
"value": "FOO"
}
]
}
]
}
}
'const url = 'https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}';
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Example segment',
query: {
logic: 'AND',
criteria: [
{
logic: 'OR',
criteria: [
{field: 'paxadults', operator: '>', value: '3'},
{field: 'farecode', operator: '=', value: 'FOO'}
]
}
]
}
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));import requests
url = "https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}"
payload = {
"name": "Example segment",
"query": {
"logic": "AND",
"criteria": [
{
"logic": "OR",
"criteria": [
{
"field": "paxadults",
"operator": ">",
"value": "3"
},
{
"field": "farecode",
"operator": "=",
"value": "FOO"
}
]
}
]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Example segment',
'query' => [
'logic' => 'AND',
'criteria' => [
[
'logic' => 'OR',
'criteria' => [
[
'field' => 'paxadults',
'operator' => '>',
'value' => '3'
],
[
'field' => 'farecode',
'operator' => '=',
'value' => 'FOO'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}using RestSharp;
var options = new RestClientOptions("https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"name\": \"Example segment\",\n \"query\": {\n \"logic\": \"AND\",\n \"criteria\": [\n {\n \"logic\": \"OR\",\n \"criteria\": [\n {\n \"field\": \"paxadults\",\n \"operator\": \">\",\n \"value\": \"3\"\n },\n {\n \"field\": \"farecode\",\n \"operator\": \"=\",\n \"value\": \"FOO\"\n }\n ]\n }\n ]\n }\n}", false);
var response = await client.PatchAsync(request);
Console.WriteLine("{0}", response.Content);
HttpResponse<String> response = Unirest.patch("https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Example segment\",\n \"query\": {\n \"logic\": \"AND\",\n \"criteria\": [\n {\n \"logic\": \"OR\",\n \"criteria\": [\n {\n \"field\": \"paxadults\",\n \"operator\": \">\",\n \"value\": \"3\"\n },\n {\n \"field\": \"farecode\",\n \"operator\": \"=\",\n \"value\": \"FOO\"\n }\n ]\n }\n ]\n }\n}")
.asString();Segments
Update a segment
Change the name or the criteria of an existing segment
PATCH
/
api
/
guestprofile
/
entities
/
{entity_id}
/
segments
/
{segment_id}
Update segment definition
curl --request PATCH \
--url https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Example segment",
"query": {
"logic": "AND",
"criteria": [
{
"logic": "OR",
"criteria": [
{
"field": "paxadults",
"operator": ">",
"value": "3"
},
{
"field": "farecode",
"operator": "=",
"value": "FOO"
}
]
}
]
}
}
'const url = 'https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}';
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Example segment',
query: {
logic: 'AND',
criteria: [
{
logic: 'OR',
criteria: [
{field: 'paxadults', operator: '>', value: '3'},
{field: 'farecode', operator: '=', value: 'FOO'}
]
}
]
}
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));import requests
url = "https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}"
payload = {
"name": "Example segment",
"query": {
"logic": "AND",
"criteria": [
{
"logic": "OR",
"criteria": [
{
"field": "paxadults",
"operator": ">",
"value": "3"
},
{
"field": "farecode",
"operator": "=",
"value": "FOO"
}
]
}
]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Example segment',
'query' => [
'logic' => 'AND',
'criteria' => [
[
'logic' => 'OR',
'criteria' => [
[
'field' => 'paxadults',
'operator' => '>',
'value' => '3'
],
[
'field' => 'farecode',
'operator' => '=',
'value' => 'FOO'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}using RestSharp;
var options = new RestClientOptions("https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"name\": \"Example segment\",\n \"query\": {\n \"logic\": \"AND\",\n \"criteria\": [\n {\n \"logic\": \"OR\",\n \"criteria\": [\n {\n \"field\": \"paxadults\",\n \"operator\": \">\",\n \"value\": \"3\"\n },\n {\n \"field\": \"farecode\",\n \"operator\": \"=\",\n \"value\": \"FOO\"\n }\n ]\n }\n ]\n }\n}", false);
var response = await client.PatchAsync(request);
Console.WriteLine("{0}", response.Content);
HttpResponse<String> response = Unirest.patch("https://{apiBaseUrl}/api/guestprofile/entities/{entity_id}/segments/{segment_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Example segment\",\n \"query\": {\n \"logic\": \"AND\",\n \"criteria\": [\n {\n \"logic\": \"OR\",\n \"criteria\": [\n {\n \"field\": \"paxadults\",\n \"operator\": \">\",\n \"value\": \"3\"\n },\n {\n \"field\": \"farecode\",\n \"operator\": \"=\",\n \"value\": \"FOO\"\n }\n ]\n }\n ]\n }\n}")
.asString();Send the segment whole: the
name and the query you send replace the ones stored. The response carries no body, and the location header points back at the segment.Was this page helpful?