Developer Docs

Table of contents

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.

Send Viber message

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

Request parameters:

ParameterMandatoryTypeDescription
validityNostringValidity duration of the Viber message, in seconds (by default – 24 hours). An integer from 15 to 86400.
tariffNointegerTariff number. The default is 0. An integer from 0 to 9.
messagesAn array of message objects. Contains 1+ objects of the following structure:
toAn array of recipients:
msisdn YesstringThe phone number to which the message is sent.
referenceNostringMessage external ID. A string of up to 32 characters containing /a-zA-Z0-9/.
textYesstringViber message text.
alpha_nameYesstringSender. String of up to 14 characters.
is_promotionalYesbooleanThe indicator whether the message is promotional or transactional.
optionsAdditional parameters for adding a picture, a title and a button.
imgNostringImage URL.
captionNostringButton name.
actionNostringButton URL.
scheduledDatetimeNostringTime of sending the Viber message (for scheduling the campains).
alt_routeNoAdditional 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
originatorYesSender
textYesMessage text

Request example:

{
    "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"
        }
    ]
}

Response parameters:

ParameterTypeDescription
messagescontains nested data:
id integerMessage ID
referencestringViber message external ID
pricefloatMessage cost
currencystringThe 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"
            }
        ]
    }
]