Developer Docs
The Viber API allows you to send messages to the Viber messenger, as well as to send SMS as an alternative if the message was not delivered to the messenger.
The method allows you to make a Viber messaging. You can include an image, a title and a CTA button into your messages.
Also, this method allows you to specify the option of forwarding (cascading) a message via SMS with the indication of the SMS Alpha-name and its text.
To send Viber message, make a request to this URL:
PUT (POST) https://api.bsg.world/rest/viber/create |
Parameter | Mandatory | Type | Description | ||
validity | No | string | Validity duration of the Viber message, in seconds (by default – 24 hours). An integer from 15 to 86400. | ||
tariff | No | integer | Tariff number. The default is 0. An integer from 0 to 9. | ||
messages | An array of message objects. Contains 1+ objects of the following structure: | ||||
to | An array of recipients: | ||||
msisdn | Yes | string | The phone number to which the message is sent. | ||
reference | No | string | Message external ID. A string of up to 32 characters containing /a-zA-Z0-9/. | ||
text | Yes | string | Viber message text. | ||
alpha_name | Yes | string | Sender. String of up to 14 characters. | ||
is_promotional | Yes | boolean | The indicator whether the message is promotional or transactional. | ||
options | Additional parameters for adding a picture, a title and a button. | ||||
img | No | string | Image URL. | ||
caption | No | string | Button name. | ||
action | No | string | Button URL. | ||
scheduledDatetime | No | string | Time of sending the Viber message (for scheduling the campains). | ||
alt_route | No | Additional parameters for forwarding a Viber message via SMS. These parameters are indicated only if it is necessary to provide alternative delivery of messages in case the message was not delivered in the messenger | |||
originator | Yes | Sender | |||
text | Yes | Message text |
{
"tariff": 9,
"validity": 24,
"messages": [
{
"to": [
{
"msisdn": "380972920283",
"external_id": "example_12"
},
{
"msisdn": "380972920282",
"external_id": "example_13"
}
],
"text": "My Viber messages are shinier than your SMS messages",
"alpha_name": "My Company",
"is_promotional": false,
"options": {
"viber": {
"img": "http://my-cool-webpage.com/logo.png",
"caption": "Join us!",
"action": "http://my-cool-webpage.com"
"alt_route": {
"originator": "testsms",
"text": "SMS message will be received if you are not a VIBER user."
}
},
"scheduledDatetime": "ISO 8601 date"
}
]
}
Parameter | Type | Description | |
messages | contains nested data: | ||
id | integer | Message ID | |
reference | string | Viber message external ID | |
price | float | Message cost | |
currency | string | The currency of the account, in which the message cost in Viber campaign is specified |
If request is successful, you will receive a response:
[
{
"error": "0",
"messages": [
{
"id": "22125",
"reference": "example_12",
"price": "0.02",
"currency": "EUR"
},
{
"id": "22126",
"price": "0.02",
"currency": "EUR"
}
]
}
]