REST API
  • Documentation
  • /
  • REST API

Welcome to the REST API. Below, you’ll find a full listing of all the available endpoints. As we add more endpoints, they will be automatically documented here.

If you have any issue or need any help using the REST API, 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’ll 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.

Resource Description
POSThttps://api.pushalert.co/rest/v1/send Send notification to all users.
POSThttps://api.pushalert.co/rest/v1/send Send notification to a single user.
POSThttps://api.pushalert.co/rest/v1/send Send notification to more than 1 user.
POSThttps://api.pushalert.co/rest/v1/segment/$SEG_ID/send Send notification to a segment.
GEThttps://api.pushalert.co/rest/v1/info/$ID Get stats about the particular notification like attempted, delivered, clicked, CTR
GEThttps://api.pushalert.co/rest/v1/segments Get all segments
POSThttps://api.pushalert.co/rest/v1/segment/create Create a new segment.
POSThttps://api.pushalert.co/rest/v1/segment/delete Delete a segment.
POSThttps://api.pushalert.co/rest/v1/segment/$SEG_ID/add Add subscriber(s) to a segment.
POSThttps://api.pushalert.co/rest/v1/segment/$SEG_ID/remove Remove subscriber(s) from a segment.

POST /rest/v1/send

Send notification to all users.

Resource Information

   
Method POST
URL https://api.pushalert.co/rest/v1/send
Requires authentication? Yes

Request Parameters

Parameter Type Description
icon (string) Optional. URL of the icon (192x192 pixels recommended).
title (string) Required. Notification title.
message (string) Required. Notification message.
url (string) Required. URL of the target page.

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/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

{
	"result": "success",
	"id": 11
}

POST /rest/v1/send

Send notification to a single user.

Resource Information

   
Method POST
URL https://api.pushalert.co/rest/v1/send
Requires authentication? Yes

Request Parameters

Parameter Type Description
icon (string) Optional. URL of the icon (192x192 pixels recommended).
title (string) Required. Notification title.
message (string) Required. Notification message.
url (string) Required. URL of the target page.
subscriber (string) Required. Subscribe ID of the target user.

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&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

{
	"result": "success",
	"id": 11
}

POST /rest/v1/send

Send notification to more than 1 user.

Resource Information

   
Method POST
URL https://api.pushalert.co/rest/v1/send
Requires authentication? Yes

Request Parameters

Parameter Type Description
icon (string) Optional. URL of the icon (192x192 pixels recommended).
title (string) Required. Notification title.
message (string) Required. Notification message.
url (string) Required. URL of the target page.
subscribers (string) Required. Array of subscriber IDs in JSON form.

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&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

{
	"result": "success",
	"id": 11
}

POST /rest/v1/segment/$SEG_ID/send

Send notification to a segment.

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
icon (string) Optional. URL of the icon (192x192 pixels recommended).
title (string) Required. Notification title.
message (string) Required. Notification message.
url (string) Required. URL of the target page.

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

{
	"result": "success",
	"id": 11
}

GET /rest/v1/info/$ID

Get stats about the particular notification like attempted, delivered, clicked and 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) Notification sent to these no. of users.
Delivered (int) Notification delivered to these no. of users.
Clicked (int) Notification clicked by these no. of users.
CTR (double) Click through rate in percent.

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

{
	"result": "success",
	"attempted": 1540,
	"delivered": 890,
	"clicked": 179,
	"ctr": "20.11%",
}

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

{
	"result": "success",
	"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.

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

{
	"result": "success",
	"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

{
	"result": "success"
}

POST /rest/v1/segment/$SEG_ID/add

Add subscribers to a segment.

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 (mixed) 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

{
	"result": "success"
}

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 (mixed) 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

{
	"result": "success"
}