Subscriber Hash#

Getting Started#

Introduction

This endpoint is used to add a subscriber to segment using subscriber hash. The request method of this call needs to be "POST". This request requires parameter segment_id and subscriber_hash.

Request URL

  https://api.pushengage.com/apiv1/segments/addSegmentWithHash

Method

  POST

Request Parameters

Required Parameters

Parameter Name Parameter Type Description
segment_id Number This is the id of segment, that is generated when a segment is created.
hashes Array This is a unique hash generated to identify subscriber.The maximum size of hashes array is 500.

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'.
message String Used to denote reason of failure and success.

Adding Subscriber to a Segment#

This endpoint is used to add a subscriber using hash 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_id=<Segment Id>&hashes[0]=<subscriber_hash>&hashes[1]=<subscriber_hash>' "https://api.pushengage.com/apiv1/segments/addSegmentWithHash"

<?php
      $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/segments/addSegmentWithHash",
      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_id=<Segment Id>&hashes[0]=<subscriber_hash>&hashes[1]=<subscriber_hash>",
      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
{
  "message": "Segment Addition to Subscriber Hashes is Successful",
  "success": true
}
{
  "message": "API KEY Invalid",
  "success": false
}
{
  "message": "Enter a valid segment id",
  "success": false
}
{
  "message": "Your enter segment id does not exist",
  "success": false
}
{
  "message": "Please Send Subscriber Hash",
  "success": false
}