Get details about a segment.

Make a GET call to the /segments/{segment_id} endpoint to get details about a segment. For example:

 {
     "name": "Sent within the last 180 days",
     "segment_criteria": "{\"version\":\"1.0.0\",\"criteria\":{\"type\":\"and\",\"group\":[{\"source\":\"tracking\",\"field\":\"sent\",\"op\":\"contains-any\",\"const_value\":\"campaigns\",\"const_date_value\":\"last-n-days\",\"date_param\":\"180\"}]}}",
     "segment_id": 12,
     "created_at": "2019-10-15T21:21:10.000Z",
     "edited_at": "2019-10-16T13:53:53.000Z"
 }

Unlike the GET /segments endpoint, response body details include the segment_criteria.

TIP: If you know the segment_id, you can also use this endpoint to get details about a previously deleted segment.

Authorization Requirements

User privileges: contacts:lists:read

Authorization scopes: contact_data

Parameters

In the path parameter, specify the segment_id for the segment that you want to get details about. If the segment_id does not exist for the account, a 404 error response is returned.

Example GET Segment Request

GET https://api.cc.email/v3/segments/{segment_id}

 <?php
 
 $request = new HttpRequest();
 $request->setUrl('https://api.cc.email/segments/12');
 $request->setMethod(HTTP_METH_GET);
 
 $request->setHeaders(array(
   'cache-control' => 'no-cache',
   'Connection' => 'keep-alive',
   'Accept-Encoding' => 'gzip, deflate',
   'Host' => 'host_name.com',
   'Cache-Control' => 'no-cache',
   'Accept' => '*/*',
   'Authorization' => 'Bearer {access_token}'
 ));
 
 try {
   $response = $request->send();
 
   echo $response->getBody();
 } catch (HttpException $ex) {
   echo $ex;
 }
curl -X GET \
  https://api.cc.email/segments/12 \
  -H 'Accept: */*' \
  -H 'Accept-Encoding: gzip, deflate' \
  -H 'Authorization: Bearer {access_token}' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Host: host_name.com' \
  -H 'cache-control: no-cache'
 
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.cc.email/v3/segments/12")
  .get()
  .addHeader("Authorization", "Bearer {access_token}")
  .addHeader("Accept", "*/*")
  .addHeader("Cache-Control", "no-cache")
  .addHeader("Host", "host_name.com")
  .addHeader("Accept-Encoding", "gzip, deflate")
  .addHeader("Connection", "keep-alive")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

Response

 {
     "name": "Sent within the last 180 days",
     "segment_criteria": "{\"version\":\"1.0.0\",\"criteria\":{\"type\":\"and\",\"group\":[{\"source\":\"tracking\",\"field\":\"sent\",\"op\":\"contains-any\",\"const_value\":\"campaigns\",\"const_date_value\":\"last-n-days\",\"date_param\":\"180\"}]}}",
     "segment_id": 12,
     "created_at": "2019-10-15T21:21:10.000Z",
     "edited_at": "2019-10-16T13:53:53.000Z"
 }

Try it!