SendPulse service REST API

Introduction

Email Service

SMTP

Web Push Notifications

Error codes and description

 

Introduction

Our API interface is used to integrate SendPulse’s distribution service capabilities with client’s personal projects.

The API is designed for developers and is accompanied by detailed documentation.

Wrappers for SendPulse API and code samples

 

 

Description

SendPulse’s REST API service works over the HTTP protocol and is essentially a set of methods that are used to perform requests and receive responses for each operation.

All answers come back in the form of JSON structures.

 

 

 

Main URL

All references to API requests in this document include the compulsory basic URL:

https://api.sendpulse.com

 

 

 

 

 

Authorization

The authorization process is only possible when preceded by a private key, which, in future, should be referenced in each request to the API.

The necessary parameters to obtain the key can be found in the private account settings page found on the following URL 

https://login.sendpulse.com/settings in the API tab.

The following parameters are used:

grant_type has to be equal to client_credentials
client_id your ID (API)
client_secret your secret (API)

To get the key you have to send a POST request to:

https://api.sendpulse.com/oauth/access_token

A sample response:The resulting key is valid for 1 hour and does not require additional requests with each operation. At the end of the license period (1 hour), you must send a request to obtain a new key.

{
  "access_token": "tf4Si1LydYpTAPyHXUgjig72jlrd5HpIJL5oigmc",
  "token_type": "Bearer",
  "expires_in": 3600
}

A sample key:

Authorization: Bearer tf4Si1LydYpTAPyHXUgjig72jlrd5HpIJL5oigmc

Email Service

 

 

 

Address Books

With the API you can create address books, edit them, delete them, as well as perform other operations with the available mailing lists.

 

 

 

Creating an address book

To create an address book, a POST request is sent to:

https://api.sendpulse.com/addressbooks

 Request parameter:

bookName book name

If successful, the server returns a response with the ID value of the address book created.

 

 

 

Editing an address book

To edit the address book, a PUT request is sent to:

https://api.sendpulse.com/addressbooks/{id}

Request parameters:

id the ID of the address book
name the new name of the book

If successful, the server returns a response stating result = true

 

 

 

Retrieving a list of address books

To retrieve a list of all of the address books that have been created, along with detailed information on each of them, a GET request is sent to:

https://api.sendpulse.com/addressbooks

Request parameters (optional):

limit the number of records
offset offset (first record to be displayed)

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

https://api.sendpulse.com/addressbooks?limit=10&offset=5

Response parameters:

id Book ID
name/td> Book name
all_email_qty Total number of emails
active_email_qty Number of active emails
inactive_email_qty Number of inactive emails
creationdate Date of creation
status Status code
status_explain Status explanation

A sample response when retrieving the list of address books:

[
{
    "id": "1",
    "name": "My first book",
    "all_email_qty": "1",
    "active_email_qty": "0",
    "inactive_email_qty": "1",
    "creationdate": "2015-04-20 08:52:40",
    "status": "0",
    "status_explain": "Active"
  },
  {
    "id": "2",
    "name": "My second book",
    "all_email_qty": "6",
    "active_email_qty": "0",
    "inactive_email_qty": "6",
    "creationdate": "2015-04-20 09:02:39",
    "status": "0",
    "status_explain": "Active"
  }
]


 

 

Retrieving address book information

To retrieve detailed information regarding a specific address book, a GET request is sent to:

https://api.sendpulse.com/addressbooks/{id}

Request Parameters:

id Book ID
name/td> Book name
all_email_qty Total number of emails
active_email_qty Number of active emails
inactive_email_qty Number of inactive emails
creationdate Date of creation
status Status code
status_explain Status explanation

A sample response when retrieving address book information:

[
{
    "id": "1",
    "name": "My first book",
    "all_email_qty": "1",
    "active_email_qty": "0",
    "inactive_email_qty": "1",
    "creationdate": "2015-04-20 08:52:40",
    "status": "0",
    "status_explain": "Active"
  },
]




Retrieving a list of emails from an address book

To retrieve a list of email addresses from a particular address book, submit a GET request to:

https://api.sendpulse.com/addressbooks/{id}/emails

Request parameters:

id Book ID
limit (optional) Number of entries
offset (optional) offset (stating the first record to display)

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

https://api.sendpulse.com/addressbooks/{id}/emails?limit=10&offset=5

Response parameters:

email Email address
status Status code
status_explain Status explanation
variables An array of variables for this address

A sample response when retrieving the list of address books:

