Retrieving a list of sent push campaigns

To retrieve a list of sent push campaigns, submit a GET request to:

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

Request parameters:

limit Number of entries
offset Offset (stating the first record to display)

When using additional parameters, the URL formed is of the following format::

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

Display 10 entries starting from the second entry

A sample response when retrieving a list of sent web push campaigns:

 

[
  {
    "id": "121",
    "title": "push title",
    "body": "push text",
    "website_id": "53",
    "send_date": "2015-12-17 14:44:47",
    "status": "13"
  }
]
 

Retrieving the total number of websites

In order to retrieve the total number of websites, a GET request is sent to:

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

A sample response when retrieving the total unmber of websites:

 

{
  "total": 2
}
 

Retrieving a list of websites

To retrieve a list of websites, a GET request is sent to:

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

Request parameters:

limit Number of entries
offset Offset (stating the first record to display)

When using additional parameters, the URL formed is of the following format:

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

A sample response when retrieving a list of websites

 

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

Retrieving a list of variables for a website

In order to retrieve a list of variables for a certain website, submit a GET request to:

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

Request parameters:

{id} Website ID

A sample response:

 

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

Retrieving a list of website subscribers

In order to retrieve a list subscribers for a certain website, submit a GET request to:

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

Request parameters:

{id} Website ID (required)
limit Number of entries
offset Offset (stating the first record to display)

When using additional parameters, the URL formed is of the following format:

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

A sample response when retrieving a list of website subscribers:

 

[
  {
    "id": "1",
    "browser": "Chrome",
    "lang": "en",
    "variables": [],
    "status": "0"
  }
]
 

Retrieving the number of website subscribers

To retrieve the total number of website subscribers, submit a GET request to:

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

Request parameters:

{id} Website ID (required)

A sample response:

{
  "total": 2
}
 

Activating/Deactivating a subscriber

In order to activate or deactivate a subscribers, a POST request is sent to:

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

Request parameters (required):

{id} Subscriber ID
state subscriber state trigger, 1 – activated, 0 – disabled

A sample response:

 

{
  "result": true
}
 

Creating a new Push campaign

To create a new push campaign, submit a POST request to:

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

Required request parameters:

title Title
website_id Website ID
body Web push notification content
ttl Push notification lifetime

Optional request parameters:

link Navigation link; if it’s not specified, the website URL will be used
filter_lang Filter subscribers by language (example en)
filter_browser Filter subscribers by a browser; this parameter can take multiple values separated by commas (example – Chrome,Safari)
filter Segmentation by one of the variables
stretch_time time for which a push campaign is throttled, in seconds. If not set, the default time (5 hours) is applied.

An example of filter parameter structure:

 

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

 

 

where:

variable_name Variable name
operator conecting operator that can take the only values ‘or’ or ‘and’
conditions An array of conditions
condition can take the following values
equal Completely equal
notequal Completely not equal
greaterthan More than
lessthan Less than
startwith Start with
endwith End with
likewith Contains
notlikewith Not contain

A sample response when creating push campaign succesfully:

 

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

Retrieving statistics on sent campaigns

To retrieve statistics on sent campaigns, submit a GET request to

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

Request parameters:

{id} wep push campaign id

A sample response when retrieving statistics on sent web push campaigns:

{
"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" 
}