Create Segment
This endpoint facilitates the creation of a segment. This call accepts form-encoded request bodies and returns responses in JSON format.
POST
https://api.pushengage.com/apiv1/segments
Request Parameters
Parameter Name | Type | Required | Description |
---|---|---|---|
segment_name | String | Yes | The name of the segment to which notifications can be sent. |
Response Object
Property Name | Type | Required | Description |
---|---|---|---|
success | Boolean | Yes | Indicates if the request was successful. Possible values are true or false . |
segment_id | String | Yes | Unique identifier for the segment. |
message | String | No | Provided when the request fails, explaining the reason for the failure. |
Example
Request
- cURL
- PHP
curl -X POST -H "api_key: <your_pushengage_api_key>" -H "Content-Type: application/x-www-form-urlencoded" -d 'segment_name=coupon' "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 => "POST",
CURLOPT_POSTFIELDS => "segment_name=coupon",
CURLOPT_HTTPHEADER => array(
"api_key: <your_pushengage_api_key>",
"content-type: application/x-www-form-urlencoded"
),
));
$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
{
"success": true,
"segment_id": 98756
}
{
"success": false,
"message": "API KEY Invalid"
}
{
"message": "ENTER A VALID SEGMENT NAME",
"success": false
}