News! SmartSender.io becomes Wooxy. Read a post from the CEO Arrow
Wooxy API v.3.0

Send Viber message

The Send Viber message method allows you to send Viber messages to any contact and manually select the domain from which to send them. Using various parameters, you can create different templates.

PAY ATTENTION 

This method does not provide for sending messages to countries from the list of restrictions: Ukraine, Belarus, Russia

Request

POST
/v3/viber/send

IMPORTANT: Do not send more than 10 concurrent API requests.

Body Example

                                        {
  "domain": "senderDomain.com",
  "phoneNumber": "+1555555555",
  "senderId": "Viber_SenderName",
  "text": "VIBER_CONTENT_TEXT",
  "buttons": {
          "text": "Title of button",
          "url": "FINAL_DESTINATION_URL"
    },
  "device": "all",
  "ttl": 3600,
  "tags": [
    "registeredTag",
    "registeredTag 2"
  ]
}
                                    

Parameters

Title Type Default Description

domain

required
string

Verified domain name from your Wooxy account. This data is used to send you webhooks and generate reports.

phoneNumber

required
string

Addressee phone number.
IMPORTANT: should be valid E.164 phone number.

senderId

optional
string Wooxysender’s default name

Your own registered name in Viber.
IMPORTANT: If you are using Wooxysender’s default name, leave this field blank.

text

required
string

Viber content text you want to send.

buttons

optional
object null

Important: Using a button without text block is not possible 

buttons.text

required
string

Text for button name

buttons.url

required
string

Link to the page where subscribers will get when they click on the link

device

optional
string all

Add kind of devices to the parameter:

  • all: We send to all devices: desktop and mobile;
  • phone: The message will only be shown on the mobile app.

ttl

optional
integer 3600

Time to live must be specified in seconds. Between 30 minutes to  72 hour.

tags

optional
array null

An array of string to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or changed frequently. Tags should be 50 characters or less.
Important: Use only registered tags.
Any tags starting with an underscore are reserved for internal use and will cause errors.

Response

                                        {
   "result": true,
   "viber_message_ids": ["5d914c3dd132d5f45a4e3670"]
}
                                    

Parameters

Title Type Description

viber_message_ids

string

The message unique identification number in the Wooxy system.

result

boolean

The sending status of the recipient:

  • true: The message is accepted and queued;
  • false: The message is rejected.

Method Errors

                                        {
   "result": false,
   "errors": [
      "Error description text"
   ]
}
                                    
Error

“Argument ‘domain’ must be a non-empty string”

“Argument senderId must be a non-empty string”

“{phoneNumber} is not a valid E.164 phone number”

“Argument text must be a non-empty string”

“Argument button must be an array with “text” and “url” string elements”

“Argument ttl must be a positive integer”

“Argument device must be all or phone”

“Argument tags must be an array”

“Tag name must be a non-empty string”

“Tags should be 50 characters or less”

“Any tags starting with an underscore are reserved for internal use and will cause errors”

“Domain {domain} not found in your account”

“Current method is not allowed for country {code}”

“There is no default list in domain {id}”

“Sender with senderId {id} not registered in account”

“Sender with senderId {id} not approved”

“Country of contact is not allowed for senderId {id}”

“There is no registered senderId {id} in account”

“Tag {tag} is not registered in account tags”

“Invalid authorization token!”

“Internal server error”

“Bad Request”

“No matches found for access token {accessToken}”

“User {id} not enabled”

“No data found for key {userId}”

“Access token check failed for key/secret $key/$accessToken”

Code Examples

PHP
                $accessToken = "YOUR_API_KEY";
$url         = 'https://api.wooxy.com/v3/viber/send';
$body        = json_encode([
    "domain"      => "senderDomain.com",
    "phoneNumber" => "+1555555555",
    "senderId"    => "Viber_SenderName",
    "text"        => "VIBER_CONTENT_TEXT",
    "button"      => [ 
          "text"  => "Title of button", 
          "url"   => "FINAL_DESTINATION_URL", 
    ],
    "device"      => "all", 
    "ttl"         => 3600, 
    "tags"        => [ 
          "registeredTag",
    ],
]);

/**
 * Request Example
 */
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_INFILESIZE, null);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Access-Token: $accessToken",
    'Content-Type: application/json',
    'Content-Length: ' . strlen($body),
]);

$result = curl_exec($ch);
if ($result === false) {
    echo 'cURL error:' . curl_error($ch) . PHP_EOL;
} else {
    echo strval($result) . PHP_EOL;
}
curl_close($ch);