Web Push Notifications API

Get a list of sent web push campaigns

To get a list of sent web push campaigns, send a GET request to:

https://api.sendpulse.com/push/tasks

Request parameters:

Parameter Type Description
limit int Number of records optional
offset int Offset (first record to be displayed)  optional
from* string Starting date optional
to* string Ending date optional
website_id id Website ID set for a campaign optional

*You must use such a format for dates: YYYY-MM-DD HH:MM:SS.

The maximum number of entries in one reply is 100.

Use the offset parameter to indicate the starting entry.

When using additional parameters, form URL in the following format (the example shows how to retrieve 10 entries starting from the 2nd one):

https://api.sendpulse.com/push/tasks/?limit=10&offset=2

If request is successful, you will receive a response:

[
  {
    "id": 121,
    "title": "push title",
    "body": "push text",
    "website_id": 53,
    "from": "2015-11-17 14:44:47",
    "to": "2015-12-23 19:42:27",
    "status": 13
  }
]

Get a total number of websites

To get a total number of websites, send a GET request to:

https://api.sendpulse.com/push/websites/total

If request is successful, you will receive a response:

{
  "total": 2
}

Get a list of websites

To get a list of websites, send a GET request to:

https://api.sendpulse.com/push/websites/

Request parameters:

Parameter Type Description
limit int Number of records optional
offset int Offset (first record to be displayed)  optional

When using additional parameters, form URL of the following format:

https://api.sendpulse.com/push/websites/?limit=10&offset=2

If request is successful, you will receive a response:

[
  {
    "id": 53,
    "url": "www.test-site.com",
    "add_date": "2015-11-23 14:42:37",
    "status": 1
  }
]

Get a list of variables for a website

To get a list of variables for a certain website, send a GET request to:

https://api.sendpulse.com/push/websites/{id}/variables

Request parameter:

Parameter Type Description
id int Website ID required

If request is successful, you will receive a response:

[
  {
    "id": 97,
    "name": "uname",
    "type": "string"
  }
]

Get a list of website subscribers

To get a list of website subscribers, send a GET request to:

https://api.sendpulse.com/push/websites/{id}/subscriptions

Request parameters:

Parameter Type Description
id int Website ID  required
limit int Number of records optional
offset int Offset (first record to be displayed)  optional
subscription_date_from string Filter by date the subscribers were added (specify date and time from and to duration of time), set in format YYYY-MM-DD optional
subscription_date_to string Filter by date the subscribers were added (specify date and time from and to duration of time), set in format YYYY-MM-DD optional

When using additional parameters, form URL of the following format:

https://api.sendpulse.com/push/websites/{id}/subscriptions/?limit=10&offset=2

If request is successful, you will receive a response:

[
    {
        "id": 311003743,
        "browser": "Firefox",
        "lang": "en",
        "os": "Linux",
        "country_code": "UA",
        "city": "Dnipro",
        "variables": [],
        "subscription_date": "2018-08-13 14:27:11",
        "status": 1
    },
    {
        "id": 311008277,
        "browser": "Opera",
        "lang": "en",
        "os": "Linux",
        "country_code": "UA",
        "city": "Dnipro",
        "variables": [],
        "subscription_date": "2018-08-13 14:33:51",
        "status": 1
    }
]

Possible push subscrbers' statuses:

Status code Status name
0 Deactivated
1 Active
6 Unsubscribed

Get a number of website subscribers

To get a total number of website subscribers, send a GET request to:

https://api.sendpulse.com/push/websites/{id}/subscriptions/total

Request parameter:

Parameter Type Description
id int Website ID required

If request is successful, you will receive a response:

{
  "total": 2
}

Get an information about a website

To get an information about a website, send a GET request to:

https://api.sendpulse.com/push/websites/info/{id} 

Request parameter:

Parameter Type Description
id int Website ID required

If request is successful, you will receive a response:

{
    "id": 111111,
    "url": "yoursite.com",
    "status": "active",
    "icon": "https://login.sendpulse.com/img/my/push/push-default-icons/icon.png",
    "add_date": "2017-11-09 13:08:37",
    "total_subscribers": 1081,
    "unsubscribed": 30,
    "subscribers_today": 10,
    "active_subscribers": 1051
}

Get a JS code for a website

To get a JS code for a website, send a GET request to:

https://api.sendpulse.com/push/websites/{id}/code 

Request parameter:

Parameter Type Description
id int Website ID required

If request is successful, you will receive a response:

{
    "script_url": "//web.webpushs.com/js/push/00008bf5640047e81be53f4a2891dd36e9_1.js",
    "script_code": "<script charset=\"UTF-8\" src=\"//web.webpushs.com/js/push/00008bf5640047e81be53f4a2891dd36e9_1.js\" async></script>"
}

Activate/deactivate a subscriber

To activate or deactivate a subscriber, send a POST request to:

https://api.sendpulse.com/push/subscriptions/state

Request parameters:

Parameter Type Description
id int Subscriber ID required
state int Subscriber state trigger, 1 – activated, 0 – deactivated required

If request is successful, you will receive a response: 

{
  "result": true
}

Create a new web push campaign

To create a new web push campaign, send a POST request to:

https://api.sendpulse.com/push/tasks

Note that the limit is 1 campaign per 15 minutes for each website.

Use the Automation360 toolset for triggered campaigns.

Request parameters:

Parameter Type Description
title string Title required
website_id int Website ID required
body string Web push notification content required
ttl int Push notification lifetime in seconds, max - 86400 sec (24 hours) required
link string Navigation link; if it’s not specified, the website URL will be used optional
filter_lang string Filter subscribers by language (for example, en) optional
filter_browser string Filter subscribers by the browser; this parameter can take multiple values separated by commas (for example – Chrome, Safari) optional
filter_region string Regional filter, accepts a JSON string with country codes, for instance ["UK"] optional
filter_url  string URL filter, accepts a JSON string of such format {"type":"include","search":"pu"}. type can have three values - 'direct', 'include', 'exclude'. When type equals 'direct' - search is an array of links, in other cases - search will be a regular string for search optional
filter_subscription_date_from string Use YYYY-MM-DD format to specify starting and ending dates of the interval to filter subscribers by the date they were added to the list optional
filter_subscription_date_to string Use YYYY-MM-DD format to specify starting and ending dates of the interval to filter subscribers by the date they were added to the list optional
filter object Segmentation by one of the variables optional
stretch_time int Timespan in which the campaign must be completed. In seconds. If not specified, the default time (5 hours) applies. optional
send_date string Schedule a campaign for a specific date and time: YYYY-MM-DD HH:MM:SS (for example, 2020-09-11 16:19:10) optional
buttons string Insert a button to the campaign, accepts a JSON string, that lists buttons and their values, for example: [{"text":"Button1","link":"link1"}] (maximum two buttons) optional
image string

Insert a larger image into the web-push notification, image parameter must include such a JSON string {"name":"test.jpg","data":"file_content"}, where test.jpg - is the image name, and file_content - Base64_encode(file contents), which can be obtained using PHP by "file_get_contents"

*The image must be in the JPG, PNG or GIF format and less than 200KB

optional

icon string

This parameter is used to insert a custom image of a standard size:
the parameter must include such a JSON string {"name":"icon.jpg","data":"base64_file_content"}, where icon.jpg — is the image name and base64_file_content — contents of the file

optional

Please note: you can add up to 10 filters for 1 campaign.

Example of filter parameter structure: 

{
  "variable_name": "uname",
  "operator": "or",
  "conditions": [
    {
      "condition": "likewith",
      "value": "a"
    },
    {
      "condition": "notequal",
      "value": "b"
    }
  ]
}

Response parameters:

Parameter Type Description
variable_name string Variable name
operator string Connecting operator, only accepts or or and values
conditions array Array of conditions
condition Accepts following values:
equal Completely equal
notequal Completely not equal
greaterthan More than
lessthan Less than
startwith Starts with
endwith Ends with
likewith Contains
notlikewith Does not contain
value Variable value

If request is successful, you will receive a response:

{
  "result": true,
  "id": 1
}

Get statistics on sent campaigns

To get statistics on sent campaigns, send a GET request to:

https://api.sendpulse.com/push/tasks/{id}

Request parameter:

Parameter Type Description
id int Web Push campaign ID required

If request is successful, you will receive a response:

{
   "id":36,
   "message":{
      "title":"s",
      "text":"s",
      "link":"http://aaa.aaa"
   },
   "website":"www.google.com",
   "website_id":53,
   "status":3,
   "send":"21",
   "delivered":14,
   "redirect":13
}

Web Push campaign statuses:

Code Description
0 New campaign
2 In progress
3 Sent
8 Test campaign sent
12 No active recipients
13 Campaign creation in progress — copying subscriptions
15 Campaign awaiting results of A/B testing
16 Canceled by user
30 Archived