[
  {
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "status": "0",
    "status_explain": "New",
    "variables": [
      {
	"name": "variable name",
	"type": "string",
	"value": "variable value"
      },
      {
	"name": "variable name",
	"type": "string",
	"value": "variable value"
      }
    ]
  },
  {
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "status": "0",
    "status_explain": "New",
    "variables": [
      {
	"name": "variable name",
	"type": "string",
	"value": "variable value"
      },
      {
	"name": "variable name",
	"type": "string",
	"value": "variable value"
      }
    ]
  }
]



 Retrieving a list of vriables from an address book

To retrieve a list of variables from a particular address book, submit a GET request to:

https://api.sendpulse.com/addressbooks/{id}/variables

Request parameters:

id Book ID

At https://sendpulse.com/ru/integrations/api#add-email you can add variables, simply by specifying a list of them in the request. If this variable doesn't exist - it will be created

 

Adding emails to an address book

To add emails to an address book, submit a POST request to:

https://api.sendpulse.com/addressbooks/{id}/emails

Request parameters:

id Book ID
emails A serialized array of emails

An example of an email address array structure

[
  {
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "variables": {
      "variable name": "value",
      "variable name": "value"
    }
  },
  {
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "variables": {
      "variable name": "value",
      "variable name": "value"
    }
  }
]

If successful, the server will return a response stating result = true

 

 

 

Deleting emails from an address book

To delete emails from an address book submit a DELETE request to:

https://api.sendpulse.com/addressbooks

Request parameters:

id Book ID
emails A serialized array of emails

An example of an email address array structure

[
  "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "This email address is being protected from spambots. You need JavaScript enabled to view it."
]

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Retrieving information for specific email address from an address book

Submit a GET request to: 

https://api.sendpulse.com/addressbooks/{id}/emails/{email}

Request parameters:

id Book ID
email Email address information is desired on

Response parameters:

email Email address
abook_id Address book ID
status Status code
status_explain Status explanation
variables An array of variables for this email

A sample response:

{
  "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "abook_id": "34",
  "status": "1",
  "status_explain": "Active",
  "variables": [
    {
      "name": "variable name",
      "type": "string",
      "value": "value"
    },
    {
      "name": "variable name",
      "type": "string",
      "value": "value"
    },
    {
      "name": "variable name",
      "type": "string",
      "value": "value"
    }
  ]
}

 

 

 

Erasing an address book

Submit a DELETE request to:

https://api.sendpulse.com/addressbooks/{id}

Request parameters:

id Book ID

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Calculating the cost of a campaign carried out by an address book

Submit a GET request to:

https://api.sendpulse.com/addressbooks/{id}/cost

Request parameter:

id Book ID

Response parameters:

cur Currency used for calculation
sent_emails_qty Total number of email addresses used
overdraftAllEmailsPrice The price for exceeding the email address limit
addressesDeltaFromBalance The number of email addresses that will be charged from the balance
addressesDeltaFromTariff The number of email addresses that will be charged by the tariff
max_emails_per_task Email address tariff restrictions
result Whether there is enough money (true – enough, false – not enough)

A sample response:

{
  "cur": "USD",
  "sent_emails_qty": 16,
  "overdraftAllEmailsPrice": 0,
  "addressesDeltaFromBalance": 0,
  "addressesDeltaFromTariff": 16,
  "max_emails_per_task": "500",
  "result": true
}




Campaigns

 

Creating a campaign

Submit a POST request to:

https://api.sendpulse.com/campaigns

Request parameters:

sender_name Sender name
sender_email Sender email address
subject Email subject
body The email body, encoded in base64
list_id Address book ID
name Campaign name (an optional parameter)
attachments Attached files, a serialized array in which the key is the name of the attachment, and the value is the content of the attachment (an optional parameter)

A sample response:

{
  "id": "27",
  "status": "0",
  "count": "0",
  "tariff_email_qty": "1",
  "paid_email_qty": "0",
  "overdraft_price": "0",
  "ovedraft_currency": "USD"
}





 Campaign information

Submit a GET request to:

https://api.sendpulse.com/campaigns/{id}

Request parameters:

id Campaign ID

A sample response:

{
  "id": "27",
  "name": "Test campaign",
  "message": {
    "sender_name": "John Doe",
    "sender_email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "subject": "My first campaign",
    "body": "<p>\ \Hi World!<\/p>",
    "list_id": "28",
    "attachments": "file.zip, file2.zip"
  },
  "status": "3",
  "all_email_qty": 9712,
  "tariff_email_qty": "9712",
  "paid_email_qty": "0",
  "overdraft_price": 0,
  "overdraft_currency": "USD"
}




