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
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 429 Too Many Requests
- 502 Bad Gateway
{
"success": true
}
{
"success": false,
"message": "segment_name or profile_id or the operation is missing"
}
{
"success": false,
"message": "profile not present in site"
}
{
"success": false,
"error_code": "1018",
"message": "given operation is not in the list"
}
{
"success": false,
"error_code": "1001",
"message": "Invalid API Key"
}
{
"success": false,
"error_code": "1030",
"message": "Please upgrade to use this endpoint"
}
{
"success": false,
"error_code": "1009",
"message": "segment not present in site"
}
{
"success": false,
"error_code": "1005",
"message": "API Cap Enabled. You can send 300 requests per minute."
}
{
"success": false,
"message": "Something went wrong, Please try again"
}
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
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 429 Too Many Requests
- 502 Bad Gateway
{
"success": true
}
{
"success": false,
"message": "segment_name or profile_id or the operation is missing"
}
{
"success": false,
"message": "profile not present in site"
}
{
"success": false,
"error_code": "1018",
"message": "given operation is not in the list"
}
{
"success": false,
"error_code": "1001",
"message": "Invalid API Key"
}
{
"success": false,
"error_code": "1030",
"message": "Please upgrade to use this endpoint"
}
{
"success": false,
"error_code": "1009",
"message": "segment not present in site"
}
{
"success": false,
"error_code": "1005",
"message": "API Cap Enabled. You can send 300 requests per minute."
}
{
"success": false,
"message": "Something went wrong, Please try again"
}