Skip to content

Send Viber Message

Our Viber Messaging API designed to fullfill most of your use cases and can be easily integrate to any of the system. We can implement single Viber message, Personlized batch Viber Message using this API.

POST
/viber/v1/send

Authentication

AUTHORIZATION: Bearer Token

Request parameters

Parameter Value / Pattern
*originator The Sender/Header of a viber message. We can use your brand name. If you would like to register a new Sender ID, you can submit your details in Register originator Section in Viber Getting Started Page
*label Enum: "PROMOTION" "TRANSACTION". Describes the nature of message being sent to end user. Default value is "promotion".
*recipients Mobile Numbers to send viber messages separated by comma in an array. The recipient's phone number should have a country code prefix. You can also set the Default Country here, and all your messages will be prefixed with the selected country code.
*content The message content is being sent. Limited to 1000 UTF-8 characters. Also, billing will be based on the number of message parts sent
image The URL address of image to be sent to end user. Image can be sent only by itself or combined with text and button. Image can be sent only if label is set to "promotion". If label is set to "transaction" this parameter must be empty.
file_name (url) The name of the file shared by the business with the user.
video The data of the video shared by the business with the user.
*duration: The duration of the video in seconds.
*fileSize: The size of the video file in MB.
*thumbnail: A static image url that acts as the preview image for the video.
*url: Public video URL.
button_action The link of button action. Button can be sent only if label is set to "promotion". If label is set to "transaction" this parameter must be empty.
button_caption Text found on the button. Button can be sent only if message contains text and only if label is set to "promotion". If label is set to "transaction" this parameter must be empty. Maximum length is 30 characters.
*channel To select the messaging channel that you want to use. (e.g., SMS, WhatsApp, Viber, Telegram, etc.)
call_back_url To receive delivery status (DLR) for your viber message, specify the callback server URL where you want to receive the message status updates using the call_back_url parameter. When the delivery status changes, the status updates will be sent to the specified URL. For information on the format of the DLR message, please refer to the "Receiving DLR" section.

Response

When the request is validated, request_id, status and created time will be returned. Users can use this request_id to query status using the Get status endpoint.

200 - Success
{
    "request_id": "d9835609-a4e0-10ea-a26a-eeafbe700fef",
    "status": "accepted",
    "created_at": "2001-08-05T12:52:38.393Z"
}
401 - Unauthorized
{ 
    "detail": { 
    "code": "ACCESS_TOKEN_SIGNATURE_VERIFICATION_FAILED",
    "message": "It looks like your requests were failed due to a missing or invalid 'Access Token'. Sign up at https://app.d7networks.com and create an authentication token in the developer section."
    } 
} 
422 - Validation Error
{
    "detail": [
        {
            "loc": [
            "string"
            ],
        "msg": "string",
        "type": "string"
        }
    ]
} 

Response Parameters

Parameter Value / Pattern
request_id Unique id for each Viber request. This request_id is required to check delivery status of your Viber message.
status The status of Viber request. Possible request status are accepted and rejected
created_at Date and time of the Viber request.

Examples:

1. Same content to Multiple recipients

curl --location --request POST 'https://api.d7networks.com/viber/v1/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "channel": "viber",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Greetings from D7 API",
        "label": "PROMOTION"
    }
],
"message_globals": {
    "originator": "SignOTP",
    "call_back_url": "https://the_url_to_recieve_delivery_report.com"
}
}'
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")

const response = await client.viber.sendViberMessage({
            recipients : ["+97150900XXXX","+97845900XXX"],
            content : 'Hello, this is a test message!',
            label : 'PROMOTION',
            originator : 'SignOTP',
            call_back_url : 'https://the_url_to_recieve_delivery_report.com'
        });

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

client = Client(api_token="Your API token")

