This is the PushAlert REST API documentation. Below, you will find the complete listing of all the available endpoints. As we add more endpoints, they will be documented here as well.
If you need help using the REST API or have any issues with its implementation, please send a mail to us at api@pushalert.co.
For more information about a particular endpoint, click on its name under the Resource header. You will be taken to the endpoint's documentation, which includes query parameters the endpoint will accept, JSON object's parameters in the response, and an example query/response.
Sending Notifications
POST /rest/v1/send
Using this endpoint you can send a notification to all subscribers. Subscribers can be targeted based on a particular Segment ID (endpoint) or using the Audience Creator ID. You can also personalize a notification with attributes.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/send |
Requires authentication? |
Yes |
Request Parameters
Parameter |
Type |
Description |
title |
(string) |
Required This is the title of the notification. It's maximum length is restricted to 64 characters. |
message |
(string) |
Required The message body, with a maximum length of 192 characters. |
url |
(string) |
Required URL of the target page where you want subscribers to land after clicking on the notification. |
icon |
(string) |
Optional URL of the icon (192x192 pixels recommended). The icon URL should be served over HTTPS. If not specified or not available over a secure connection, the default icon from account would be used. |
large_image |
(string) |
Optional URL of the hero image (720x360 pixels recommended, 1.5 aspect ratio). The large image URL should be served over HTTPS. If not specified or not available over a secure connection, this will not be sent. |
action1 |
(array) |
Optional An array containing the title and URL to be used for the first CTA button in the notification. Both title and URL are required. The title can be of maximum 16 characters. If longer, the button will not be shown. Eg. '{"title":"Click here!", "url":"https://example.com"}' (including quotes) |
action2 |
(array) |
Optional An array containing the title and URL to be used for the second CTA button in the notification. Both title and URL are required. The title can be of maximum 16 characters. If longer, the button will not be shown. Eg. '{"title":"Summer Sale!", "url":"https://example.com"}' (including quotes) |
action1_attr |
(array) |
Optional An array containing the title and URL with attributes to be used for the first CTA button in the notification. Both title and URL are required. The title can be of maximum 16 characters. If longer, the button will not be shown. Please make sure that action1 (fallback) is also added or the button with attributes will not be shown. Eg. '{"title":"Apply {{coupon_code}}", "url":"https://example.com"}' (including quotes) |
action2_attr |
(array) |
Optional An array containing the title and URL with attributes to be used for the second CTA button in the notification. Both title and URL are required. The title can be of maximum 16 characters. If longer, the button will not be shown. Please make sure that action2 (fallback) is also added or the button with attributes will not be shown. Eg. '{"title":"Apply {{coupon_code}}", "url":"https://example.com"}' (including quotes) |
audience_id |
(int) |
Optional ID of target audience, created via Audience Creator from Dashboard. Used for precise targeting. |
subscriber |
(string) |
Optional To send a notification to a particular subscriber, use the subscriber ID with this endpoint. |
subscribers |
(string) |
Optional To send a notification to a specific set of subscribers, you can include this parameter with an array of subscriber IDs in JSON format. Only one among subscriber or subscribers parameters can be used in a single endpoint call. |
title_attr |
(string) |
Optional Notification title with custom attributes. This is an optional field, if attributes are not found, the title parameter will be used. |
message_attr |
(string) |
Optional Notification message with custom attributes. If omitted or attributes not available then the message parameter will be used. |
url_attr |
(string) |
Optional Notification URL with custom attributes. If omitted or attributes not available then the url parameter will be used. |
expire_time |
(int) |
Optional Define the expiry time of a notification in seconds. By default it is set to 86400 seconds or 24 hours. |
schedule_time |
(unix-timestamp) |
Optional Define the time when you want the notification to be sent with a 10-digit unix timestamp. |
Response Parameters
Parameter |
Type |
Description |
id |
(int) |
ID of the sent notification. |
Example: Send to All Subscribers
curl -H "Authorization: api_key=<insert api key here>" --data "title=Your%20Title&message=Your%20Message&icon=http://yourwebsite.com/icon.png&url=https://yourwebsite.com" https://api.pushalert.co/rest/v1/send
<?php
$title = "Notification Title";
$message = "Notification Message";
$icon = "https://yourwebsite.com/icon.png";
$url = "https://yourwebsite.com/";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/send";
//POST variables
$post_vars = array(
"icon" => $icon,
"title" => $title,
"message" => $message,
"url" => $url
);
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo $output["id"]; //Sent Notification ID
}
else {
//Others like bad request
}
?>
Output
{
"success": true,
"id": 11
}
Example: Send to a Single Subscriber
curl -H "Authorization: api_key=<insert api key here>" --data "title=Your%20Title&message=Your%20Message&icon=http://yourwebsite.com/icon.png&url=https://yourwebsite.com&subscriber=SUBSCRIBER_ID" https://api.pushalert.co/rest/v1/send
<?php
$title = "Notification Title";
$message = "Notification Message";
$icon = "https://yourwebsite.com/icon.png";
$url = "https://yourwebsite.com/";
$subscriber = "SUBSCRIBER_ID";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/send";
//POST variables
$post_vars = array(
"icon" => $icon,
"title" => $title,
"message" => $message,
"url" => $url,
"subscriber" => $subscriber
);
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo $output["id"]; //Sent Notification ID
}
else {
//Others like bad request
}
?>
Output
{
"success": true,
"id": 11
}
Example: Send to Multiple Subscribers
curl -H "Authorization: api_key=<insert api key here>" --data "title=Your%20Title&message=Your%20Message&icon=http://yourwebsite.com/icon.png&url=https://yourwebsite.com&subscribers=[\"SUBSCRIBER_ID1\",\"SUBSCRIBER_ID2\"]" https://api.pushalert.co/rest/v1/send
<?php
$title = "Notification Title";
$message = "Notification Message";
$icon = "https://yourwebsite.com/icon.png";
$url = "https://yourwebsite.com/";
$subscribers = array(
"SUBSCRIBER_ID1",
"SUBSCRIBER_ID2"
);
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/send";
//POST variables
$post_vars = array(
"icon" => $icon,
"title" => $title,
"message" => $message,
"url" => $url,
"subscribers" => json_encode($subscribers)
);
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo $output["id"]; //Sent Notification ID
}
else {
//Others like bad request
}
?>
Output
{
"success": true,
"id": 11
}
Notification with Custom Attributes
Using this API call you can personalize notifications with custom attributes. Since there can be some users without attribute values, you need to mention the default title and message as well. To use an attribute in title or message, use double curly braces i.e. {{attribute_name}}, {{email}}, {{name}} etc. For adding attributes to subscribers, you can refer to the JS API function addAttributes or use this REST API Endpoint.
Example
curl -H "Authorization: api_key=<insert api key here>" --data "title=Your%20Title&message=Your%20Message&url=https://yourwebsite.com/&title_attr=Hi%20{{name}}&message=Your%20Custom%20Message%20for%20{{name}}&url_attr=https://yourwebsite.com/account/user/{{user_id}}&icon=http://yourwebsite.com/icon.png&subscribers=[\"SUBSCRIBER_ID1\",\"SUBSCRIBER_ID2\"]" https://api.pushalert.co/rest/v1/send
<?php
$title = "Notification Title";
$message = "Notification Message";
$title_attr = "Hi {{name}}";
$message_attr = "Your Custom Message for {{name}}";
$icon = "https://yourwebsite.com/icon.png";
$url = "https://yourwebsite.com/";
$url_attr = "https://yourwebsite.com/account/user/{{user_id}}";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/send";
//POST variables
$post_vars = array(
"icon" => $icon,
"title" => $title,
"message" => $message,
"url" => $url,
"title_attr" => $title_attr,
"message_attr" => $message_attr,
"url_attr" => $url_attr
);
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo $output["id"]; //Sent Notification ID
}
else {
//Others like bad request
}
?>
Output
{
"success": true,
"id": 11
}
POST /rest/v1/segment/$SEG_ID/send
Send notification to a pre-defined segment of subscribers. You can create segments both from Dashboard -> Segmentation as well through the Create Segment call.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/segment/$SEG_ID/send |
Requires authentication? |
Yes |
Method Parameters
Parameter |
Type |
Description |
$SEG_ID |
(int) |
Segment ID. |
Request Parameters
Parameter |
Type |
Description |
title |
(string) |
Required This is the title of the notification. It's maximum length is restricted to 64 characters. |
message |
(string) |
Required The message body, with a maximum length of 192 characters. |
url |
(string) |
Required URL of the target page where you want subscribers to land after clicking on the notification. |
icon |
(string) |
Optional URL of the icon (192x192 pixels recommended). The icon URL should be served over HTTPS. If not specified or not available over a secure connection, the default icon from account would be used. |
Response Parameters
Parameter |
Type |
Description |
id |
(int) |
ID of the sent notification. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "title=Your%20Title&message=Your%20Message&icon=http://yourwebsite.com/icon.png&url=https://yourwebsite.com" https://api.pushalert.co/rest/v1/segment/999/send
<?php
$title = "Notification Title";
$message = "Notification Message";
$icon = "https://yourwebsite.com/icon.png";
$url = "https://yourwebsite.com/";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/segment/999/send"; //place your segment id instead of 999
//POST variables
$post_vars = array(
"icon" => $icon,
"title" => $title,
"message" => $message,
"url" => $url
);
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo $output["id"]; //Sent Notification ID
}
else {
//Others like bad request
}
?>
Output
{
"success": true,
"id": 11
}
Notification Stats
GET /rest/v1/info/$ID
Get detailed stats about a particular notification including total subscibers attempted, total delivered, number of clicks and overall click-through-rate (CTR).
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/info/$ID |
Requires authentication? |
Yes |
Method Parameters
Parameter |
Type |
Description |
$ID |
(int) |
ID of the notification. |
Response Parameters
Parameter |
Type |
Description |
Attempted |
(int) |
Total number of subscribers the notification was sent to. This is generally equal to the total number of subscribers of your website. However, if some subscribers have unsubscribed, or blocked notifications, this reflects the current active subscriber base. |
Delivered |
(int) |
Total number of subscribers the notification was delivered to, this is not a static statistic. It keeps on updating as your subscribers come online and receive the notification. |
Clicked |
(int) |
Number of clicks on the notification, again this is a dynamic stat and keeps on updating throughout the day. To see specific clicks on particular Action buttons, please check analytics on the Dashboard. |
CTR |
(double) |
Overall click-through-rate (CTR) till now, based on total delivery. |
Example
curl -H "Authorization: api_key=<insert api key here>" https://api.pushalert.co/rest/v1/info/11
<?php
$notfID = 11;
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/info/$notfID";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Attempted: {$output["attempted"]}, Delivered: {$output["delivered"]}, Clicked: {$output["clicked"]} and CTR: {$output["ctr"]}%";
}
else {
//Others like bad request
}
?>
Output
{
"success": true,
"attempted": 1540,
"delivered": 890,
"clicked": 179,
"ctr": "20.11%",
}
Delete Scheduled
POST /rest/v1/delete/$ID
Delete a Scheduled Notification.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/delete/$ID |
Requires authentication? |
Yes |
Request Parameters
Parameter |
Type |
Description |
id |
(int) |
Required Notification ID. |
Response Parameters
Parameter |
Type |
Description |
success |
(string) |
true/false. |
Example
curl -H "Authorization: api_key=<insert api key here>" https://api.pushalert.co/rest/v1/delete/$ID
<?php
$ID = "NOTIFICATION_ID";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/delete/$ID";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$post_vars = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Scheduled Notification Deleted";
}
else {
//Others like bad request
}
?>
Output
{
"success": true,"msg": "Deleted successfully."
}
Advanced Segmentation
GET /rest/v1/segments
Get the list of all segments with their IDs as well as total subscribers.
Resource Information
|
|
Method |
GET |
URL |
https://api.pushalert.co/rest/v1/segments |
Requires authentication? |
Yes |
Response Parameters
Returns an array of segments, where each segment array contains:
Parameter |
Type |
Description |
id |
(int) |
Segment ID. |
name |
(string) |
Segment Name |
subscribers |
(int) |
Total no. of subscribers in this segment. |
Example
curl -H "Authorization: api_key=<insert api key here>" https://api.pushalert.co/rest/v1/segments
<?php
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/segments";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
for($i=0; $i<count($output["segments"]); $i++){
echo "{$output["segments"][$i]["id"]} - {$output["segments"][$i]["name"]} - {$output["segments"][$i]["subscribers"]}\n";
}
}
else {
//Others like bad request
}
?>
Output
{
"success": true,
"segments": {
{
"id":999,
"name": "PhoneNews",
"subscribers": 2345
},
{
"id":1021,
"name": "PoliticsNews",
"subscribers": 1636
},
{
"id":2452,
"name": "EntertainmentNews",
"subscribers": 7421
},
}
}
POST /rest/v1/segment/create
Create a new segment programmatically. You can also create a segment from Dashboard > Segmentation.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/segment/create |
Requires authentication? |
Yes |
Request Parameters
Parameter |
Type |
Description |
name |
(string) |
Required Segment name. |
Response Parameters
Parameter |
Type |
Description |
id |
(int) |
ID of created segment. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "name=YOUR_SEGMENT_NAME" https://api.pushalert.co/rest/v1/segment/create
<?php
$seg_name = "YOUR_SEGMENT_NAME";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/segment/create";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$post_vars = array(
"name" => $seg_name
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo $output["id"]; //Created Segment ID
}
else {
//Others like bad request
}
?>
Output
{
"success": true,
"id": 8979
}
POST /rest/v1/segment/delete
Delete a segment.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/segment/delete |
Requires authentication? |
Yes |
Request Parameters
Parameter |
Type |
Description |
id |
(int) |
Required Segment ID. |
Response Parameters
Parameter |
Type |
Description |
result |
(string) |
Success/Failure. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "id=YOUR_SEGMENT_ID" https://api.pushalert.co/rest/v1/segment/delete
<?php
$seg_id = "YOUR_SEGMENT_ID";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/segment/delete";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$post_vars = array(
"id" => $seg_id
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Segment deleted";
}
else {
//Others like bad request
}
?>
Output
{
"success": true
}
POST /rest/v1/segment/$SEG_ID/add
Add subscribers to a segment. Requires Segment ID which is available from Dashboard > Segmentation or through the REST API call for all segment details.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/segment/$SEG_ID/add |
Requires authentication? |
Yes |
Method Parameters
Parameter |
Type |
Description |
$SEG_ID |
(int) |
Segment ID. |
Request Parameters
Parameter |
Type |
Description |
subscribers |
(string) |
Required Array of subscriber IDs in JSON form. |
Response Parameters
Parameter |
Type |
Description |
result |
(string) |
Success/Failure. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "subscribers=[\"SUBSCRIBER_ID1\",\"SUBSCRIBER_ID2\"]" https://api.pushalert.co/rest/v1/segment/999/add
<?php
$seg_id = "999"; //Your segment ID
$subscribers = array(
"SUBSCRIBER_ID1",
"SUBSCRIBER_ID2");
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/segment/$seg_id/add";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$post_vars = array(
"subscribers" => json_encode($subscribers)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Subscribers added successfully";
}
else {
//Others like bad request
}
?>
Output
{
"success": true
}
POST /rest/v1/segment/$SEG_ID/remove
Remove subscribers from a segment.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/segment/$SEG_ID/remove |
Requires authentication? |
Yes |
Method Parameters
Parameter |
Type |
Description |
$SEG_ID |
(int) |
Segment ID. |
Request Parameters
Parameter |
Type |
Description |
subscribers |
(string) |
Required Array of subscriber IDs to be removed in JSON format. |
Response Parameters
Parameter |
Type |
Description |
result |
(string) |
Success/Failure. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "subscribers=[\"SUBSCRIBER_ID1\",\"SUBSCRIBER_ID2\"]" https://api.pushalert.co/rest/v1/segment/999/remove
<?php
$seg_id = "999"; //Your segment ID
$subscribers = array(
"SUBSCRIBER_ID1",
"SUBSCRIBER_ID2");
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/segment/$seg_id/remove";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$post_vars = array(
"subscribers" => json_encode($subscribers)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Subscribers removed successfully";
}
else {
//Others like bad request
}
?>
Output
{
"success": true
}
Custom Attributes
POST /rest/v1/attribute/put
Add custom attributes to a subscriber. These attributes can be used in personalizing the notifications and for targeting a particular set of subscribers.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/attribute/put |
Requires authentication? |
Yes |
Request Parameters
Parameter |
Type |
Description |
subscriber |
(string) |
Required Subscribe ID of the target user. |
attributes |
(string) |
Required JSON Array of attributes in form of key-value pair. Maximum individual key length is 32 characters and value length is 128 characters. |
Response Parameters
Parameter |
Type |
Description |
result |
(string) |
Success/Failure. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "attributes={'name':'John','gender':'Male'}&subscriber=SUBSCRIBER_ID" https://api.pushalert.co/rest/v1/attribute/put
<?php
$subscriber_id = "SUBSCRIBER_ID";
$attributes = array(
"name"=>"John",
"gender"=>"Male");
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/attribute/put";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$post_vars = array(
"subscriber" => $subscriber_id,
"attributes" => json_encode(array($attr_name=>$attr_value))
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "Attributes added successfully";
}
else {
//Others like bad request
}
?>
Output
{
"success": true
}
POST /rest/v1/attribute/get
Get custom attributes of a subscriber. These attributes can be used in personalizing the notifications and for targeting a particular sets of subscribers.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/attribute/get |
Requires authentication? |
Yes |
Request Parameters
Parameter |
Type |
Description |
subscriber |
(string) |
Required Subscribe ID of the target user. |
Response Parameters
Parameter |
Type |
Description |
result |
(string) |
Success/Failure. |
attributes |
(string) |
If success, then key-value pairs of attributes. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "subscriber=SUBSCRIBER_ID" https://api.pushalert.co/rest/v1/attribute/get
<?php
$subscriber_id = "SUBSCRIBER_ID";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/attribute/get";
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$post_vars = array(
"subscriber" => $subscriber_id
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
print_r($output['attributes']);
}
else {
//Others like bad request
}
?>
Output
{
"success": true
}
Custom Events Tracking and Triggers
POST /rest/v1/track/event
Using this endpoint you can trigger a notification in the back-end based on user interaction. It requires the subscription ID to be passed along with the event parameters.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/track/event |
Requires authentication? |
Yes |
Parameter |
Type |
Description |
Request Parameters
subscriber |
(string) |
Required The subscriber ID for the subscriber that triggered the event. |
eventCategory |
(string or integer) |
Required The object or page that was interacted with (e.g. 'Video'). |
eventAction |
(string or integer) |
Required The type of interaction (e.g. 'play','pause','stopped'). |
eventLabel |
(string or integer) |
Optional Used for categorizing events. (e.g. 'Launch Campaign'). |
eventValue |
(integer) |
Optional A numeric value associated with the event (e.g. 2017). |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "subscriber=SUBSCRIBER_ID&eventCategory=video&eventAction=play&eventLabel=winter%20collection&eventValue=51" https://api.pushalert.co/rest/v1/track/event
<?php
$subscriber = "SUBSCRIBER_ID";
$eventCategory = "video";
$eventAction = "play";
$eventLabel = "winter collection";
$eventValue = "51";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/track/event";
//POST variables
$post_vars = array(
"subscriber" => $subscriber,
"eventCategory" => $eventCategory,
"eventAction" => $eventAction,
"eventLabel" => $eventLabel,
"eventValue" => $eventValue,
);
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "success";
}
else {
//Others like bad request
}
?>
Output
{
"success": true
}
Automated Abandoned Cart Notifications
POST /rest/v1/abandonedCart
Using this endpoint you can schedule a notification when a cart is abandoned on your eCommerce store.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/abandonedCart |
Requires authentication? |
Yes |
Parameter |
Type |
Description |
Request Parameters
subscriber |
(string) |
Required The subscriber ID for the subscriber that triggered the event. |
extra_info |
(JSON Encoded Key-value Pair) |
Optional There can be two parameters sent in extra_info - first_name and total_items. You can choose to include either one of them or both. Where 'first_name' is the first or full name of the customer, while 'total_number' is the number of items in cart. For e.g. {'first_name':'Alex','total_items':2} This will be used to personalize the notification for your customer. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "subscriber=SUBSCRIBER_ID&extra_info={'first_name':'Alex','total_items':2}" https://api.pushalert.co/rest/v1/abandonedCart
<?php
$subscriber = "SUBSCRIBER_ID";
$extra_info = array(
'first_name'=>'Alex',
'total_items'=>2
);
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/abandonedCart";
//POST variables
$post_vars = array(
"subscriber" => $subscriber,
"extra_info" => json_encode($extra_info),
);
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "success";
}
else {
//Others like bad request
}
?>
Output
{
"success": true
}
POST /rest/v1/abandonedCart/delete
Use this endpoint to delete a previously scheduled abandoned cart notification when the order is completed or all products are removed from cart.
Resource Information
|
|
Method |
POST |
URL |
https://api.pushalert.co/rest/v1/abandonedCart/delete |
Requires authentication? |
Yes |
Parameter |
Type |
Description |
Request Parameters
subscriber |
(string) |
Required The subscriber ID for the subscriber that triggered the order completed event. |
Example
curl -H "Authorization: api_key=<insert api key here>" --data "subscriber=SUBSCRIBER_ID" https://api.pushalert.co/rest/v1/abandonedCart/delete
<?php
$subscriber = "SUBSCRIBER_ID";
$apiKey = "YOUR_API_KEY";
$curlUrl = "https://api.pushalert.co/rest/v1/abandonedCart/delete";
//POST variables
$post_vars = array(
"subscriber" => $subscriber
);
$headers = Array();
$headers[] = "Authorization: api_key=".$apiKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_vars));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
$output = json_decode($result, true);
if($output["success"]) {
echo "success";
}
else {
//Others like bad request
}
?>
Output
{
"success": true
}