View Segments
This endpoint retrieves a list of all segments created by users. The response is provided in JSON format.
GET
https://api.pushengage.com/apiv1/segments
Request Parameters
Parameter Name | Type | Required | Description |
---|---|---|---|
segment_id | String | No | The unique identifier generated when a segment is created. |
limit | Integer | No | Specifies the maximum number of segments to display in the results. Minimum value is 1. |
offset | Integer | No | The starting index for displaying segments. Minimum value is 0. |
segment_type | String | No | Retrieves all segments, including those based on geos, devices, and browsers, when set to 'all'. |
Response Object
Property Name | Type | Required | Description |
---|---|---|---|
segments | Segment[] | Yes | An array representing the segments. For more details, refer to the segment object section. |
success | Boolean | Yes | Indicates if the push response was successful. Possible values are true or false . |
count | Integer | Yes | Represents the total number of segments returned. |
message | String | No | Provided in the event of a failure, indicating the reason for the failure. |
Segment Object
Property Name | Type | Description |
---|---|---|
segment_id | String | The unique identifier for the segment. |
segment_name | String | The name associated with the segment. |
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": [
{
"segment_id": "234567",
"segment_name": "coupon"
},
{
"segment_id": "123455",
"segment_name": "laptop"
}
],
"success": true,
"count": 2
}
{
"success": false,
"message": "API KEY Invalid"
}