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_id ID of the campaign (int)
task_name campaign name
message text of the message
message_type type 2 — marketing, type 3 — transactional
*required parameter
button_text text on the button; if not specified, NULL response will follow
button_link transfer link; if not specified, NULL response will follow
image_link image location; if not specified, NULL response will follow
address_book address book; 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(seconds)
send_date date of sending

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 the 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 the request to send a message containing text + button

{
    "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 60 seconds, max 86400 seconda(24 hours), "sender_id": 1, //id of an active sender name "send_date": "now", // or date in the 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 }, "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 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,
    ]
];
 

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 address book name,- 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 (seconds)
send_date date 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
                'send_date' => 2017-08-25 14:55:05,
                'status' => "sent",
                '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 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 address book name,- 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 (seconds)
send_date date the campaign was sent
status task status
sent sent
delivered delivered
read read
redirected number button clickthrough rate
undelivered not delivered
errors number of errors
created date 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": "sent",
        "statistic": {
            "sent": 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, 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, 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 ID of the address book containing the phone number, in case manuall entry returns NULL
status status of the message sent to this number (sent; 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" 
        }
    ]
}