Sending Push#

Getting Started#

Introduction

This endpoint is used to create new notifications and can be sent to all subscribers. The request method of this call needs to be a "POST". The title, message, URL and other option of the notification have to be sent as "POST" parameters to the API endpoint.

Request URL

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

Method

POST

Request Parameters

Required Parameters

Parameter Name Parameter Type Description
notification_title String Title of the push notification.
notification_message String The message to be displayed in the push notification.
notification_url String URL to be opened, on clicking the received push notification.

Optional Parameters

Parameter Name Parameter Type Description
image_url String Image to be displayed in the Push Notification.
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.
include_segments Array of String Include_segments accepts value as array of segment_id. Notifications will be sent to only those subscribers, which are subscribed in this segment.
include_countries Array of String include_countries accepts value as array of country. Notifications will be sent to only those subscribers, which are subscribed from these countries.
include_states Array of String include_states accepts value as array of state. Notifications will be sent to only those subscribers, which are subscribed from these states.
include_cities Array of String include_cities accepts value as array of city. Notifications will be sent to only those subscribers, which are subscribed from these cities.
include_device_types Array of String include_device_types accepts value as array of device. Notifications will be sent to only those subscribers, which are subscribed from these devices.
include_browsers Array of String include_browsers accepts value as array of browser. Notifications will be sent to only those subscribers, which are subscribed from these browsers.
require_interaction Number This defines the maximum duration for the notification to remain on browsers without user interaction.
notification_expiry Number This is the expiry time for a notification after which the notification will not be sent to subscribers. The maximum time is 28 days.
notification_type String This defines the notification send time such as now, later or draft. By default, the notification send time is now.
subscriber_hash Array of String A subscriber hash is unique for a subscriber provided by PushEngage. Notifications will be sent to the device having this subscriber hash.
big_image_url String The URL of an image to be displayed as part of the notification.

Response Objects

Mandatory Object

Property Name Property Type Description
success Boolean Indicates whether push request succeeded or not. Values can be 'true' or 'false'.
Notification_id Number Indicates unique id of notification.

Optional Object

Property Name Property Type Description
message String Present in case of failure. Indicates the reason of failure.

Sample Push Notification#

The sample push notification requires these parameters -

  • notification_title (Title should not exceed 45 characters.)
  • notification_message (Message should not exceed 73 characters.)
  • notification_url (URLs should be in W3C format.)

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12345
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Image#

Push with a custom notification image. This image replaces site logo in the notification. For push notification with image the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • image_url.

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&image_url=your_image_path/image.png'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&image_url=your_image_path/image.png",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12346
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Profile Id#

Notifications will be sent to only those devices which has this profile id. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • profile_id

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&profile_id[0]=<profile_id>&profile_id[1]=<profile_id>'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&profile_id[0]=<profile_id>&profile_id[1]=<profile_id>",
      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;
    }
?>

Note

Maximum entries in profile_id array is 100.

Response

  • 200 OK
  • 401 Unauthorized
  • 400 Bad Request
  • 400 Bad Request
  • 400 Bad Request
  • 400 Bad Request
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12347
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "No Subcribers Found for the given profile_id"
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Segment#

Notifications will be sent to only those subscribers which are subscribed to this segment. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • include_segments

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&include_segments[0]=123456'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&include_segments[0]=123456",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12348
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Geo segmentation#

Notifications will be sent to only those subscribers which are subscribed from these geos. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • include_countries
  • include_states
  • include_cities

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&include_countries[0]=countryname&include_states[0]=statename&include_cities[0]=cityname'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&include_countries[0]=countryname&include_states[0]=statename&include_cities[0]=citiesname",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12348
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Device Segmentation#

Notifications will be sent to only those subscribers which are subscribed from these devices. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • include_device_types

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&include_device_types[0]=desktop'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&include_device_types[0]=desktop",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12348
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Browser Segmentation#

Notifications will be sent to only those subscribers which are subscribed from these browsers. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • include_browsers

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&include_browsers[0]=chrome'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&include_browsers[0]=chrome",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12348
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with required Interaction#

This feature is available for Chrome 47 and above versions only. For chrome browser below version 47 default notification duration is 20 seconds. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • require_interaction (its value should be 0 or 1)