Retrieving the list of campaigns

Submit a GET request to:

https://api.sendpulse.com/campaigns

Request parameters:

limit Number of entries (optional parameter)
offset Offset issue (stating the record to display from)

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

https://api.sendpulse.com/campaigns?limit=10&offset=5

A sample response:

[
  {
    "id": "27",
    "name": "Test campaign",
    "message": {
      "sender_name": "John Doe",
      "sender_email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
      "subject": "My first campaign",
      "body": "<p>\ \Hi World!<\/p>",
      "list_id": "28",
      "attachments": "file.zip, file2.zip"
    },
    "status": "3",
    "all_email_qty": 9712,
    "tariff_email_qty": "9712",
    "paid_email_qty": "0",
    "overdraft_price": 0,
    "overdraft_currency": "USD"
  }
]




Country statistics

Submit a GET request to:

https://api.sendpulse.com/campaigns

Request parameters:

id Campaign ID

Response parameters:

US Country code
34567 Emails opened

A sample response:

{
  "RU": 23,
  "US": 34567
} 

 

 

 

Referrals statistics

Submit a GET request to:

https://api.sendpulse.com/campaigns/{id}/referrals

Request parameters:

id Campaign ID

Response parameters:

link The URL from the email
count Number of clicks

 

A sample response:

 

[
  {
    "link": "http://first_link.com"
    "count": 123454
  },
  {
    "link": "http://second_link.com"
    "count": 5463
  }
] 

 

 

 

Cancelling a campaign

Submit a DELETE request to:

https://api.sendpulse.com/campaigns/{id}

Request parameters:

id Campaign ID

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Senders

Retrieving a list of all of the senders

Submit a GET request to:

https://api.sendpulse.com/senders

 

A sample response:

 

[
  {
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "status": "Active"
  },
  {
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "status": "Active"
  }
]

 

 

 

Adding a sender

Submit a POST request to:

https://api.sendpulse.com/senders

Request parameters:

email Sender’s email address
name Sender’s name

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Deleting a sender

Submit a DELETE request to:

https://api.sendpulse.com/senders

Request parameters:

email Sender’s email address

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Activating a sender

Submit a POST request to:

https://api.sendpulse.com/senders/{email}/code

Request parameters:

code Activation code

 

A sample response (if succeed):

 

{
  "result": true,
  "email": This email address is being protected from spambots. You need JavaScript enabled to view it.
}

 

 

 

Receiving the activation code at the sender’s email address

Submit a GET request to:

https://api.sendpulse.com/senders/{email}/code

 

A sample response:

 

{
  "result": true,
  "email": This email address is being protected from spambots. You need JavaScript enabled to view it.
}

If the request was successful, the sender will receive an email containing the activation code.

 

 

 

Email Address

Retrieve general information for a specific email address

Submit a GET request to:

https://api.sendpulse.com/emails/{email}

 

A sample response:

 

[
  {
    "book_id": "39359",
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "status": "3",
    "variables": [
      {
"name": "variable name",
"type": "string",
"value": "variable value"
      },
      {
"name": "variable name",
"type": "string",
"value": "variable value"
      },
      {
"name": "variable name",
"type": "string",
"value": "variable value"
      }
    ]
  },
  {
    "book_id": "39362",
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "status": "3",
    "variables": [
      {
"name": "variable name",
"type": "string",
"value": "variable value"
      }
    ]
  }
]

 

 

 

Erasing an email address from all address books

Submit a DELETE request to:

https://api.sendpulse.com/emails/{email}

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Retrieving statistics for an email address by campaigns

Submit a GET request to:

https://api.sendpulse.com/emails/{email}/campaigns

 

A sample response:

 

{
  "statistic": {
    "sent": 0,
    "open": 0,
    "link": 0
  },
  "blacklist": false
}

 

 

Blacklist

Viewing the blacklist

Submit a GET request to:

https://api.sendpulse.com/blacklist

 

A sample response:

 

[
  "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "This email address is being protected from spambots. You need JavaScript enabled to view it.",
]

 

 

 

Blacklisting an email address

Submit a POST request to:

https://api.sendpulse.com/blacklist

Request parameters:

email A string containing email addresses separated by commas
comment A comment encoded in base64 (an optional parameter)

 

An example of a string containing email addresses separated by commas:

This email address is being protected from spambots. You need JavaScript enabled to view it.,This email address is being protected from spambots. You need JavaScript enabled to view it.,This email address is being protected from spambots. You need JavaScript enabled to view it.

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Erasing an email address from the blacklist

