Viber#
The following Viber messages are supported:
text only;
image only;
text + button to follow the link;
text + image + button to follow the link.
Request to Send Viber Messages#
Request Examples#
To generate a test request with your parameters, please
open the request generator.
1{
2 "login":"YOUR_LOGIN",
3 "password":"YOUR_PASSWORD",
4 "useTimeDiff":false,
5 "id":"8770100",
6 "scheduleInfo":
7 {
8 "timeBegin":"10:00",
9 "timeEnd":"20:00",
10 "weekdaysSchedule":"12345"
11 },
12 "destAddr":"Subscriber's_Number",
13 "message":
14 {
15 "type":"VIBER",
16 "data":
17 {
18 "instantContent":
19 {
20 "type":"TEXT",
21 "data":
22 {
23 "text":"VIBERMESS"
24 }
25 },
26 "serviceNumber":"SENDER'S_NAME",
27 "ttl":1
28 }
29 }
30}
1{
2 "login":"YOUR_LOGIN",
3 "password":"YOUR_PASSWORD",
4 "id":"8770100",
5 "scheduleInfo":
6 {
7 "timeBegin":"10:00",
8 "timeEnd":"20:00",
9 "weekdaysSchedule":"12345"
10 },
11 "destAddr":"Subscriber's_Number",
12 "message":
13 {
14 "type":"VIBER",
15 "data":
16 {
17 "instantContent":
18 {
19 "type":"IMAGE_URL",
20 "data":
21 {
22 "imageURL":"https://example.ru/image"
23 }
24 },
25 "serviceNumber":"SENDER'S_NAME",
26 "ttl":1
27 }
28 }
29}
1{
2 "login":"YOUR_LOGIN",
3 "password":"YOUR_PASSWORD",
4 "useTimeDiff":false,
5 "id":"8770100",
6 "scheduleInfo":
7 {
8 "timeBegin":"10:00",
9 "timeEnd":"20:00",
10 "weekdaysSchedule":"12345"
11 },
12 "destAddr":"Subscriber's_Number",
13 "message":
14 {
15 "type":"VIBER",
16 "data":
17 {
18 "instantContent":
19 {
20 "type":"BUTTON",
21 "data":
22 {
23 "text":"VIBERMESS",
24 "imageURL":"https://example.ru/image",
25 "caption":"GO_TO",
26 "action":"https:// example.ru/image"
27 }
28 },
29 "serviceNumber":"SENDER'S_NAME",
30 "ttl":1
31 }
32 }
33}
Parameters#
Parameter |
Required |
Data type |
Description |
|---|---|---|---|
login |
yes |
string |
Partner’s name. |
password |
yes |
string |
Partner’s password for sending messages. |
useTimeDiff |
no |
boolean |
Taking into account the time zone when starting messaging. More details
If
If
Default value: |
id |
no |
string |
Unique identifier on the Partner’s side. More detailsThis parameter is necessary for controlling repeated submissions and duplication (the control service is activated separately). The Partner can call the Service Provider (request to send a message) multiple times with the same ID. In this case, the message will be sent to the subscriber only once (on the first request). In response to the requests, the Service Provider will return the same message identifier in the Service Provider's system to the Partner (the same as for the first request). The Service Provider optionally returns this identifier to the Partner in the message delivery report if it is available. |
shortenLinks |
no |
boolean |
Parameter controls the automatic shortening of long links in the message. More detailsPossible values are:
If the parameter is not included in the request, but the service is available to the Partner, the links will be shortened by default. The ability to use this service is discussed and configured in advance by the Service Provider. For more details: Link Shortening Service. |
scheduleInfo |
no |
object |
Messaging schedule. More detailsIf it is not specified, it is sent immediately upon receipt of the request. |
scheduleInfo/
timeBegin
|
no |
string |
Start time. More details
Example: |
scheduleInfo/
timeEnd
|
no |
string |
End time. More details
Example: |
scheduleInfo/
weekdaysSchedule
|
no |
string |
Messaging days. More details
Specified by numbers from If there are no restrictions on days of the week, this parameter can be empty or not delivered in the request. |
scheduleInfo/
deadline
|
no |
string |
End date of the messaging. More details
Example: |
destAddr |
yes |
string |
Subscriber’s phone number. More detailsIt contains the country code, operator code and phone number.
For the Russian Federation, the code can be
Examples: |
message |
yes |
object |
Parameters of a message being sent. |
message/type |
yes |
enum |
Message type. More details
The value of |
message/data |
yes |
object |
Parameters of the data being sent. |
message/data/
instantContent
|
yes |
object |
Parameters of the Viber message being sent (images, buttons). |
instantContent/
type
|
yes |
enum |
Type of a message parameter. More detailsPossible values are:
Important For business accounts that support the functionality of Viber
sessions, messages with the type |
instantContent/
data
|
yes |
object |
Parameters of the data being sent when selecting the More detailsPossible values are:
|
instantContent/
data/text
|
yes |
string |
Message text. More detailsCharacter limit: 1000. |
instantContent/
data/imageURL
|
yes |
string |
URL of an image to be transmitted. More details400x400px image with JPG or PNG extension is recommended to be used. |
instantContent/
data/caption
|
yes |
string |
Button text in Viber message. More detailsCharacter limit: 30. |
instantContent/
data/action
|
yes |
string |
Button link in Viber message. More detailsCharacter limit: 2048. URL for the link shall begin with "http://", "https://", "viber://", "mailto:", "tel:". |
message/data/
serviceNumber
|
no |
string |
Sender’s name from which the message is being sent. |
message/data/ttl
|
no |
integer |
Message lifetime. More detailsAcceptable range in minutes: from 30 to 86400. Note When |
message/data/
ttlUnit
|
no |
enum |
Unit of measurement of the message delivery period. More details
It is transmitted only with
Possible values are: |
extraParam |
no |
string |
Additional parameters passed as More details
The comma character cannot be included in the parameter name, but it
can be included in its value — in this case it must be doubled.
Example: the string
|
registeredDelivery |
no |
integer |
Requirement of delivery reports. More detailsPossible values are:
|
notifyUrl |
no |
string |
Hostname of the incoming API to receive the delivery report. More detailsThis parameter is optional in the request, but if sent you should consider the following: if the parameter is specified, it cannot be empty.
The If any of the specified conditions are not met, an error will be generated and the request will not be executed. |
cascadeChainLink |
no |
object |
Cascading message parameters. More details |
Response#
After sending the message, the Service Provider synchronously returns a response. In case of a successful submission, HTTP code 200 OK is returned.
Successful Viber Sending#
1 {
2 "mtNum": "7390612217"
3 "id": "8770599"
4 }
Parameter |
Data type |
Description |
|---|---|---|
mtNum |
string |
Identifier of the sending chain assigned by the Service Provider platform. |
id |
string |
Unique identifier on the Partner’s side. It is present if it provided when sending. |
Viber Sending Errors#
For error responses, the HTTP response code will be different from 200 (see Error Codes).
1 {
2 "error": {
3 "code": 4,
4 "description": "Invalid request"
5 },
6 "extendedDescription": "Capture is absent or length longer 30 characters"
7 }
In this example capture parameter is missing in the BUTTON type of a Viber message or its length exceeds 30 characters.
Parameter |
Data type |
Description |
|---|---|---|
error |
object |
Error information. |
error/code |
int |
Error code. |
error/description |
string |
A brief description of the error. |
extendedDescription |
string |
Detailed description of the error (optional parameter). |
Error Codes#
Code |
Description |
HTTP-code |
|---|---|---|
1 |
Service is unavailable |
503 |
2 |
Invalid IP-address |
403 |
3 |
Too many connections |
429 |
4 |
Invalid request |
400 |
5 |
Invalid login |
401 |
6 |
Invalid password |
401 |
7 |
serviceNumber is not defined |
400 |
8 |
destAddr is not correct |
406 |
9 |
Message type is not correct |
406 |
10 |
Prohibited sending duplicates |
409 |
11 |
Invalid TTL |
406 |
100 |
100 |
500 |
Viber Delivery Statuses#
To receive Viber message statuses, you need to set up the Delivery Status Service.
Delivery Error codes#
Delivery error codes for each message type are provided in the corresponding tab of the Description of Error Codes (parameter status=5) section.
Viber Session#
Note
The functionality of Viber sessions is not available by default. To enable it, you should contact your account manager.
Viber Session Setup#
Important
For business accounts that support Viber sessions, messages with the type “text only“ or “image only“ are available (the value of InstantContent.type parameter must be TEXT or IMAGE_URL).
Features of the Sessions#
Start of the session:
only subscriber can initiate a session;
the session starts when the subscriber sends the first message to the Partner;
the session cannot be initiated by an image;
if only one sender is present in the correspondence (it doesn’t matter whether it’s a subscriber or a Partner), this is not considered a session, messages will be charged in the usual way.
Session limits:
session duration is 24 hours by default;
the Partner can send up to 60 messages (a new session starts automatically after exceeding this limit);
the Partner can send up to 10 messages without a subscriber’s response (the session is automatically closed after exceeding this limit);
the Partner can send messages with the type “text“ or “image“ only.
The session ends in the following cases:
after 24 hours;
after reaching the limit of 60 messages (a new session starts automatically);
after reaching the limit of 10 unanswered messages from the Partner.