Developer Docs

Table of contents

Sending a Viber message

PUT (POST is also supported) /viber/create

The JSON-encoded array is passed, having the following structure:

Endpoint: https://api.bsg.hk/rest/viber/create

Header:

X-API-KEY: live_qwer234
Content-type: application/json

JSON Body RAW:

{
    "tariff": 9,
    "validity": 24,
    "messages": [
        {
            "to": [
                {
                    "msisdn": "85227210116",
                    "external_id": "example_12"
                },
                {
                    "msisdn": "85226010227",
                    "external_id": "example_13"
                }
            ],
            "text": "My Viber messages are shinier than your SMS messages",
            "callback_url": "https://my-cool-webpage.com/viber-dlr",
            "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"
                }
            },
            "scheduledDatetime": "ISO 8601 date"
        }
    ]
}
  • validity – the validity duration of the Viber message, in seconds (by default – 24 hours). An integer from 15 to 86400
  • tariff – tariff number. The default is 0. An integer from 0 to 9
  • result – an array of message objects. Contains 1+ objects having the following structure:
  • to – array of recipients. Upon that, the required parameter phone and the optional parameter external_id are set
  • text – Viber message text
  • callback_url – link to automatically send delivery reports. Attention, the report is sent only if the external_id is specified for the recipient.
  • alpha_name – sender
  • is_promotional – the attribute defining whether the message is promotional, or transactional
  • options – additional options. At the moment, the options that are present in the Viber tag are being checked.
  • scheduledDatetime – time of the SMS sending (for the SMS messaging scheduling)

Example of the correct response:

[
    {
        "error": "0",
        "messages": [
            {
                "id": "22125",
                "reference": "example_12",
                "price": "0.02",
                "currency": "EUR"
            },
            {
                "id": "22126",
                "price": "0.02",
                "currency": "EUR"
            }
        ],
        "total_price": "0.04",
        "currency": "EUR"
    }
]

In case if the request contains an error:

{
"error":"11","errorDescription":"Incorrect msisdn"
}

We use cookies (and other similar technologies) to collect data to improve your experience on our site. By using our website, you’re agreeing to the collection of data as described in our Website Data Collection Policy.