Add Subscriber to Segment using Profile ID
This endpoint allows you to add a subscriber to a segment using a profile ID. This call accepts form-encoded request bodies and returns responses in JSON format.
Profile IDs serve as unique identifiers for your subscribers, enabling you to recognize them across multiple devices and browsers. Each subscriber can be assigned just one profile ID. This ID should be a string, and you have the flexibility to use any value, such as an email or phone number.
POST
https://api.pushengage.com/apiv1/profile
Request Parameters
Parameter Name | Type | Required | Description |
---|---|---|---|
segment_name | String | Yes | Defines the segment name for targeting specific notifications. |
profile_id | String[] | Yes | A unique ID associated with a subscriber. Notifications are dispatched exclusively to devices possessing this ID. |
operation | String | Yes | Specifies the action to be performed. Acceptable values are add or delete . |
Response Object
Property Name | Type | Required | Description |
---|---|---|---|
success | Boolean | Yes | Indicates if the push response was successful. Can be either true or false . |
message | String | No | Provided when there's a failure, detailing the reason. |
Adding Profile to a Segment 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=<your_segment_name>&profile_id=<your_unique_profile_id>&operation=add' "https://api.pushengage.com/apiv1/profile"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.pushengage.com/apiv1/profile",
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=<your_segment_name>&profile_id=<your_unique_profile_id>&operation=add",
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
}
{
"success": false,
"message": "API KEY Invalid"
}
{
"success": false,
"message": "segment_name or profile_id or the operation is missing"
}
{
"success": false,
"message": "profile not present in site"
}
{
"success": false,
"message": "segment not present in site"
}
{
"success": false,
"message": "given operation is not in the list"
}
Deleting Profile from a Segment 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=<your_segment_name>&profile_id=<your_unique_profile_id>&operation=delete' "https://api.pushengage.com/apiv1/profile"
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.pushengage.com/apiv1/profile",
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=<your_segment_name>&profile_id=<your_unique_profile_id>&operation=delete",
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
}
{
"success": false,
"message": "API KEY Invalid"
}
{
"success": false,
"message": "segment_name or profile_id or the operation is missing"
}
{
"success": false,
"message": "profile not present in site"
}
{
"success": false,
"message": "segment not present in site"
}
{
"success": false,
"message": "given operation is not in the list"
}