Submit a DELETE request to:

https://api.sendpulse.com/blacklist

Request parameters:

email A string containing email addresses separated by commas

 

An example of a string containing email addresses separated by commas:

This email address is being protected from spambots. You need JavaScript enabled to view it.,This email address is being protected from spambots. You need JavaScript enabled to view it.,This email address is being protected from spambots. You need JavaScript enabled to view it.

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Balance

Checking the user’s balance

Submit a GET request to:

https://api.sendpulse.com/balance

An optional request parameter: the currency value

When using optional parameter, the URL formed is of the following format:

https://api.sendpulse.com/balance/USD

 

A sample response:

 

{
  "currency": "USD",
  "balance_currency": 0.02
}

 

 

 

SMTP

Sending an email

In order to send an email, submit a POST request to:

https://api.sendpulse.com/smtp/emails

Request parameters:

email a serialized array with email data

Email array parameters:

html The HTML version of the email, encoded in base64
text The text version of the email
subject The email subject
from An array containing the sender’s name and email address
to An array of recipients
bcc An array

 

An example of an email address array structure

 

{
  "html" : "<p>Example text</p>",
  "text" : "Example text",
  "subject" : "Example subject",
  "from" : {
      "name" : "Example name",
      "email" : "This email address is being protected from spambots. You need JavaScript enabled to view it."
  },
  "to" : [
      {
  "name" : "Recipient1 name",
  "email" : "This email address is being protected from spambots. You need JavaScript enabled to view it."
      },
      {
  "name" : "Recipient2 name",
  "email" : "This email address is being protected from spambots. You need JavaScript enabled to view it."
      },
  ],
  "bcc" : [
      {
  "name" : "Recipient1 name",
  "email" : "This email address is being protected from spambots. You need JavaScript enabled to view it."
      },
      {
  "name" : "Recipient2 name",
  "email" : "This email address is being protected from spambots. You need JavaScript enabled to view it."
      },
  ],
    "attachments" {
            "text.txt" => "this is simple txt file"
  }
}

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Retrieving a list of emails

In order to retrieve a list of all emails sent, submit a GET request to:

https://api.sendpulse.com/smtp/emails

Request parameters (optional):

limit Number of entries
offset Sample offset
from Sample start date
to Sample max date
sender Sender
recipient Recipient

 

A sample response:

 

{
  "id": "123123",
  "sender": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "total_size": "1128",
  "sender_ip": "127.0.0.1",
  "smtp_answer_code": "250",
  "smtp_answer_subcode": "0",
  "smtp_answer_data": "Bad recipients",
  "used_ip": "5.104.224.87",
  "recipient": null,
  "subject": "SendPulse :: Email confirmation",
  "send_date": "2013-12-17 10:33:53",
  "tracking": {
    "click": 1,
    "open": 1,
    "link": [
      {
"url": "http://some-url.com",
"browser": "Chrome 29.0.1547.57",
"os": "Linux",
"screen_resolution": "1920x1080",
"ip": "46.149.83.86",
"country": "Ukraine",
"action_date": "2013-09-30 11:27:40"
      }
    ],
    "client_info": [
      {
"browser": "Thunderbird 17.0.8",
"os": "Linux",
"ip": "46.149.83.86",
"country": "Ukraine",
"action_date": "2013-09-30 11:27:49"
      }
    ]
  }
}

 

 

 

Retrieving information for a specific email

In order to retrieve information for a specific email, submit a GET request to:

https://api.sendpulse.com/smtp/emails/{id}

Request parameters:

id Email ID

 

A sample response:

 

{
  "id": "123123",
  "sender": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "total_size": "1128",
  "sender_ip": "127.0.0.1",
  "smtp_answer_code": "250",
  "smtp_answer_subcode": "0",
  "smtp_answer_data": "Bad recipients",
  "used_ip": "5.104.224.87",
  "recipient": null,
  "subject": "SendPulse :: Email confirmation",
  "send_date": "2013-12-17 10:33:53",
  "tracking": {
    "click": 1,
    "open": 1,
    "link": [
      {
"url": "http://some-url.com",
"browser": "Chrome 29.0.1547.57",
"os": "Linux",
"screen_resolution": "1920x1080",
"ip": "46.149.83.86",
"country": "Ukraine",
"action_date": "2013-09-30 11:27:40"
      }
    ],
    "client_info": [
      {
"browser": "Thunderbird 17.0.8",
"os": "Linux",
"ip": "46.149.83.86",
"country": "Ukraine",
"action_date": "2013-09-30 11:27:49"
      }
    ]
  }
}

 

 

 

 