If require_interaction value is 0 means notification duration is 20 seconds and 1 means notification duration is 28 days. The default value of require_interaction is 1.

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&require_interaction=0'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&require_interaction=0",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12349
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Expiry Time#

This defines the expiry time for a notification. If a user is not available online with a browser running,then the notification will be attempted until expiration time. The maximum and default duration of notification expiry is 1 month. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • notification_expiry (Its value should be in minutes.)

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&notification_expiry=10'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&notification_expiry=10",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12350
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Notification Type#

This defines the notification sending time as now, later or draft. If you select the option now, the notification is sent to subscribers immediately. If you select the option later the notification will be scheduled to sent. If you select the option draft, the notification is saved in draft status in PushEngage. By default the notification sent type is now. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • notification_type (default value is "now")

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&notification_type=now'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&notification_type=now",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12351
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Subscriber Hash#

Notifications will be sent to only the device having this subscriber hash. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • subscriber_hash.

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&subscriber_hash[0]=<subscriber_hash>&subscriber_hash[1]=<subscriber_hash>&subscriber_hash[2]=<subscriber_hash>'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&subscriber_hash[0]=<subscriber_hash>&subscriber_hash[1]=<subscriber_hash>&subscriber_hash[2]=<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;
    }
?>

Note

Maximum entries in subscriber_hash array is 100.

Response

  • 200 OK
  • 401 Unauthorized
  • 400 Bad Request
  • 400 Bad Request
  • 400 Bad Request
  • 400 Bad Request
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12352
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "No Subcribers Found for the given subscriber_hash"
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Multi Action#

Push notification with multi action for targeting users. You can use custom image for each call to action. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • multi_element_title1
  • multi_element_url1
  • multi_element_image1
  • multi_element_title2
  • multi_element_url2
  • multi_element_image2

Example#

Request

Case a: Push Notification with One Action Button

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&multi_element_title1=Men&multi_element_url1=http://www.example.com/men.html&multi_element_image1=http://www.example.com/image.png'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&multi_element_title1=Men&multi_element_url1=http://www.example.com/men.html&multi_element_image1=http://www.example.com/image.png",
      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;
    }
?>

Case b: Push Notification with Two Action Button

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&multi_element_title1=Men&multi_element_url1=http://www.example.com/men.html&multi_element_image1=http://www.example.com/men.png&multi_element_title2=Women&multi_element_url2=http://www.example.com/women.html&multi_element_image2=http://www.example.com/women.png'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&multi_element_title1=Men&multi_element_url1=http://www.example.com/men.html&multi_element_image1=http://www.example.com/men.png&multi_element_title2=Women&multi_element_url2=http://www.example.com/women.html&multi_element_image2=http://www.example.com/women.png",
      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;
    }
?>

Note

multi_element_image1 and multi_element_image2 are optional parameters.

Response

  • 200 OK
  • 401 Unauthorized
  • 400 Bad Request
  • 400 Bad Request
  • 400 Bad Request
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12353
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Push Notification with Big Image#

Push notification with big image will display the image as part of the notification. For this push notification the required parameters are -

  • notification_title
  • notification_message
  • notification_url
  • big_image_url

Example#

Request

  • cURL
  • PHP
curl -X POST
-H "api_key: <your_pushengage_api_key>"
-H "Content-Type: application/x-www-form-urlencoded"
-d 'notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&big_image_url=your_image_path/image.png'
"https://api.pushengage.com/apiv1/notifications"
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.pushengage.com/apiv1/notifications",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "notification_title=this is title of notification&notification_message=this is message of notification&notification_url=http://www.example.com&big_image_url=your_image_path/image.png",
      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
  • 500 Internal Server Error
{
  "success": true,
  "notification_id": 12359
}
{
  "success": false,
  "message": "API KEY Invalid"
}
{
  "message": "The Title field is required.",
  "success": false
}
{
  "message": "The Message field is required.",
  "success": false
}
{
  "message": "The URL field is required.",
  "success": false
}
{
  "success": false,
  "message": "sending notification failed"
}

Note

Push notification with combination of optional parameters according to your requirements.

Push Notification with Impression Count Callback URL#

Push notification with Impression Count Callback URL will send third party URL to be called when impression is viewed by the notification.

Note

This API is restricted reach out to care@pushengage.com for approval.