client.viber.send_viber_message(recipients=["+97150900XXXX","+97845900XXX"], content="Greetings from D7 API", label="PROMOTION", originator="INFO2WAY", call_back_url="https://the_url_to_recieve_delivery_report.com")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
1
2
3
4
5
6
7
8
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$client = new Client(api_token="Your API token")

$response = $direct7->viber->sendViberMessage(recipients:["+97150900XXXX","+97845900XXX"], content:'Hello, World!', label:'PROMOTION', originator:'SignOTP', call_back_url:'https://example.com/callback');
var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)   
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
viber := direct7.NewViber(client)
recipients := []string{"{{recipient}}"}
content := "Greetings from D7 API"
label := "PROMOTION"
originator := "INFO2WAY"
callBackURL := "https://the_url_to_recieve_delivery_report.com"

response, err := viber.SendViberMessage(recipients, content, label, originator, callBackURL)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"messages\": [\n    {\n        \"channel\": \"viber\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Greetings from D7 API\",\n        \"label\": \"PROMOTION\",\n}\n  ],\n  \"message_globals\": {\n    \"originator\": \"SignOTP\",\n    \"call_back_url\": \"https://the_url_to_recieve_delivery_report.com\"\n  }\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/viber/v1/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/viber/v1/send'));
request.body = json.encode({
"messages": [
    {
    "channel": "viber",
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Greetings from D7 API",
    "label": "PROMOTION"
    }
],
"message_globals": {
    "originator": "SignOTP",
    "call_back_url": "https://the_url_to_recieve_delivery_report.com"
}
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n  `"messages`": [`n    {`n        `"channel`": `"viber`",`n        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n        `"content`": `"Greetings from D7 API`",`n        `"label`": `"PROMOTION`",`n        }`n  ],`n  `"message_globals`": {`n    `"originator`": `"SignOTP`",`n    `"call_back_url`": `"https://the_url_to_recieve_delivery_report.com`"`n  }`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/viber/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
1
2
3
4
5
require 'direct7'

client = Direct7::Client.new('Your API token')

client.viber.send_viber_message(recipients=["+97150900XXXX","+97845900XXX"], content="Greetings from D7 API", label="PROMOTION", originator="INFO2WAY", call_back_url="https://the_url_to_recieve_delivery_report.com")

2. Different content and Multiple destinations

curl --location --request POST 'https://api.d7networks.com/viber/v1/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
    "messages": [
        {
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Greetings from D7 API - First message",
        "label": "PROMOTION"
        },
        {
        "recipients": ["{{recipient3}}","{{recipient4}}"],
        "content": "Greetings from D7 API - Second Message",
        "label": "PROMOTION"
        }
    ],
    "message_globals": {
        "channel": "viber",
        "originator": "SignOTP",
        "call_back_url": "https://the_url_to_recieve_delivery_report.com"
        }
}'
var axios = require('axios');
var data = JSON.stringify({
"messages": [
    {
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Greetings from D7 API - First message",
    "label": "PROMOTION"
    },
    {
    "recipients": [
        "{{recipient3}}",
        "{{recipient4}}"
    ],
    "content": "Greetings from D7 API - Second Message",
    "label": "PROMOTION"
    }
],
"message_globals": {
    "channel": "viber",
    "originator": "SignOTP",
    "call_back_url": "https://the_url_to_recieve_delivery_report.com"
}
});

var config = {
method: 'post',
url: 'https://api.d7networks.com/viber/v1/send',
headers: { 
    'Content-Type': 'application/json', 
    'Accept': 'application/json', 
    'Authorization': 'Bearer {{api_access_token}}'
},
data : data
};

axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json

url = "https://api.d7networks.com/viber/v1/send"

payload = json.dumps({
"messages": [
    {
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Greetings from D7 API - First message",
    },
    {
    "recipients": [
        "{{recipient3}}",
        "{{recipient4}}"
    ],
    "content": "Greetings from D7 API - Second Message",
    }
],
"message_globals": {
    "channel": "viber",
    "originator": "SignOTP",
    "label":"PROMOTION",
    "call_back_url": "https://the_url_to_recieve_delivery_report.com"
}
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.d7networks.com/viber/v1/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
    "messages": [
        {
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Greetings from D7 API - First message",
        "label": "PROMOTION"
        },
        {
        "recipients": ["{{recipient3}}","{{recipient4}}"],
        "content": "Greetings from D7 API - Second Message",
        "label": "PROMOTION"
        }
    ],
    "message_globals": {
        "channel": "viber",
        "originator": "SignOTP",
        "call_back_url": "https://the_url_to_recieve_delivery_report.com"
        }
}',
CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Accept: application/json',
    'Authorization: Bearer {{api_access_token}}'
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
package main

import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)

func main() {

url := "https://api.d7networks.com/viber/v1/send"
method := "POST"

payload := strings.NewReader(`{
    "messages": [
        {
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": "Greetings from D7 API - First message",
        "label": "PROMOTION"
        },
        {
        "recipients": ["{{recipient3}}","{{recipient4}}"],
        "content": "Greetings from D7 API - Second Message",
        "label": "PROMOTION"
        }
    ],
    "message_globals": {
        "channel": "viber",
        "originator": "SignOTP",
        "call_back_url": "https://the_url_to_recieve_delivery_report.com"
        }
}`)

client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)

if err != nil {
    fmt.Println(err)
    return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer {{api_access_token}}")

res, err := client.Do(req)
if err != nil {
    fmt.Println(err)
    return
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(body))
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": \"Greetings from D7 API - First message\",\n        \"label\": \"PROMOTION\",\n   },\n        {\n        \"recipients\": [\"{{recipient3}}\",\"{{recipient4}}\"],\n        \"content\": \"Greetings from D7 API - Second Message\",\n        \"msg_type\": \"text\",\n        \"data_coding\": \"text\"\n        }\n    ],\n    \"message_globals\": {\n        \"channel\": \"viber\",\n        \"originator\": \"SignOTP\",\n        \"call_back_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/viber/v1/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();    
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/viber/v1/send'));
request.body = json.encode({
"messages": [
    {
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Greetings from D7 API - First message",
    "label": "PROMOTION"
    },
    {
    "recipients": [
        "{{recipient3}}",
        "{{recipient4}}"
    ],
    "content": "Greetings from D7 API - Second Message",
    "label": "PROMOTION"
    }
],
"message_globals": {
    "channel": "viber",
    "originator": "SignOTP",
    "call_back_url": "https://the_url_to_recieve_delivery_report.com"
}
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n    `"messages`": [`n        {`n        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n        `"content`": `"Greetings from D7 API - First message`",`n        `"label`": `"PROMOTION`",`n   },`n        {`n        `"recipients`": [`"{{recipient3}}`",`"{{recipient4}}`"],`n        `"content`": `"Greetings from D7 API - Second Message`",`n        `"msg_type`": `"text`",`n        `"data_coding`": `"text`"`n        }`n    ],`n    `"message_globals`": {`n        `"channel`": `"viber`",`n        `"originator`": `"SignOTP`",`n        `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n        }`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/viber/v1/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
require "uri"
require "json"
require "net/http"

url = URI("https://api.d7networks.com/viber/v1/send")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer {{api_access_token}}"
request.body = JSON.dump({
"messages": [
    {
    "recipients": [
        "{{recipient1}}",
        "{{recipient2}}"
    ],
    "content": "Greetings from D7 API - First message",
    "label": "PROMOTION"
    },
    {
    "recipients": [
        "{{recipient3}}",
        "{{recipient4}}"
    ],
    "content": "Greetings from D7 API - Second Message",
    "label": "PROMOTION"
    }
],
"message_globals": {
    "channel": "viber",
    "originator": "SignOTP",
    "call_back_url": "https://the_url_to_recieve_delivery_report.com"
}
})

response = https.request(request)
puts response.read_body