Profile with Segment#

Getting Started#

Introduction

This endpoint is used to add profile to a segment or, delete profile from a segment. The request method of this call needs to be "POST". Segment name, profile id and operation has to be sent as POST parameters to the API endpoint.

Request URL

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

Method

  POST

Request Parameters

Required Parameters

Parameter Name Parameter Type Description
segment_name String This defines the segment name. You can send notifications to particular segment.
profile_id Array of String A profile id is unique for a subscriber provided by customer. Notifications will be sent to only to those devices having this profile id.
operation String Valid Values are add or delete.

Response Objects

Required Object

Property Name Property Type Description
success Boolean To denote whether the request succeeded or not. Values can be 'true' or 'false'.

Optional Object

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

Adding Profile to a Segment#

This endpoint is used to add profile to a segment. This request requires parameter segment_name, profile_id and operation. In this case operation value should be 'add'.

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>",
        "cache-control: no-cache",
        "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
  • 400 Bad Request
  • 400 Bad Request
  • 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#

This endpoint is used to delete profile from a segment. This request requires parameter segment_name, profile_id and operation. In this case operation value should be 'delete'.

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>",
        "cache-control: no-cache",
        "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
  • 400 Bad Request
  • 400 Bad Request
  • 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"
}