Get ready to automatically post your content to an unlimited audience! Using the API described below you can configure your system to post directly into your Viber Channel.Get started now
Own a Channel – only Channel super admins can get access to API.
Must be using a version of Viber 17.7 or higher.
Obtain Authentication token.
In order to implement our API, as a channel super admin you will need to obtain an authentication token unique for your Channel. You can do this by entering your Channel’s info screen-> scroll down to “Developer Tools” -> copy token -> use the token for posting via API.
Once you have your token you will be able to set your Channel’s webhook. To send messages using this API, it is necessary to set a webhook.
Setting the webhook will be done by calling the set_webhook
API with a valid and certified URL. For security reasons only URLs with valid and official SSL certificate from a trusted Certificate Authority will be allowed. This action defines the account’s webhook and the type of events the account wants to be notified about.
Once a set_webhook
request is sent Viber will send a callback to the webhook to check its availability. The webhook must reply with status 200 for the request to succeed.
Please Note: Posting to the Channel using the API, or when new messages are posted in the Channel by users will not generate a callback to this webhook.
set_webhook
POST requestName | Description | Validation |
---|---|---|
url | Required. Account webhook URL to receive callbacks & messages from users | Webhook URL must use SSL. Note: Viber doesn’t support self signed certificates |
event_types
are deprecated, please ignore
Response parameters
Name | Description | Validation |
---|---|---|
status | Action result | 0 for success. In case of failure – appropriate failure status number. See error codes table for additional information |
status_message | ok or failure reason |
Success: ok . Failure: invalidUrl , invalidAuthToken , badData , missingData and failure . See error codes table for additional information |
For each set_webhook
request Viber will send a callback to the webhook URL to confirm it is available.
The expected HTTP response to the callback is 200
OK – any other response will mean the webhook request failed.
If the webhook is not available the set_webhook
response will be status 1: invalidUrl
.
Callback data
Name | Description | Validation |
---|---|---|
event | Callback type – which event triggered the callback | webhook |
timestamp | Time of the event that triggered the callback | Epoch time |
message_token | Unique ID of the message |
The get_account_info
request will fetch the account’s details as registered in Viber.
The account admin will be able to edit most of these details from his Viber client.
The Sender IDs of the Channel superadmins (role “superadmin”) and admins (role “admin”) can be found under the “members” field of the response. Only the superadmins’ ID should be used as the sender ID with this API.
Destination:
In order to post to your Channel you will need to send a POST request with the below properties.
The following parameters are available for all message types:
Name | Description | Validation |
---|---|---|
from | Unique Viber user id | Required, valid user id. Your audience will see the sender’s name as the Channel name. Note that Channels Super admins uses Channel name alias by default, you can change this in your Channel settings panel |
type | Message type | Required. Available message types: text, picture, video, file, location, contact, sticker, url |
Please Note: All requests should be in JSON format.
Below is a list of all supported message types with post data examples.
Post data
Post parameters
Name | Description | Validation |
---|---|---|
type | Message type | required.text |
text | The text of the message | required. Max 7000 characters |
Post data
Post parameters
Name | Description | Validation |
---|---|---|
type | Message type | required.picture |
text | Description of the photo. Can be an empty string if irrelevant | Required. Max 768 characters |
media | URL of the image (JPEG) | Required. Max size 1 MB. Only JPEG format is supported. Other image formats as well as animated GIFs can be sent as URL messages or file messages. The URL must have a resource with a .jpeg file extension. Example: https://www.example.com/path/image.jpeg |
thumbnail | URL of a reduced size image (JPEG) | Optional. Max size 100 kb. Recommended: 400x400. Only JPEG format is supported |
Post data
Post parameters
Name | Description | Validation |
---|---|---|
type | Message type | required.video |
media | URL of the video (MP4, H264) | Required. Max size 50 MB. Only MP4 and H264 are supported |
size | Size of the video in bytes | Required |
duration | Video duration in seconds; will be displayed to the receiver | Optional. Max 180 seconds |
thumbnail | URL of a reduced size image (JPEG) | Optional. Max size 100 kb. Recommended: 400x400. Only JPEG format is supported |
Post data
Post parameters
Name | Description | Validation |
---|---|---|
type | Message type | required.file |
media | URL of the file | Required. Max size 50 MB. See forbidden file formats for unsupported file types |
size | Size of the file in bytes | Required |
file_name | Name of the file | Required. File name should include extension. Max 256 characters (including file extension). Sending a file without extension or with the wrong extension might cause the client to be unable to open the file |
Post data
Post parameters
Name | Description | Validation |
---|---|---|
type | Message type | required.contact |
contact.name | Name of the contact | Required. Max 28 characters |
contact.phone_number | Phone number of the contact | Required. Max 18 characters |
Post data
Post parameters
Name | Description | Validation |
---|---|---|
type | Message type | required.location |
location | Location coordinates | Required. Latitude (±90°) and longitude (±180°) within valid ranges |
Post data
Post parameters
Name | Description | Validation |
---|---|---|
type | Message type | required.url |
media | URL | Required. Max 2,000 characters |
text | Description of the URL | Optional. Max 120 characters |
Post data
Post parameters
Name | Description | Validation |
---|---|---|
type | Message type | required.sticker |
sticker_id | URL | Unique Viber sticker ID. For examples visit the sticker IDs page |
The following error codes will be returned with API responses. The status
parameter will include the error code value while the status_message
parameter will include the error name or a more specific string describing the error.
Value | Name | Description |
---|---|---|
0 |
ok |
Success |
1 |
invalidUrl |
The webhook URL is not valid |
2 |
invalidAuthToken |
The authentication token is not valid |
3 |
badData |
There is an error in the request itself (missing comma, brackets, etc.) |
4 |
missingData |
Some mandatory data is missing |
7 |
publicAccountBlocked |
The account is blocked |
8 |
publicAccountNotFound |
The account associated with the token is not a account. |
9 |
publicAccountSuspended |
The account is suspended |
10 |
webhookNotSet |
No webhook was set for the account |
12 |
tooManyRequests |
Rate control breach |
other | General error |
General error |
In the event that you need to invalidate the current authentication token and generate a new one, please email your request to devsupport@viber.com with the link to the Channel & the super admin’s phone number.