Viber API
Create a Viber campaign
To create a Viber campaign, send a POST request to:
| https://api.sendpulse.com/viber |
Request parameters:
| Parameter | Type | Description | ||||
| task_name | string | Campaign name. If omitted or empty, the service generates the name automatically: "Viber campaign for the personal list on" | optional | |||
| message_type* | int | Message type: 2 - promo, 3 - system |
required | |||
| sender_id | int |
Active sender name ID, from which you send campaigns. You can get in Get a list of sender names method. To use it you must have registered the sender name in the Settings > Senders and Viber templates. |
required | |||
| message_live_time | int | Message lifetime (seconds), minimum 10s, maximum 86400 seconds (24 hours) | required | |||
| send_date | string | 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 |
required | |||
| address_book* | int | Mailing list ID | required | |||
| recipients* | array | List of phone numbers in [180931111111,180931111112, 180931111113] format. For system message you can include only one phone number. |
required | |||
| message* | string | Message text (maximum length is 1000 characters) | required | |||
| stretch_time | int | Gradual message sending. You can set values from 0 to 5 hours, and your campaign will be sent to all recipients in smaller parts within the specified time frame. | optional | |||
| template_id* | int |
ID of the approved system template. You can find it in the list of registered templates in your account. You can also get it using the Get a list of message templates method. To use it you must have registered template in the Settings > Senders and Viber templates > Message templates. |
required | |||
| variables* | object | Variables included in the template, in the following format: {"variable_name": "value"}. Each value can contain up to 125 characters and must not include links. |
required | |||
| emulate | boolean | Test mode. The request is fully validated, including the template, variables, sender, and other parameters, but the message is not sent and no funds are charged. The response returns a test task_id: 12345. |
optional | |||
| ab_test | object | A/B test settings. With this object, the request creates an A/B test instead of a regular campaign. The main request parameters make up variant A, and variants holds variant B. Applicable only to a promo campaign ("message_type": 2) sent to one mailing list (address_book) with at least 20 valid recipients, without segmentation or gradual sending (stretch_time). |
optional | |||
| tested_field | int | What the test compares: 1 — text, 2 — image, 3 — button |
required | |||
| criterion | int | What decides the winner: 1 — the share of clicks, 2 — the share of reads. SendPulse counts both shares among delivered messages. If the shares are equal, variant A wins. |
required | |||
| test_percent | int | Share of recipients in the test group, from 20 to 80. Variants A and B split the test group equally, and the rest of the recipients get the winner. For example, with 40, variants A and B each go to about 20% of the mailing list, and the winner goes to the remaining 60%. |
required | |||
| winner_mode | int | Who chooses the winner: 1 — SendPulse, automatically after winner_delay_minutes; 2 — you, with the Choose the winner of an A/B test method or in your account |
required | |||
| winner_delay_minutes | int | Time from the test start to the automatic winner choice, in minutes: from 60 (1 hour) to 44580 (30 days 23 hours). Required if "winner_mode": 1; ignored in manual mode. |
optional | |||
| variants | array | Variant B as an array of one object. Include only the tested field, and make its value differ from variant A. Use message (string, up to 1,000 characters) for the text, image.link for the image, or button.text and button.link for the button. SendPulse validates variant B by the same rules as variant A. |
required | |||
| additional | object | Additional parameters for promo message: | optional | |||
| button* | Button parameters: | |||||
| text | string | Button text | optional | |||
| link | string | Button link | optional | |||
| image* | Image parameters: | |||||
| link | string | Link to your uploaded image | optional | |||
| resend_sms | Function of re-sending messages via SMS service: | |||||
| status | boolean | true if enabled, false if disabled |
optional | |||
| sms_text | string | SMS message text | optional | |||
| sms_sender_name | string | SMS Sender ID | optional | |||
You can use either address_book, or recipients parameter to specify a list of recipients, one of these parameters is required.
You can send only the following types of messages:
- System (text only):
message,template_id,variablesparameters; - Promo (text only):
messageparameter only; - Promo (text + button + image):
message,button,imageparameters; - Promo (text + button):
message,buttonparameters; - Promo (image):
imageparameter.
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.
Starting October 1, 2026, the provider accepts transactional Viber messages only as registered templates. After this date, sending message text in message parameter with message_type: 3 will no longer work. Until then, both methods are supported.
Request example to send system message:
{
"sender_id": 327,
"message_type": 3,
"template_id": 531,
"variables": { "name": "John", "code": "1234" },
"recipients": [380931111111],
"message_live_time": 3600,
"send_date": "now"
}
Request example 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":{
"button":{
"text":"Buy all cosmetics",
"link":"https://sendpulse.com/"
},
"image":{
"link":"https://sendpulse.com/images/image.png"
},
"resend_sms":{
"status":true,
"sms_text":"Text of the sms message",
"sms_sender_name":"sendpulse"
}
}
}
Request example 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"
}
}
}
Request example 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,
"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"
//image 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"
}
}
}
Request example 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,
"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",
"additional":{
"button":{
"text":"Buy all cosmetics",
"link":"https://sendpulse.com"
},
"resend_sms":{
"status":true,
"sms_text":"Text of the sms",
"sms_sender_name":"sendpulse"
}
}
}
Request example to send gradually:
{
"recipients":[
380683850429
],
"message":"Test",
"message_type":2,
"message_live_time":1000,
"sender_id":4647,
"send_date":"now",
"stretch_time":1
}
Request example to create an A/B test:
{
"task_name": "Black Friday A/B",
"message_type": 2,
"sender_id": 4647,
"address_book": 1488435,
"message_live_time": 3600,
"send_date": "now",
"message": "Black Friday: -50% on all cosmetics today only",
"additional": {
"button": {
"text": "Shop now",
"link": "https://sendpulse.com/"
}
},
"ab_test": {
"tested_field": 1,
"criterion": 1,
"test_percent": 40,
"winner_mode": 1,
"winner_delay_minutes": 120,
"variants": [
{ "message": "Only today: half price on all cosmetics" }
]
}
}
In this example, the test compares two message texts. SendPulse chooses the winner by the share of clicks 2 hours after the test starts.
To test an image or a button, use one of these forms for variant B:
"variants": [{ "image": { "link": "https://sendpulse.com/images/image-b.png" } }]
"variants": [{ "button": { "text": "Get -50%", "link": "https://sendpulse.com/" } }]
The response is the same as for a regular campaign, and its task_id is the ID of the variant A campaign. To get the test report using this ID, use the Get an A/B test report by campaign method.
When you create a test, SendPulse charges your balance for the whole mailing list at once.
The test starts once the campaign passes moderation. If you schedule the campaign, the test starts at the time set in send_date.
Variant B and the final campaign, which sends the winner to the rest of the recipients, are separate campaigns. Variant B waits for the test to start, and the final campaign waits for the winner.
While these campaigns wait, Get a list of campaigns returns them with an empty status. Get statistics on a campaign returns "status": null for them.
With "emulate": true, SendPulse validates the ab_test object but doesn't create an A/B test or check the minimum of 20 recipients.
If request is successful, you will receive a response:
{
"result": true,
"data": {
"address_book_id": null,
"button_link": null,
"button_text": null,
"image_link": null,
"message": "Margaret, you have been approved for a 50% discount on all items in the "Cosmetics" category",
"message_live_time": "1000",
"message_type": 3,
"resend_sms": 0,
"send_date": "2026-03-26 12:40:05",
"sender_id": 4501,
"sms_sender_name": null,
"sms_text": null,
"task_id": 90241,
"task_name": "Viber campaign for the personal list on 2026-03-26 12:40"
}
}
If the request fails, you will receive the following response:
{
"message": "3085",
"error_code": 422
}
Where message is the numeric code indicating the reason for the error. See the table below for transactional error codes:
| Error code | Description |
| 3084 | The template has not been approved yet |
| 3085 | Not all template variables are filled in |
| 3086 | Only one phone number is allowed for a transactional message |
| 3087 | The template belongs to a different sender |
| 3088 | The variable value exceeds 125 characters or contains a link |
| 3091 | template_id is empty or invalid |
| 3093 | message cannot be sent together with a template |
If the A/B test settings are invalid, the API returns HTTP status 422 and the error text in message. For example, an invalid test_percent value returns the following response:
{
"message": "A/B test group must be from 20% to 80% of recipients",
"error_code": 422
}
The API can return the following A/B test errors:
| Error text | What to do |
A/B test settings are invalid |
Make sure ab_test has tested_field, criterion, test_percent, winner_mode, and variants with valid values. |
A/B test group must be from 20% to 80% of recipients |
Set test_percent to a value from 20 to 80. |
A/B test winner delay must be from 1 hour to 30 days 23 hours |
Set winner_delay_minutes to a value from 60 to 44580. |
A/B test is not available for transactional messages |
Send a promo campaign: "message_type": 2. |
A/B test is available only for a single address book |
Specify one mailing list ID in address_book instead of recipients. |
A/B test requires at least 20 recipients |
Use a mailing list with at least 20 valid recipients. |
A/B test variant is missing or does not differ in the tested field |
In variants, include variant B with the tested field, and make its value differ from variant A. |
Gradual sending is not available for an A/B test |
Remove stretch_time or set it to 0. |
This element cannot be tested in this type of campaign: a carousel tests the text or the cards, a survey tests the question or the answers, a message tests the text, image or button |
Set tested_field to 1, 2, or 3. |
This criterion is not available for this campaign: a survey is decided by votes or reads, other campaigns by clicks or reads |
Set criterion to 1 or 2. |
A/B test is not available for a segmented list |
Send the campaign to a mailing list without segmentation. |
If a field of variant B is invalid, the API returns the same error as for variant A, for example, for a text longer than 1,000 characters or an invalid button link.
Get a list of campaigns
To get a list of campaigns, send a GET request to:
| https://api.sendpulse.com/viber/task |
Request parameters:
| Parameter | Type | Description | |
| limit | int | Number of records | optional |
| offset | int | Offset (first record to be displayed) | optional |
If request is successful, you will receive a response:
[
{
"id": 9380939,
"name": "Viber campaign for the personal list on 2026-03-26 15:02",
"message": "Jane, you have been approved for a 50% discount on all items in the "Cosmetics" category",
"button_text": null,
"button_link": null,
"image_link": null,
"address_book": null,
"sender_name": "YAMAMAY",
"sender_id": 4495,
"message_live_time": 1000,
"send_date": "2026-03-29 10:00:00",
"status": "moderation",
"created": "2026-03-26 12:50:02"
},
{
"id": 9380926,
"name": "Viber campaign for the personal list on 2026-03-26 14:48",
"message": "Margaret, you have been approved for a 50% discount on all items in the "Cosmetics" category",
"button_text": null,
"button_link": null,
"image_link": null,
"address_book": 0,
"sender_name": "YAMAMAY",
"sender_id": 4495,
"message_live_time": 1000,
"send_date": "2026-03-29 10:00:00",
"status": null,
"created": "2026-03-26 12:48:23"
}
]
Response parameters:
| Parameter | Type | Description |
| id | int | Campaign ID |
| name | string | Campaign name |
| message | string | Message text |
| button_text | string | Text on the button,- if not specified, will return null |
| button_link | string | Clickthrough link,- if not specified, will return null |
| image_link | string | Image link,- if not specified, will return null |
| address_book_id | int | Mailing list ID,- if keyed in manually, will return null |
| sender_name | string | Sender name, that was used to send the campaign |
| sender_id | int | Sender ID |
| message_live_time | int | Lifetime of the message (in seconds) |
| send_date | string | Date that the campaign was sent |
| status | string | Status of the task |
| created | string | Date the campaign was created |
Get statistics on a campaign
To get statistics on a campaign, send a GET request to:
| https://api.sendpulse.com/viber/task/{id} |
Request parameters:
| Parameter | Type | Description | |
| id | int | Campaign ID | required |
If request is successful, you will receive a response:
{
"id": 19864149,
"name": "Viber campaign by book",
"message": "My viber message",
"button_text": null,
"button_link": null,
"image_link": null,
"address_book_ids": [
1488435
],
"sender_name": "my_sender",
"sender_id": 4647,
"message_live_time": 86400,
"send_date": "2023-12-18 14:40:34",
"status": "sent",
"created": "2023-12-18 14:40:34",
"stretch_time": 0,
"resend_sms": true,
"resend_sms_status": 2,
"statistic": {
"sent": 2,
"delivered": 1,
"read": 1,
"redirected": 0,
"undelivered": 1,
"errors": 0
}
}
Response parameters:
| Parameter | Type | Description | |||||||||||||||||
| id | int | Campaign ID | |||||||||||||||||
| name | string | Campaign name | |||||||||||||||||
| message | string | Campaign message | |||||||||||||||||
| button_text | string | Text of the button,- if not specified, will return null |
|||||||||||||||||
| button_link | string | Link on the button,- if not specified, will return null |
|||||||||||||||||
| image_link | string | Image link,- if not specified, will return null |
|||||||||||||||||
| address_book_ids | int | Array of address book identifiers used to create the campaign, - if keyed in manually, will return null |
|||||||||||||||||
| sender_name | string | Sender name | |||||||||||||||||
| sender_id | int | Sender identifier | |||||||||||||||||
| message_live_time | int | Message lifetime (in seconds) | |||||||||||||||||
| send_date | string | Campaign sending time | |||||||||||||||||
| status | string | Campaign status | |||||||||||||||||
| created | string | Campaign creation time | |||||||||||||||||
| stretch_time | int | Campaign sending duration | |||||||||||||||||
| resend_sms | boolean | Marker indicating whether sending through SMS is available | |||||||||||||||||
| resend_sms_status | int | SMS send status,- if not specified, will return null
|
|||||||||||||||||
| statistics | object | Contains campaign statistics information | |||||||||||||||||
| sent | int | Number of sent messages | |||||||||||||||||
| delivered | int | Number of delivered messages | |||||||||||||||||
| read | int | Number of read messages | |||||||||||||||||
| redirected | int | Button clickthrough rate | |||||||||||||||||
| undelivered | int | Number of undelivered messages | |||||||||||||||||
| errors | int | Number of not sent messages due to technical errors | |||||||||||||||||
Get a list of sender names
To get a list of sender names, send a GET request to:
| https://api.sendpulse.com/viber/senders |
If request is successful, you will receive a 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"
}
]
Response parameters:
| Parameter | Type | Description |
| id | int | Sender ID |
| status | string | Current sender status |
| name | string | Sender name |
| service_type | string | Type of service |
| web_site | string | Website |
| description | string | Description of the service |
| country | string | Recipients' country |
| traffic_type | string | Type of traffic |
| admin_comment | string | Comment of the admin,- if the comment exists, text will be returned, otherwise, the API will return null |
Get a sender name
To get a sender name, send a GET request to:
| https://api.sendpulse.com/viber/senders/{id} |
Request parameter:
| Parameter | Type | Description | |
| id | int | Sender ID | required |
If request is successful, you will receive a 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"
}
Response parameters:
| Parameter | Type | Description |
| id | int | Sender ID |
| status | string | Current sender status |
| name | string | Sender name |
| service_type | string | Type of service |
| web_site | string | Website |
| description | string | Description of the service |
| country | string | Recipients' country |
| traffic_type | string | Type of traffic |
| admin_comment | string | Comment of the admin,- if the comment exists, text will be returned, otherwise, the API will return null |
Get a list of message templates
To get a list of message templates, send a GET request to:
| https://api.sendpulse.com/v2/viber-service/user-templates/list |
Request parameter:
| Parameter | Type | Description | |
| sender_id | int | Sender ID to filter templates by | optional |
If the request is successful, the response includes all templates in your account, except deleted ones, sorted from newest to oldest:
{
"data": [
{
"id": 1532,
"name": "Order shipped",
"text": "Your order {{order}} has been shipped",
"status": 2,
"status_name": "verified",
"sender_id": 4647,
"sender_name": "MyShop",
"template_type": 2,
"language": "en",
"created_at": "2026-10-01 10:00:00",
"updated_at": "2026-10-02 12:00:00"
}
]
}
Response parameters:
| Parameter | Type | Description | ||
| data | array | List of templates: | ||
| id | int | Template ID. To send a system message using this template, specify the ID in the template_id parameter of the Create a Viber campaign method. |
||
| name | string | Template name | ||
| text | string | Template text. Variables in the text use the {{variable_name}} format. |
||
| status | int |
Template status:
|
||
| status_name | string | Template status name, for example, verified |
||
| sender_id | int | Sender ID | ||
| sender_name | string | Sender name | ||
| template_type | int |
Template type:
|
||
| language | string | Template language code, for example, en |
||
| created_at | string | Date and time the template was created | ||
| updated_at | string | Date and time the template was last updated | ||
If you specify a sender_id value that isn't a positive integer, the API returns an error with HTTP status 422 and error code 3101. The error text is in your account language.
You can send a system message only with a verified transactional template: "status": 2 and "template_type": 2. The template must belong to the sender name you send the message from.
Get a list of Viber campaign recipients
To get a list of Viber campaign recipients, send a GET request to:
| https://api.sendpulse.com/viber/task/{id}/recipients |
Request parameter:
| Parameter | Type | Description | |
| id | int | Campaign ID | required |
If request is successful, you will receive a response:
{
"task_id": 44,
"recipients": [
{
"phone": 380934760182,
"address_book_id": 850852,
"status": "send",
"send_date": "2023-06-23 08:54:01",
"price": 0.74,
"currency": "USD",
"last_update": "2023-06-23 08:53:38"
}
]
}
Response parameters:
| Parameter | Type | Description | ||
| task_id | int | Campaign ID | ||
| recipients | array | List of recipients: | ||
| phone | int | Recipient's phone number | ||
| address_book_id | int | Mailing list ID containing the phone number, in the case of manual entry the API will return null |
||
| status | string | Status of the message sent to this number (send; delivered; delivered and opened; delivered and read; delivered; read and a clickthrough followed; not delivered; error) | ||
| send_date | string | Sending time | ||
| price | float | Price for the message | ||
| currency | string | Actual user's currency and price for the message are displayed in this currency | ||
| last_update | string | Last statistics update | ||
Get an A/B test report
To get an A/B test report, send a GET request to:
| https://api.sendpulse.com/v2/viber-service/ab-tests/{id} |
Request parameter:
| Parameter | Type | Description | |
| id | int | A/B test ID. You can get it in the id field of the Get an A/B test report by campaign response. |
required |
If the request is successful, you will receive a response:
{
"data": {
"id": 15,
"status": 2,
"tested_field": 1,
"criterion": 2,
"test_percent": 40,
"winner_mode": 1,
"winner_delay_minutes": 120,
"created_at": "2026-10-27 09:00:00",
"test_started_at": "2026-10-27 09:05:00",
"winner_pick_at": "2026-10-27 11:05:00",
"winner": "B",
"winner_picked_at": "2026-10-27 11:05:30",
"currency": "USD",
"refunded": false,
"campaigns": [
{"variant": "A", "task_id": 1001, "status": 3, "recipients": 200, "cost": 2.5, "currency": "USD", "delivered": 190, "opened": 120, "redirected": 30, "undelivered": 10},
{"variant": "B", "task_id": 1002, "status": 3, "recipients": 200, "cost": 2.5, "currency": "USD", "delivered": 195, "opened": 140, "redirected": 41, "undelivered": 5},
{"variant": "final", "task_id": 1003, "status": 2, "recipients": 600, "cost": 7.5, "currency": "USD", "delivered": 0, "opened": 0, "redirected": 0, "undelivered": 0}
],
"hourly": [
{"hour_at": "2026-10-27 10:00:00", "variant": "A", "delivered": 180, "opened": 90, "redirected": 20},
{"hour_at": "2026-10-27 10:00:00", "variant": "B", "delivered": 185, "opened": 110, "redirected": 33}
]
}
}
Response parameters:
| Parameter | Type | Description | ||
| id | int | A/B test ID | ||
| status | int | Test status: 0 — active: waiting for the start or running; 2 — completed: SendPulse has sent the winner; 3 — canceled; 4 — failed: the automatic winner choice failed, and our support team is handling it |
||
| tested_field | int | What the test compares: 1 — text, 2 — image, 3 — button. Tests created in your account can also have 4 — carousel cards or 5 — survey answers. |
||
| criterion | int | What decides the winner: 1 — clicks, 2 — reads. Survey tests created in your account can also have 3 — votes. |
||
| test_percent | int | Share of recipients in the test group, in percent | ||
| winner_mode | int | Who chooses the winner: 1 — SendPulse, automatically; 2 — you |
||
| winner_delay_minutes | int | Time from the test start to the automatic winner choice, in minutes; null in manual mode |
||
| created_at | string | Date and time the test was created | ||
| test_started_at | string | Date and time the test started; null until the test starts |
||
| winner_pick_at | string | Scheduled date and time of the automatic winner choice. In manual mode, it's null: the test waits for your choice with no deadline. |
||
| winner | string | Winning variant: A or B; null until the winner is chosen |
||
| winner_picked_at | string | Date and time the winner was chosen; null until then |
||
| currency | string | Currency of the cost | ||
| refunded | boolean | true if the test was canceled and SendPulse refunded its full cost to your balance |
||
| campaigns | array | Campaigns of the test, one item per campaign: | ||
| variant | string | Campaign variant: A, B, or final. The final campaign sends the winner to the rest of the recipients. |
||
| task_id | int | Campaign ID | ||
| status | int | Campaign status: 1 — under moderation, 2 — sending, 3 — sent, 5 — blocked, 13 — copying phone numbers, 14 — queued for sending, 16 — canceled, 90 — waiting for the A/B test: variant B until the test starts, the final campaign until the winner is chosen |
||
| recipients | int | Number of recipients | ||
| cost | float | Campaign cost. Until SendPulse splits the recipients between the campaigns, variant A shows the whole cost. | ||
| currency | string | Currency of the cost | ||
| delivered | int | Number of delivered messages | ||
| opened | int | Number of read messages | ||
| redirected | int | Number of button clicks | ||
| voted | int | Number of recipients who voted; only in survey tests | ||
| undelivered | int | Number of messages that weren't delivered, including errors and messages over the limit | ||
| hourly | array | Cumulative counters of variants A and B at the start of every hour, for a chart. Each point has the hour_at, variant, delivered, opened, and redirected fields, plus voted in survey tests. |
||
SendPulse adds a point to hourly every hour until the winner is chosen. In manual mode, if you don't choose the winner, the points stop 30 days 23 hours after the test starts.
All dates are in UTC, in the YYYY-MM-DD HH:MM:SS format.
The winner is the variant with the higher share of clicks, reads, or votes among delivered messages, depending on criterion. If the shares are equal, variant A wins.
If the request fails, you will receive a response with HTTP status 400:
{
"message": "A/B test not found",
"data": null,
"error_code": 3112,
"error_text": "..."
}
message is always in English, and error_text is in your account language. Error code 3112 means that the A/B test isn't found or belongs to another user.
Get an A/B test report by campaign
To get an A/B test report by a campaign ID, send a GET request to:
| https://api.sendpulse.com/v2/viber-service/ab-tests/by-task/{taskId} |
Request parameter:
| Parameter | Type | Description | |
| taskId | int | ID of any campaign of the test: variant A, variant B, or the final campaign, such as the task_id that the Create a Viber campaign method returns. |
required |
The response and the errors are the same as in the Get an A/B test report method.
Choose the winner of an A/B test
To choose the winner of an A/B test in manual mode, send a POST request to:
| https://api.sendpulse.com/v2/viber-service/ab-tests/{id}/winner |
You can choose the winner only for a test in manual mode ("winner_mode": 2) that has started and is still running ("status": 0). To check the mode and the status, use the Get an A/B test report method.
After you choose the winner, SendPulse sends it to the rest of the recipients right away. You can't undo this action.
Request parameters:
| Parameter | Type | Description | |
| id | int | A/B test ID | required |
| variant | string | Winning variant: A or B, case-insensitive |
required |
Request example:
{ "variant": "B" }
If the request is successful, you will receive a response:
{ "data": { "result": true } }
If the request fails, you will receive a response with HTTP status 400 and one of the following error codes:
| Error code | Description |
| 3112 | The A/B test isn't found or belongs to another user |
| 3113 | You can't choose the winner of this A/B test now: the test is in automatic mode, hasn't started yet, or has already finished |
| 3118 | The variant is unknown: specify A or B |
Get a list of contacts in the blacklist
To get a list of contacts in the blacklist, send a GET request to:
| https://api.sendpulse.com/v2/viber-service/phone-exception |
Request parameter:
| Parameter | Type | Description | |
| limit | int | Number of records | optional |
| offset | int | Offset (first record to be displayed) | optional |
If request is successful, you will receive a response:
{
"data": {
"list": [
{
"id": 164,
"user_id": 7046460,
"phone": 73832370050,
"description": "",
"add_date": "2021-11-05 13:34:03"
},
{
"id": 165,
"user_id": 7046460,
"phone": 73912050915,
"description": "",
"add_date": "2021-11-05 13:34:03"
}
],
"total": 29
}
}
Add phone number to the blacklist
To add a phone number to the blacklist, send a POST request to:
| https://api.sendpulse.com/v2/viber-service/phone-exception |
Request parameter:
| Parameter | Type | Description | |
| phones | array | List of the phone numbers, for example ["380977217975", "380977217977", "380977217978"] | required |
| description | string | Description of the reason for adding a number to the blacklist | optional |
If request is successful, you will receive a response:
{
"result": true,
"counters": {
"added": 7,
"exists": 0
}
}
Remove a phone number from the blacklist
To remove a phone number from the blacklist, send a DELETE request to:
| https://api.sendpulse.com/v2/viber-service/phone-exception |
Request parameter:
| Parameter | Type | Description | |
| phones | array | List of the phone numbers, for example ["380977217975", "380977217977", "380977217978"] | required |
If request is successful, you will receive a response:
{
"result": true,
"deleted": 7
}
o