POST Send Push to All Subscribers

Please use the endpoing URL below to send a notification to all subscribers. The request method of this call needs to be "POST".

The title, message and URL of the notification and the Image URL have to be sent as POST parameters to the API endpoint.

URL of the image to be shown in the notification needs to point to a 192 x 192 PNG.

Endpoint URL

https://app.webpushr.com/api/v1/notification/send/all

Request Parameters

Parameter Type Description
title string required Title of the notification Character limit: 100
message string required Body of the notification Character limit: 250
target_url string required This is the URL that will be opened when someone clicks on the notification. This will be URL to your article, product listing or any other page on your site that you are promoting via push notification. Character limit: 255
name string optional This is only used for internal reporting and Webpushr dashboard views. We recommend naming each campaign based on the campaign's purpose. Character limit: 100
icon string optional URL of the icon to be shown in the notification. URL needs to be on HTTPS and needs to point to a 192 x 192 PNG.
image string optional URL of the big image to be shown in the notification. URL needs to be on HTTPS and needs to point to an image file. Please note that this only works for Chrome subscribers on Android & Edge Browsers. Chrome on Desktop & Firefox does not support this as of now.
expire_push string optional This parameter is used to set the time (in minutes, hours or days) up till which the notification should be attempted if the subscriber is offline. If this is not set, the default value of 4 weeks is used. Pass a number followed by 'm' for minutes, 'h' for hours & 'd' for days. Example: '5d' for 5 days, '50d' for 50 days.
auto_hide integer optional To be sent as a POST parameter and should be a binary (1 or 0) value. '1' will keep the notification on recepients' screen until it is actively clicked upon or closed. '0' will close the notification automatically, after a few seconds, after it appears on the screen.
send_at date optional You will set this if you want to send the notification at a scheduled time in the future. The format is expressed in terms of delta to UTC. Example: 2019-10-10 19:31 +5:30
action_buttons array optional A multi-diminsional array containting the list of buttons. Note that these OPTIONAL buttons are not supported by all browsers and devices at this time.
Parameter Type Description
title string required Title of the action button Character limit: 100
url string required URL of the action button. Character limit: 100

Examples

curl -X POST \
-H "webpushrKey: <YOUR REST API KEY>" \
-H "webpushrAuthToken: <YOUR AUTHENTICATION TOKEN>" \
-H "Content-Type: application/json" \
-d '{"title":"notification_title","message":"notification message","target_url":"https://www.webpushr.com"}' \
https://app.webpushr.com/api/v1/notification/send/all
	$end_point = 'https://app.webpushr.com/api/v1/notification/send/all';
	$http_header = array( 
		"Content-Type: Application/Json", 
		"webpushrKey: <YOUR REST API KEY>", 
		"webpushrAuthToken: <YOUR AUTHENTICATION TOKEN>"
	);
	$req_data = array(
		'title' 			=> "Notification title", //required
		'message' 		=> "Notification message", //required
		'target_url'	=> 'https://www.webpushr.com', //required
		'name'			=> 'Test campain',
		'icon'			=> 'https://www.webpushr.com/logo.png',
		'image'			=> 'https://www.webpushr.com/image.png',
		'auto_hide'		=> 1,
		'expire_push'	=> '5m',
		'send_at'		=> '2019-10-10 19:31 +5:30',
		'action_buttons'=> array(	
			array('title'=> 'Demo', 'url' => 'https://www.webpushr.com/demo'),
			array('title'=> 'Rates', 'url' => 'https://www.webpushr.com/pricing')
		)
	);
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
	curl_setopt($ch, CURLOPT_URL, $end_point );
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($req_data) );
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$response = curl_exec($ch);
	echo $response;

Result Format

{
   "status" : "success",
   "description" : "Campaign created successfully!", 
   "ID" : 1
}
{
    "status": "failure",
    "type" : "header_invalid",
    "description": "Missing webpushrKey in header"
}
{
    "status": "failure",
    "type" : "bad_request",
    "description": "Invalid JSON request"
}
{
    "status": "failure",
    "type" : "authentication_failure",
    "description": "You are not authorized"
}
{
    "status": "failure",
    "type" : "rate_limit",
    "description": "Too many requests"
}
{
    "status": "failure",
    "description": "Something went wrong. Please try again after some time"
}
{
    "status": "failure",
    "type": "missing_parameter",
    "description": "Missing required parameter title"
}
{
    "status": "failure",
    "type": "invalid_format",
    "description": "Schedule date must be in valid format YYYY-MM-DD HH:MM +0"
}
{
    "status": "failure",
    "type": "invalid_format",
    "description": "Please provide the valid format for expire_push perameter."
}
{
    "status": "failure",
    "type": "invalid_value",
    "description": "Schedule date must be at least 5 minutes in future"
}
{
    "status": "failure",
    "type": "invalid_value",
    "description": "Invalid parameter 'action_buttons' values"
}
{
    "status": "failure",
    "type": "invalid_type",
    "description": "Parameter action_buttons must be an array"
}