Rename a segment.
Use the PATCH /segments/{segment_id}/name
method to rename an existing segment. The segment name must be unique.
Parameters
In the request body, specify the new name (name
) for the segment. If the segment name already exists, the system returns a 409 error response.
Example PATCH Segments Requests
PATCH https://api.cc.email/v3/segments/{segment_id}/name
<?php
HttpRequest::methodRegister('PATCH');
$request = new HttpRequest();
$request->setUrl('https://api.cc.email/v3/segments/3/name');
$request->setMethod(HttpRequest::HTTP_METH_PATCH);
$request->setMethod(HTTP_METH_PATCH);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'Connection' => 'keep-alive',
'Content-Length' => '49',
'Accept-Encoding' => 'gzip, deflate',
'Host' => 'your_host.com',
'Cache-Control' => 'no-cache',
'Authorization' => 'Bearer {access_token}',
'Content-Type' => 'application/json',
'Accept' => '*/*'
));
$request->setBody('{
"name": "Opened any of my last ten campaigns"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
curl -X PATCH \
https://api.cc.email/v3/segments/3/name\
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Bearer {access_token}' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Length: 49' \
-H 'Content-Type: application/json' \
-H 'Host: your_host.com' \
-H 'cache-control: no-cache' \
-d ' {
"name": "Opened any of my last ten campaigns"
}'
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \t\"name\": \"Opened any of my last ten campaigns\"\n}");
Request request = new Request.Builder()
.url("https://api.cc.email/v3/segments/3/name")
.patch(body)
.addHeader("Accept", "*/*")
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer {access_token}")
.addHeader("Cache-Control", "no-cache")
.addHeader("Host", "your_host.com")
.addHeader("Accept-Encoding", "gzip, deflate")
.addHeader("Content-Length", "49")
.addHeader("Connection", "keep-alive")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
Response
{
"name": "Opened any of my the last ten campaigns",
"segment_criteria": "{\"version\":\"1.0.0\",\"criteria\":{\"type\":\"and\",\"group\":[{\"source\":\"tracking\",\"field\":\"opened\",\"op\":\"contains-any\",\"const_value\":\"last-n-campaigns\",\"param\":\"5\"}]}}",
"segment_id": 3,
"created_at": "2020-01-21T15:25:52.000Z",
"edited_at": "2020-01-21T15:25:52.000Z"
}