Unsubscribing a recipient

In order to unsubscribe a recipient, submit a POST request to:

https://api.sendpulse.com/smtp/unsubscribe

Request parameters:

emails A serialized email array

 

An example of an email address array structure

 

[
  {
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "comment": "comment1"
  },
  {
    "email": "This email address is being protected from spambots. You need JavaScript enabled to view it.",
    "comment": "comment2"
  }
]

 

 

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Erasing from the unsubscribed list

In order to remove an entry from the unsubscribed list, submit a DELETE request to:

https://api.sendpulse.com/smtp/unsubscribe

Request parameters:

emails A serialized email array

 

An example of an email address array structure:

 

{
  "This email address is being protected from spambots. You need JavaScript enabled to view it.",
  "This email address is being protected from spambots. You need JavaScript enabled to view it."
}

 

 

If the request was successful, you will receive a JSON response stating result = true

 

 

 

Retrieving the sender’s IP address

In order to retrieve the list of sender IP addresses, submit a GET request to:

https://api.sendpulse.com/smtp/ips

 

A sample response:

[
  "127.0.0.1"
]

 

 

 

Retrieving a list of allowed domains

In order to retrieve a list of the allowed domains, submit a GET request to:

https://api.sendpulse.com/smtp/domains

 

A sample response:

 

[
  "@mail.ru"
]

 Retrieving the list of unsubscribed

In order to retrieve bounces, submit a GET request to

https://api.sendpulse.com/smtp/unsubscribe

Request parameters:

day The day you want to get information about. Format: YYYY-MM-DD
limit Number of entries
offset Sample offset

Example: https://api.sendpulse.com/smtp/unsubscribe?limit=10&offset=20 - you will receive 10 entries starting from с 20

You you point the day, the data will be for 1 day

Example of the request with the date: smtp/unsubscribe?date=2016-03-05

Retrieving bounces per 24 hours

In order to retrieve bounces, submit a GET request to

https://api.sendpulse.com/smtp/bounces/day

Request parameters:

day The day you want to get information about. Format: YYYY-MM-DD
limit Number of entries
offset Sample offset

Example: https://api.sendpulse.com/smtp/bounces/day?limit=10&offset=20 - you will receive 10 entries starting from с 20

You can get bounces only for the last 24 hours starting from this moment. Example: today is - 2016-04-28 14:34:00, you will get entries from 2016-04-27 14:34:00 till 2016-04-28 14:34:00

Adding a domain

In order to add a domain, submit a POST request to:

https://api.sendpulse.com/smtp/domains

Request parameters:

email Sender’s email address

If the request was successful, you will receive a JSON response stating result = true

 

 

 

New domain verification

In order to activate and verify a new domain, submit a GET request to:

https://api.sendpulse.com/domains/{email}

If the request was successful, you will receive a JSON response stating result = true

Additionally, the new domain verification code will be sent to the specified email address.

 

 

 

Web Push Notifications

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": "ru",
    "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" 
}

Error codes and description

Error code Description
8 Empty data
10 Empty sender email address
11 Can’t find recipients addresses
13 Empty email message content field
14 Can’t find email address with a specified ID
17 Can’t find email address
19 Email address already exists
20 You are not allowed to use free mail services
21 Can’t find email address on activation
97 Invalid email address type. You are not allowed to use free mail services.
201 Empty address book name
203 This address book name already exists
303 Can’t find email addresses in the address book
400 Can’t find such SMTP user. Please, create SMTP service account.
502 Can’t find email address
602 Can’t find campaign. Probably, it has already been sent.
701 Empty sender name or email address
703 Can’t find address book
704 Can’t find sender
707 Not enough funds on your account balance
711 You should wait for 15 minutes before creating new campaign on the same address book.
720 Empty subject field
721 Empty email message content field
722 Can’t find address book ID
799 Wrong send date. It must be in such format: Y-m-d H:i:s and can not be less than the current date
800 Invalid operation
802 Can’t find campaign
901 Empty sender name field
902 Chosen email address is already used
903 Empty sender email address field
904 Email address is blacklisted
905 You have reached the limit of available sender addresses
906 Email address syntax error
1101 Empty email address field
1003 The specified sender doesn’t exist
1004 Activation code was sent. You should wait for 15 minutes before the next try.
1005 Confirmation sending error
1104 Can’t find activation code

Subcategories

Try SendPulse today for free