Create a Viber Campaign
To send a Viber campaign, send a POST request to the link below
https://api.sendpulse.com/viber |
Request parameters:
task_name | campaign name | ||
message_type | message type: type 2 - promo, type 3 - system |
||
sender_id | active sender name ID, from which you send campaigns; the method for receiving sender_id is described here, to use it you must have registered the sender name in the service settings |
||
message_live_time | message lifetime (seconds), minimum 60s, maximum 86400 seconds (24 hours) | ||
sent_date | sending time. Use now if you need to send the message immediately, or specify the time in the format YYYY-MM-DD HH:MM:SS if you need to schedule it for the future |
||
address_book* | mailing list identifier | ||
recipients* | array of phone numbers in JSON format [180931111111,180931111112, 180931111113] | ||
message* | message text, maximum length 1000 characters | ||
additional | additional parameters | ||
button* | button parameters | ||
text | button text | ||
link | button link | ||
image* | image parameters | ||
link | link to your uploaded image | ||
resend_sms | function of re-sending messages via SMS service | ||
status | true if enabled, false if disabled |
||
sms_text | SMS message text | ||
sms_sender_name | SMS Sender ID |
Note: you can use the address_book
parameter or recipients
to specify a list of recipients, one these parameters is required
You can send the following types of messages:
- System or promo (text only):
message
parameter only; - Promo (text + button + image): parameters:
message
,button
,image
; - Promo (text + button): parameters:
message
,button
; - Promo (image): parameters:
image
.
Please note: when you send a system message ("message_type": 3
), the text in the message
parameter is checked. It must match the text of the approved template. You can add and submit a template for approval in your personal account after registering a sender.
Sample request to send a message of the Text+Button+Image format:
{
"recipients": [
// recipients array
380931111111,
380931111112,
380931111113
],
"address_book": null,
// there are two options avalable: send either an address book ID, or an array of recipients (1000 recipients maximum)
"message": "Margaret, you have been approved for a 50% discount on all items in the "Cosmetics" category"
"message_type": 2,
"message_live_time": 1000,
//seconds (60 seconds minimum, maximum 86400 seconds(24 hours),
"sender_id": 1,
//id of the active user, the campaign will be sent from
"send_date": "now",
// or date in the following format YYYY-MM-DD HH:ii:ss
"additional": {
// additional data
"button": {
//button in the message
"text": "Buy all cosmetics",
//text on the button
"link": "https://sendpulse.com/"
// click through link
},
"image": {
// image in the message
"link": "https://sendpulse.com/images/image.png"
//image link
},
"resend_sms": {
//status indicating that resend option turned on
"status" : true,
// text of the sam messamge
"sms_text" : "Text of the sms message",
// sender name sms
"sms_sender_name" : "sendpulse"
}
}
}
Example of the request to send a message containing only text:
{
"recipients": [
// array of recipients
380931111111,
380931111112,
380931111113
],
"address_book": null,
// There are two options: either send the address book ID, or send the recipients array, 1000 recipients maximum
"message": "Margaret, you have been approved for a 50% discount on all items in the "Cosmetics" category",
// max lenghth is 1000 symbols
"message_type": 2,
"message_live_time": 1000,
//seconds (min 60seconds, max 86400 seconds(24 hours),
"sender_id": 1,
//id of an active sender name
"send_date": "now",
// or date in the following format YYYY-MM-DD HH:ii:ss
"additional": {
"resend_sms": {
//status indicating that re-sending is engaged
"status" : true,
// sms text
"sms_text" : "Text of the sms message",
// sender name sms
"sms_sender_name" : "sendpulse"
}
}
}
Example of a request to send a message containing only an image:
{
"recipients": [
// array of recipients
380931111111,
380931111112,
380931111113
],
"address_book": null,
//
There are two options: either send the address book ID, or send the recipients array, 1000 recipients maximum
"message": null,
// ma
"message_type": 2,
"message_live_time": 1000,
//seconds (min 60s, max 86400s (24 hrs),
"sender_id": 1,
//id of an active sender name
"send_date": "now",
// or date in the following format YYYY-MM-DD HH:ii:ss
"additional": {
// additional data
"image": {
// image in the message
"link": "https://sendpulse.com/images/image.png"
//immage link
},
"resend_sms": {
//status indicating resend option is turned on
"status" : true,
// sms text
"sms_text" : "Text of the sms",
// sms sender name
"sms_sender_name" : "sendpulse"
}
}
}
Example of a request to send a message containing text + button:
{
"recipients":[
// array of recipients
380931111111,
380931111112,
380931111113
],
"address_book":null,
:"either send the address book ID",
"or send the recipients array",
1000 recipients maximum"message":"Margaret, you have been approved for a 50% discount on all items in the ""Cosmetics"" category",
// max lenghth is 1000 symbols"message_type":2,
"message_live_time":1000,
//seconds (min 60 seconds,
max 86400 seconda(24 hours),
"sender_id":1,
"send_date":"now",
:"ii":"ss""additional":{
"button":{
"text":"Buy all cosmetics",
"link":"https://sendpulse.com"
},
"resend_sms":{
"status":true,
"sms_text":"Text of the sms",
"sms_sender_name":"sendpulse"
}
}
}
Example of a response:
[
'result' => true,
'data' => [
'task_id' => 12345,
'task_name' => "My Viber campaign",
'message' => "First Viber campoaign",
'button_text' => "Button",
'button_link' => "https://sendpulse.com",
'image_link' => "https://sendpulse.com/images/image.png",
'address_book_id' => 1234456,
'sender_id' => 123,
'message_type' => "2",
'message_live_time' => 450,
'send_date' => 2017-07-25 14:54:25,
]
];
Editing Viber Campaign
Submit POST request to the link below
https://api.sendpulse.com/viber/update |
Request parameters:
main_task_id | Campaign ID (int) |
task_name | Campaign name |
message | Text of the messageя |
message_type | type 2 — marketing, type 3 — transactional *required parameter |
button_text | Text of the button; if not specified, NULL response will follow |
button_link | Tansfer link; if not specified, NULL response will follow |
image_link | Image location; if not specified, NULL response will follow |
address_book | Mailing list; if not specified, NULL response will follow |
sender_id | Sender ID (at the time of sending) *required parameter find the method of getting the sender id here make sure user has registered sender ids in service settings |
message_live_time | Message lifetime(in seconds) |
send_date | Date of sending |
Retrieving a List of Campaigns
To retrieve a list of campaigns, send a GET request to:
https://api.sendpulse.com/viber/task |
Sample request:
limit | An even number greater than 0 (optional parameter) |
offset | An even number greater or equal 0 (optional parameter) |
Sample response:
id | Entry ID |
name | Campaign ID |
message | Text of the message |
button_text | Text on the button,- if not specified, will return NULL |
button_link | Clickthrough link,- if not specified, will return NULL |
image_link | Image link,- if not specified, will return NULL |
address_book_id | Mailing list ID,- if keyed in manually, will return NULL |
sender_name | Sender name, that was used to send the campaign |
sender_id | Sender ID used in the campaign |
message_live_time | Lifetime of the message (in seconds) |
sent_date | Date that the campaign was sent |
status | Status of the task |
created | Date the campaign was created |
Sample response:
[
'id' => 123,
'name' => "My campaign",
'message' => "First message",
'button_text' => "Button",
'button_link' => "https://sendpulse.com",
'image_link' => "https://sendpulse.com/images/image.png",
'address_book' => 12313,
'sender_name' => "sendPulse",
'sender_id' => 12
'sent_date' => 2017-08-25 14:55:05,
'status' => "send",
'created' => "2017-06-25 12:14:55"
]
Retrieving Statistics on a Campaign
To retrieve statistics on a campaign, send a GET request to:
https://api.sendpulse.com/viber/task/{id} |
Response parameters:
id | Entry ID |
name | Campaign ID |
message | Text of the message |
button_text | Text of the button,- if not specified, will return NULL |
button_link | Clickthrough link,- if not specified, will return NULL |
image_link | Image link,- if not specified, will return NULL |
address_book_id | Mailing list ID,- if keyed in manually, will return NULL |
sender_name | Sender name, that was used to send the campaign |
sender_id | Sender ID used in the campaign |
message_live_time | Lifetime of the message (in seconds) |
send_date | Date that the campaign was sent |
status | Task status |
send | Send |
delivered | Delivered |
read | Read |
redirected | Button clickthrough rate |
undelivered | Not delivered |
errors | Number of errors |
created | Date that the campaign was created |
Sample response, if the campaign exists:
{
"id": 38,
"name": "Viber_Campaign_38",
"message": "Viber message text",
"button_text": "Button",
"button_link": "https://sendpulse.com",
"image_link": null,
"address_book": null,
"sender_name": "infoservice",
"send_date": "2017-06-22 09:51:35",
"status": "send",
"statistic": {
"send": 1,
"delivered": 1,
"read": 0,
"redirected": 0,
"undelivered": 0,
"errors": 0
},
"created": "2017-06-22 09:51:22"
}
Retrieving a List of Sender Names
To retrieve statistics on a campaign, send a GET request to:
https://api.sendpulse.com/viber/senders |
Response parameters:
id | Entry ID |
status | Current status of the name |
name | Name, messages will be received from |
service_type | Type of service |
web_site | Website |
description | Description of the service |
country | Recipients' country |
traffic_type | Type of traffic |
admin_comment | Comment of the admin,- if the comment exists, text will be returned, otherwise, the API will return NULL |
Sample response:
[
{
"id": 1,
"status": "verified",
"name": "myName",
"service_type": "Test service",
"web_site": "https://www.sendpulse.com",
"description": "We are testing the final variant of the message",
"country": "UK",
"traffic_type": "Public information",
"admin_comment": "Your name has been approved, thank you for choosing our service. Sendpulse team"
}
]
Retrieving a Sender Name
To retrieve a name of the sender, send a GET request to:
https://api.sendpulse.com/viber/senders/{id} |
Response parameters:
id | Entry ID |
status | Current status of the name |
name | Name, messages will be received from |
service_type | Type of service |
web_site | Website |
description | Description of the service |
country | Recipients' country |
traffic_type | Type of traffic |
admin_comment | Comment of the admin,- if the comment exists, text will be returned, otherwise, the API will return NULL |
Sample response:
{
"id": 1,
"status": "verified",
"name": "infoservice",
"service_type": "Test service",
"web_site": "https://www.sendpulse.com",
"description": "We are testing the final variant of the message",
"country": "UK",
"traffic_type": "Public information",
"admin_comment": "Your name has been approved, thank you for choosing our service. Sendpulse team"
}
Retreiving a List of Recipients of a Viber Campaign
To retrieve a sender name, send a GET request to:
https://api.sendpulse.com/viber/task/{id}/recipients |
Response parameters:
task_id | Campaign ID |
recipients | Recipients array |
phone | Recipient's phone number |
address_book_id | Mailing list ID containing the phone number, in the case of manial entry the API will return NULL |
status | Status of the message sent to this number (send; delivered; delivered and opened; delivered and read; delivered; read and a clicktrough followed; not delivered; error) |
sent_date | Sending time |
price | Price for the message |
currency | Actual user's currency and price for the message are displayed in this currency |
last_update | Last statistics update |
Sample response:
{
"task_id": 44,
"recipients": [
{
"phone": 380934760182,
"address_book_id": 850852,
"status": "send",
"sent_date": "2017-06-23 08:54:01",
"price": 0.74,
"currency": "RUR",
"last_update": "2017-06-23 08:53:38"
}
]
}
Sign up with
Sign in with Facebook Sign in with Google