List of segments#

Getting Started#

Introduction

This endpoint is used to list all segments created by users. In which include response objects segments, success and count. Segments object include property, namely are subscriber_id, segment_id and segment_name.

Request URL

  https://api.pushengage.com/apiv1/segments

Method

  GET

Request Parameters

Required Parameters

There is no required parameters.

Optional Parameters

Parameter Name Parameter Type Description
segment_id String This is the id of segment, that is generated when a segment is created.
limit Integer To denote the limit of segment display as a result. The minimum value is 1.
offset Integer To denote the starting index of limit display as a result. The minimum value is 0.
segment_type String To get the list of all segments created including the geos, device, browsers. The value of this parameter should be 'all'.

Response Objects

Required Object

Property Name Property Type Description
segments Array of Object To denote name of segments object. Get more detail in segments object section.
success Boolean To denote whether push response succeeded or not. Values can be 'true' or 'false'.
count Integer To denote the total number of segments.

Segments object#

Segments object include property, namely are subscriber_id, segment_id and segment_name.

Property Name Property Type Description
subscriber_id Array of String To denote the array of the id of the subscribers. Value is always unique.
segment_id String To denote the id of segment. Value is always unique.
segment_name String To denote name of segment.

Optional Object

Property Name Property Type Description
message String Present in case of failure. Used to denote reason of failure.

Getting a List of Segments#

This endpoint is used to list all segments that belongs to your site. There is no requirement of any parameter.

Example#

Request

  • cURL
  • PHP
curl -X GET 
-H "api_key: <your_pushengage_api_key>" 
"https://api.pushengage.com/apiv1/segments"
<?php

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/segments",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "api_key: <your_pushengage_api_key>",
        "cache-control: no-cache"
      ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
?>

Response

  • 200 OK
  • 401 Unauthorized
{
  "segments": [
    {
      "subscriber_id": [
        "123456789"
      ],
      "segment_id": "234567",
      "segment_name": "coupon"
    },
    {
      "subscriber_id": [
        "124568978","123456789"
      ],
      "segment_id": "123455",
      "segment_name": "laptop"
    }
  ],
  "success": true,
  "count": 2
}
{
  "success": false,
  "message": "API KEY Invalid"
}

Getting List of All Types of Segments#

This endpoint is used to list all segments that belongs to your site. This will include segments created along with geo, device and browser segmentation. The required parameter for this is segment_type.

Request Parameters

Required Parameters

  • segment_type

Example#

Request

  • cURL
  • PHP
curl -X GET 
-H "api_key: <your_pushengage_api_key>" 
"https://api.pushengage.com/apiv1/segments?segment_type=all"
<?php

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/segments?segment_type=all",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "api_key: <your_pushengage_api_key>",
        "cache-control: no-cache"
      ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
?>

Response

  • 200 OK
  • 401 Unauthorized
{
    "data": {
        "segments": [
            {
                "segment_id": "1234",
                "segment_name": "segment1"
            },
            {
                "segment_id": "1235",
                "segment_name": "segment2"
            }
        ],
        "countries": [
            "country1",
            "country2"
        ],
        "states": [
            "state1",
            "state2",
        ],
        "cities": [
            "city1",
            "city2",
        ],
        "device_types": [
            "desktop",
            "mobile"
        ],
        "browsers": [
            "chrome",
            "firefox"
        ]
    },
    "success": true
}
{
  "success": false,
  "message": "API KEY Invalid"
}

Getting a Single Segment#

This endpoint is used to get single segment. This endpoint requires parameter segment_id.

Example#

Request

  • cURL
  • PHP
curl -X GET 
-H "api_key: <your_pushengage_api_key>" 
"https://api.pushengage.com/apiv1/segments?segment_id=234567"
<?php

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/segments?segment_id=234567",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "api_key: <your_pushengage_api_key>",
        "cache-control: no-cache"
      ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
?>

Response

  • 200 OK
  • 401 Unauthorized
  • 400 Bad Request
{
  "segments": [
    {
      "subscriber_id": [
        "123456789"
      ],
      "segment_id": "234567",
      "segment_name": "coupon"
    }
  ],
  "success": true,
  "count": 2
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "invalid segment_id",
  "success": false
}

Getting a List of Segment with Limit#

This endpoint is used to list limited segments. This endpoint requires parameter limit.

Example#

Request

  • cURL
  • PHP
curl -X GET 
-H "api_key: <your_pushengage_api_key>" 
"https://api.pushengage.com/apiv1/segments?limit=1"
<?php

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/segments?limit=1",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "api_key: <your_pushengage_api_key>",
        "cache-control: no-cache"
      ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
?>

Response

  • 200 OK
  • 401 Unauthorized
{
  "segments": [
    {
      "subscriber_id": [
        "123456789"
      ],
      "segment_id": "234567",
      "segment_name": "coupon"
    }
  ],
  "success": true,
  "count": 2
}
{
  "success": false,
  "message": "API KEY Invalid"
}

Getting a List of Segments with Offset#

This endpoint is used to list limited segments from a specified index. This endpoint requires parameters limit and offset.

Example#

Request

  • cURL
  • PHP
curl -X GET 
-H "api_key: <your_pushengage_api_key>" 
"https://api.pushengage.com/apiv1/segments?offset=1&limit=1"
<?php

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/segments?offset=1&limit=1",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "api_key: <your_pushengage_api_key>",
        "cache-control: no-cache"
      ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
?>

Response

  • 200 OK
  • 401 Unauthorized
{
  "segments": [
    {
      "subscriber_id": [
        "124568978","123456789"
      ],
      "segment_id": "123455",
      "segment_name": "laptop"
    }
  ],
  "success": true,
  "count": 2
}
{
  "success": false,
  "message": "API KEY Invalid"
}