Skip to main content

Send a Message

POST https://chatapi.viber.com/pa/send_message

This endpoint allows you to send a message to a subscriber of your bot.

Pay attention

The following limitations apply to the send_message endpoint:

  • You can send up to 100 messages to a user within an hour without receiving a reply. The
    message count towards the limit will reset when the user replies to a message. Once you
    have reached the limit, you will receive the following error response:
    {"status":12,"status_message":"Too many requests", message_token: "1234567890", chat_hostname: "SN-CHAT-0x_"}
  • Maximum message size is 30KB.

Request

Headers


Content-Type: application/json
Authorization: X-Viber-Auth-Token: YOUR_AUTHENTICATION_TOKEN

Parameters


NameTypeDescriptionNotes
typestringThe type of the message.Required. one of the available message types. See full list here
sender.namestringThe name of the bot.Required. Max 28 characters.
sender.avatarstringThe avatar of the bot.Optional. the avatar size should not exceed 100KB. The recommended dimensions for the avatar are 720x720.
tracking_datastringAllow the bot to track messages and user’s replies. The tracking_data value sent with the message will be returned with the user's reply.Optional Max 4000 characters
min_api_versionintegerThe minimum API version that the message is supported in.Optional Default value is 1.
Additional fileds based on the message type
Example
curl -X POST https://chatapi.viber.com/pa/broadcast_message -H "X-Viber-Auth-Token: YOUR_AUTHENTICATION_TOKEN" -d '{"type":"text",receiver="jc9HsWTZ2Yf2NkRZ8KcNug==","text":"Hello World","sender":{"name":"Viber Bot","avatar":"http://avatar.example.com"}}'

Response

Attributes


NameTypeDescriptionNotes
statusintegerThe status of the request.0 for success. In case of failure - appropriate failure status number. See common errors for more information
status_messagestringThe status message of the request.Success: ok. Failure: invalidUrl, invalidAuthToken, badData, missingData and failure. See common errors for more information
message_tokenintegerUnique id of the message
chat_hostnamestringThe name of ther server that host your botfor internal use
billing_statusstringAn indication of how this message is categorized for billing purposes, allowing you to know if it was charged or not, or whether it counts toward. Read more about bots billing hereAn integer between 0 and 5. See the table in billing statuses section below for more information
Example
{
"status": 0,
"status_message": "ok",
"message_token": 1234567890,
"chat_hostname": "chatapi.viber.com",
"billing_status": 0
}

Billing Statuses


ValueNameDescription
0freeDefault for all cases other than the ones listed below: chat extension, reply to open conversation, etc.
1inSessionNonBillableBot1:1 message/keyboard sent in a session from a non-billable bot
2inSessionForBillableBot1:1 message/keyboard sent in a session from a billable bot
3outOfSessionFreeMessageNonBillableBotFree out of session 1:1 message/keyboard sent by a non-billable bot
4outOfSessionFreeMessageForBillableBotFree out of session 1:1 message/keyboard sent by a billable bot
5outOfSessionBilledMessageCharged out of session 1:1 message/keyboard sent by a billable bot