# VIBER API

DecisionTelecom Viber API allows you to send and receive Viber business messages to and from any country in the world via API. Each message is identified by a unique random ID, so users can always check the status of a message using given endpoint.

The Viber API uses HTTPS with access key that is used as the API authorization. Request and response payloads are formatted as JSON using UTF-8 encoding.

**API Authorization** - Base64 access key.

Please contact your account manager to get an API key.

## **Auth**

## Basic Auth

#### **Example**:

```
$userHashKey = 'User Hash Key provided by your account manager';
$ch = curl_init('https://web.it-decision.com/v1/api/send-viber');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$userHashKey");
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestParams)); // 
$requestParams - raquest array with correct data 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
$result = curl_exec($ch); 
curl_close($ch);
```

## **Send Viber message**

{% tabs %}
{% tab title="POST" %}

```
https://web.it-decision.com/v1/api/send-viber
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Request POST:" %}

```json
Example for text-image-button messages:
{
	"source_addr": "Custom Company", 						
	"destination_addr": 8882222200,							
	"message_type":108, 									
	"text":"Message content", 										
	"image":"https://yourdomain.com/images/image.jpg", 		
	"button_caption":"Join Us", 							
	"button_action":"https://yourdomain.com/join-us",   	
	"source_type":1, 										
	"callback_url":"https://yourdomain.com/viber-callback",
	"validity_period":3600
}

Example for promotional text messages:
{
	"source_addr": "Custom Company", 						
	"destination_addr": 8882222200,	
	"message_type":225, 								
	"text":"Message content",
	"source_type":1, 	
	"callback_url":"https://yourdomain.com/viber-callback",
	"validity_period":3600
}

Example for send file:
{
	"source_addr": "Custom Company", 						
	"destination_addr": 8882222200,						
	"message_type":222, 
	"file_url":" https://yourdomain.com/files/custom.pdf ",	
	"source_type":1, 								
	"callback_url":"https://yourdomain.com/viber-callback",
	"validity_period":180
}

Example for transactional template messages:
{
	"source_addr": "Custom Company", 						
	"destination_addr": 8882222200,	
	"message_type":304, 
	"text":"Message content",							
	"source_type":2,
	"callback_url":"https://yourdomain.com/viber-callback",
	"validity_period":180
}

Example for carousel messages:
{
	"source_addr": "Custom Company",
	"destination_addr": 8882222200,
	"message_type":901,
	"source_type":1, // carousel is promotional message
	"callback_url":"https://yourdomain.com/viber-callback",
	"validity_period":6800,
	"text":"Message content",
	"carousel": {
	    "items": [
	      {
	        "title": "50% Off on All Shoes!50%",
	        "imageUrl": "https://example.com/images/sale.jpg",
	        // Expected formats - PNG, JPEG, JPG. Recommended size: 215x185px
	        "primaryButton": {
	          "label": "Shop Now",
	          "actionUrl": "https://example.com/shoes-sale"
	        },
	        "secondaryButton": {
	          "label": "View Details",
	          "actionUrl": "https://example.com/shoes-sale"
	        }
	      },
	      {
	        "title": "New Arrivals: Summer Collection",
	        "imageUrl": "https://example.com/images/sum.jpg",
	        // Expected formats - PNG, JPEG, JPG. Recommended size: 215x185px
	        "primaryButton": {
	          "label": "Explore",
	          "actionUrl": "https://example.com/summer"
	        },
	        "secondaryButton": {
	          "label": "Learn More",
	          "actionUrl": "https://example.com/summer-info"
	        }
	      }
	    ]
	  }
}

Example for list messages:
{
	"source_addr": "Custom Company",
	"destination_addr": 8882222200,
	"message_type":801,
	"source_type":2, // list is trsnsactional message
	"callback_url":"https://yourdomain.com/viber-callback",
	"validity_period":1600,
	"text":"Survey title",
	"tracking_data": "tracking data for
survey", // tracking_data is mandatory for list message
  "survey": {
    "options": [ // Number of options can be from 2 to 5.
      "option1 text",
      "option2 text",
      "option3 text",
      "option4 text",
      "option5 text"
    ]
  }
}
```

{% endtab %}
{% endtabs %}

### **Parameters**

**source\_addr:**

from 3 to 20 characters - from whom the message

**destination\_addr:**

from 11 to 20 digits - to whom the message

**message\_type (Type of message sent):**

225 - only text (for all devices)

8 - text+image+button (for primary device)

108 - text+image+button (for all devices)

9 - text+ button (for primary device)

109 - text+button (for all devices)

222 - send file (for all devices) , supported formats: .doc, .docx, .rtf, .dot, .dotx, .odt ,odf, .fodt, .txt, .info, .pdf, .xps, .pdax, .eps, xls, .xlsx, .ods, .fods, .csv, .xlsm, .xltx

301 - template transactional text (for primary device)

304 - template transactional text (for all devices)

801 - list message (for all devices)

901 - carousel message (for all devices)

**text:**

up to 1000 characters - text of Viber message

**image (Correct URL with image for promotional message with button caption and button action):**

jpg or jpeg (mime type is image/jpeg), maximum resolution 800x800 pixels

png (mime type is image/png), maximum resolution 800x800 pixels

**button\_caption:**

from 1 to 30 characters - button caption

**button\_action:**

Correct URL for transition when you press the button

**source\_type (Message sending procedure):**

promotion message (the message can be with text, picture, button) - 1

transactional message (template text message) – 2

**callback\_url:**

Correct URL for message status callback

**validity\_period:**

TTL (Time to live) allows the sender to limit the lifetime of a message. In case the message did not get the status "delivered" before the time ended, the message will not be charged and will not be delivered to the user. In case no TTL was provided (no "ttl" parameter) Viber will try to deliver the message for up to 1 day.

promotion message - min TTL 60 seconds max TTL 43200 seconds (12 hours)

transactional message - min TTL 60 seconds max TTL 43200 seconds (12 hours)

**file\_url:**

Only for 222 message type сorrect URL for document.\
Possible file extensions to send: .doc, .docx, .rtf, .dot, .dotx, .odt ,odf, .fodt, .txt, .info, .pdf, .xps, .pdax, .eps, xls, .xlsx, .ods, .fods, .csv, .xlsm, .xltx\
The file name must contain an extension and must not exceed 25 characters.\
File size must be up to 200 MB.

**carousel:**&#x20;

message type enables businesses to send a single message featuring text and multiple\
customizable sections (items), each showcasing different products or services along with\
dedicated media and a call-to-action.\
The message type allows presenting from 2 to 5 individual items. Each carousel item includes an\
image, a brief description, and offers up to 2 customizable buttons. All items in the carousel can\
have different sets of buttons.

**items:** from 2 to 5 carousel items.

* title (Mandatory) - Item title text. From 2 to 38 UTF-8 characters.
* imageUrl (Mandatory) - Expected formats - PNG, JPEG, jpg. Recommended size: 215x185
* primaryButton (Mandatory) - Holds a set of primary button parameters.
* secondaryButton (Optional) - Holds a set of secondary button parameters.
* label (Mandatory) - Button parameter. The text that will appear on the action button. Up to 10 UTF-8 characters when inside the primaryButton. Up to 12 UTF-8 characters when inside the secondaryButton.
* actionUrl (Mandatory) - Button parameter. The URL users are directed to or the action performed when pressing the action button\or tap on the image.

**survey:**&#x20;

List messages provide the opportunity to present users with a question and 2-5 answers\
from which they will be able to select one. Once a user selects an option, it will be\
highlighted as selected. The corresponding option text will be sent from the user to the\
business chat, triggering a user’s reply callback to the message URL, provided to the manager and set in your account settings.

After selection, the user will be able to change his selection.\
Upon changing the selection, an additional message will be sent on the user behalf in the\
chat and an additional reply callback will be sent to the message URL, provided to the manager and set in your account settings.

To utilize this message type, please ensure **that your business account has a**\
**message URL value configured**.

**options:** from 2 to 5 list items.

* text (Mandatory) - Up to 85 UTF-8 characters.
* tracking\_data (Mandatory) - Mandatory for List message type.
* options (Mandatory) - Number of options can be from 2 to 5.
* option text (Mandatory) - Up to 50 UTF-8 characters per option.

### **User’s reply callback for list message**:

Text response indicating user’s selection will be sent to the business message URL along with\
tracking information provided in the request:

{% tabs %}
{% tab title="JSON (POST)" %}

```json
{
    "message_token":5420791495801572569,
    "phone_number":"+972611200716", 
    "time":"1584475182",
    "service_id":3001, 
    "message": {
        "text":"Yes, very satisfied",
        "tracking_data": "tracking data for survey"
    }
}
```

{% endtab %}
{% endtabs %}

### Response:

{% tabs %}
{% tab title="JSON (POST)" %}

```json
{
    "message_id":4291235	
}
```

{% endtab %}
{% endtabs %}

### **Values**:

**message\_id:**

Sent message ID

## Send verification messages (**OTP)**

### Logic

A templated message is a predefined message stored on Viber side which allows the\
sender to define specific values upon sending the message. Viber\`s verification messages\
are new message types designed for sending one time passwords (OTP) using\
pre-approved and pre-designed templates.

### Availability

Templates described in the [Predefined OTP Templates section](#predefined-otp-templates) are available for all services by default.\
In contrast to our regex template logic, there is no need to submit a template for each\
and every service separately, they are already stored on our side.

### Copy

A templated message has a predefined copy which includes [predefined variables](#predefined-otp-templates) that\
can be defined to hold a requested value by the sender.\
Variables are specific and defined for each template and will be validated according to\
specific limitations of each variable.

Example of templated message structure:\
Your code is **{{pin}}**.\
Please don't share your code with ANYONE. We'll never call or message you and ask for it.

In this case, the sender can define the pin value when sending the message. For\
example, if the sender will define the pin as 123456, the message that will be shown to\
the user will be:\
Your code is **123456**.\
Please don't share your code with ANYONE. We'll never call or message you and ask for it.

{% tabs %}
{% tab title="Request POST:" %}

```json
Example for verification messages (OTP):
{
	"source_addr": "Custom Company", 						
	"destination_addr": 8882222200,							
	"message_type":701, // 701 - OTP to primary only; 702 - to all of the user devices									
	"source_type":2,    // OTP is trasactional message										
	"callback_url":"https://yourdomain.com/viber-callback",
	"validity_period":180,
	"template_id":"be56d97b-2a33-4c89-ac5f-f555a2c827d9", // see more in Predefined OTP Templates section
	"template_params":{ // see more about params in Predefined OTP Templates section
		"pin":"5234567"
		/*"code_reason":"subscribed to the newsletter"*/
		/*"business_platform_name": "Custom Company"*/
		/*"business_platform_action_name": "Custom Company"*/
		/*"pin_type":"custom pin type"*/
		/*"code_validity_time":15*/
	}	
   
}
```

{% endtab %}
{% endtabs %}

### Additional Parameters for OTP

**message\_type:**\
Mandatory.\
**701** - template message sent to primary only\
**702** - template message sent to all of the user devices

**template\_id:** \
Mandatory. [Predefined code](#predefined-otp-templates) of a template copy to be sent.

**template\_params:**\
Mandatory. A range of variables which are specific per template. For the\
templates and possible values description. Each template holds a different\
set of parameters which will be validated upon request.

### Predefined OTP Templates

<table data-full-width="false"><thead><tr><th width="277.5999755859375">1.Basic OTP</th><th width="468"></th></tr></thead><tbody><tr><td>Template ID</td><td>0aac888f-2ee2-4112-9659-1755a951966a</td></tr><tr><td>English Copy</td><td>Your code is <strong>{{pin}}</strong>.<br><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT</td></tr></tbody></table>

<table data-full-width="false"><thead><tr><th width="277.5999755859375">2.Basic OTP valid for 5 minutes</th><th width="468"></th></tr></thead><tbody><tr><td>Template ID</td><td>c2cdc028-a48b-4187-bbaf-3aaa137b6e23</td></tr><tr><td>English Copy</td><td>Your code is <strong>{{pin}}</strong>. It's valid for 5 minutes.<br><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT</td></tr></tbody></table>

<table data-full-width="false"><thead><tr><th width="277.5999755859375">3.OTP with business/platform name</th><th width="468"></th></tr></thead><tbody><tr><td>Template ID</td><td>c33cccaf-735f-4d62-8383-a76bf4999e2d</td></tr><tr><td>English Copy</td><td><p><strong>{{business_platform_name}}</strong>: Your code is <strong>{{pin}}</strong>. </p><p><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</p></td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT <br>{{business_platform_name}} - TEXT</td></tr></tbody></table>

<table data-full-width="false"><thead><tr><th width="277.5999755859375">4.Basic OTP with code validity time</th><th width="468"></th></tr></thead><tbody><tr><td>Template ID</td><td>bed0942f-e07e-4879-834b-29cc4cf3ec35</td></tr><tr><td>English Copy</td><td>Your code is <strong>{{pin}}</strong>. It's valid for <strong>{{code_validity_time}}</strong> minutes. <br><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT <br>{{code_validity_time}} - NUMBER</td></tr></tbody></table>

<table data-full-width="false"><thead><tr><th width="277.5999755859375">5.OTP with code type &#x26; validity time</th><th width="468"></th></tr></thead><tbody><tr><td>Template ID</td><td>60d67b38-b9fb-444a-80e6-754447e010c6</td></tr><tr><td>English Copy</td><td>Your <strong>{{pin_type}}</strong> code is <strong>{{pin}}</strong>. It's valid for <strong>{{code_validity_time}}</strong> minutes. <br><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT <br>{{pin_type}} - TEXT <br>{{code_validity_time}} - NUMBER</td></tr></tbody></table>

<table data-full-width="false"><thead><tr><th width="277.5999755859375">6.OTP with business/platform  name &#x26;  validity time</th><th></th></tr></thead><tbody><tr><td>Template ID</td><td>6c929cef-29b4-4349-bc9d-2a07bdbb6e43</td></tr><tr><td>English Copy</td><td>Your <strong>{{business_platform_name}}</strong> code is <strong>{{pin}}</strong>. It's valid for <strong>{{code_validity_time}}</strong> hours. <br><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT <br>{{business_platform_name}} - TEXT <br>{{code_validity_time}} - NUMBER</td></tr></tbody></table>

<table><thead><tr><th width="277.5999755859375">7.OTP with type of code type</th><th width="468"></th></tr></thead><tbody><tr><td>Template ID</td><td>82ba31a3-db42-4e87-82e8-33fa92b9e5ed</td></tr><tr><td>English Copy</td><td>Your <strong>{{pin_type}}</strong> code is <strong>{{pin}}</strong>.<br><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT<br>{{pin_type}} - TEXT</td></tr></tbody></table>

<table><thead><tr><th width="277.5999755859375">8.OTP with details on OTP action/platform</th><th width="468"></th></tr></thead><tbody><tr><td>Template ID</td><td>210ee8a9-1ed5-43cd-96e4-65bba311ab40</td></tr><tr><td>English Copy</td><td>Your one-time password for <strong>{{business_platform_action_name}}</strong> is <strong>{{pin}}</strong>.<br><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT <br>{{business_platform_action_name}} - TEXT</td></tr></tbody></table>

<table><thead><tr><th width="277.5999755859375">9.OTP with business/platform name &#x26; code reason</th><th width="468"></th></tr></thead><tbody><tr><td>Template ID</td><td>be56d97b-2a33-4c89-ac5f-f555a2c827d9</td></tr><tr><td>English Copy</td><td><strong>{{business_platform_name}}</strong>: Your code is <strong>{{pin}}</strong>. You got this code because <strong>{{code_reason}}</strong>. <br><strong>Please don't share your code with ANYONE</strong>. We'll never call or message you and ask for it.</td></tr><tr><td>Parameters and<br>Validations</td><td>{{pin}} - TEXT <br>{{business_platform_name}} - TEXT <br>{{code_reason}} - TEXT</td></tr></tbody></table>

## **Receive Viber message**

{% tabs %}
{% tab title="POST" %}

```
 https://web.it-decision.com/v1/api/receive-viber
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Request POST:" %}

```json
{
    "message_id":4291235
}
```

{% endtab %}
{% endtabs %}

### Parameters

**message\_id:**

The ID of the message whose status you want to get (for the last 30 days)

{% tabs %}
{% tab title="Response JSON:" %}

```json
{
    "message_id":4291235, 			
    "status":1, 					
}
```

{% endtab %}
{% endtabs %}

### Values

**message\_id:**

The ID of the message whose status you want to get (for the last 30 days)

**status:**

Current Viber message status

## **Receive bulk Viber messages**

The number of verified messages is no more than 200 in one request.

{% tabs %}
{% tab title="POST" %}

```
 https://web.it-decision.com/v1/api/receive-bulk-viber
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Request POST:" %}

```json
[
     {"message_id":11017894},
     {"message_id":11017879},
     {"message_id":11017865},
     {"message_id": ... n}
]
```

{% endtab %}
{% endtabs %}

### Parameters

**message\_id:**

The ID of the message whose status you want to get (for the last 30 days)

{% tabs %}
{% tab title="Response JSON:" %}

```json
{
    "11017894": {
        "message_id": 11017894,
        "status": 1
    },
    "11017879": {
        "message_id": 11017879,
        "status": 1
    },
    "11017865": {
        "name": "Empty parameter or parameter validation error",
        "message": "Invalid Parameter: message_id 11017865 is not accepted for you",
        "code": 1,
        "status": 400
    }
}
```

{% endtab %}
{% endtabs %}

### Values

**message\_id:**

The ID of the message whose status you want to get (for the last 30 days)

**status:**

Current Viber message status

## **Callback**

The callback will be returned to the URL specified when sending the message in the parameter callback\_url

{% tabs %}
{% tab title="Response JSON:" %}

```json
{
    "message_id":4291235,                                 
    "status":1                                                                       
}

If the status is 3 (Rejected) then the additional parameter reject_code will be returned:
{
    "message_id":4291235,                                 
    "status":1,         
    "reject_code":9                                              
}

If the message type being sent is 301 or 304 (template transactional text) then the additional parameter matching_template_id will be returned
{
    "message_id":4291235,                                 
    "status":1,         
    "matching_template_id":11079289                                                            
}
```

{% endtab %}
{% endtabs %}

### Values

**message\_id:**

The ID of the message

**status:**

Current Viber message status

**reject\_code:**

code returned by Viber when rejecting a message:

1 - Internal server error.

2 - The ID wasn’t in use for over a year/The ID was recently created and

wasn’t uploaded to the server yet.

3 - An error in the request’s structure. Could be a missing comma, brackets,

text over 1000 characters, etc.

5 - Incorrect message type. Either a non-supported type or an incorrect value.

6 - Missing mandatory parameters.

7 - Indicates a server timeout on Viber’s end.

8 - The ID was blocked by the user/The user blocked business messages

completely on their device.

9 - The destination number is not registered as a Viber user.

10 - Not an Android or iOS device with a Viber version that supports Business

Messages.

401 - The request was sent from a non-whitelisted IP for this ID/An incorrect ID

that doesn’t belong to the partner was used in the request.

13 - An error in the billing process

18 - Missing value/Incorrect value in the request for “label” parameter.

28 - The file that is being attempted to be sent is not in a supported format for

this feature.

29 - The name of the file is more than the maximum 25 characters.

30 - In case the thumbnail URL is compiled of more than 1000 characters.

38 - The provided template ID is not found (for OTP)

39 - Template variables did not pass the server validation (for OTP)

40 - One of the List messages parameters failed validation.

41 - One of the Carousel messages parameters failed validation.

**matching\_template\_id:**

ID issued by Viber when registering a template. If the parameter is present and the parameter value is empty, it means the message does not match any of the registered templates and has been re-rated from transactional to promotional message on the Viber side.

## **Viber messages statuses**

| Name        | Status code |
| ----------- | ----------- |
| sent        | 0           |
| delivered   | 1           |
| error       | 2           |
| rejected    | 3           |
| undelivered | 4           |
| pending     | 5           |
| seen        | 6           |
| unknown     | 20          |

## **Errors**

| Name    | Too Many Requests   |
| ------- | ------------------- |
| message | Rate limit exceeded |
| code    | 0                   |
| status  | 429                 |

| Name    | Empty parameter or parameter validation error |
| ------- | --------------------------------------------- |
| message | Invalid Parameter: \<param>                   |
| code    | 1                                             |
| status  | 400                                           |

#### param:

source\_addr more than 20 chars

destination\_addrr more than 20 chars

wrong viber user account

source\_type is wrong

source\_type or message\_type is wrong

source\_type is wrong, because the account is another type

message\_type is wrong

empty text

text more than 1000 chars

transaction message error - not empty image, button\_caption or button\_action

message\_type is wrong - not empty image, button\_caption or button\_action

message\_type is wrong - empty image, button\_caption or button\_action

message\_type is wrong - empty button\_caption or button\_action

image is not url

image url wrong scheme

image not valid type

image is not valid

image size is more than 800x800

button\_action is empty

button\_caption is empty

button\_caption or button\_action is empty

image or button\_action is empty

image or button\_caption is empty

callback\_url is not url

callback\_url url wrong scheme

button\_action is not url

button\_action url wrong scheme

button\_action more than 30 chars

message\_id \<message\_id> is not accepted for you

file\_url is not url

file\_url wrong scheme

file\_url contains an invalid file type or extension, possible file extensions to send: .doc, .docx, .rtf, .dot, .dotx, .odt ,odf, .fodt, .txt, .info, .pdf, .xps, .pdax, .eps, xls, .xlsx, .ods, .fods, .csv, .xlsm, .xltx

button\_caption is not applicable with file\_url

button\_action is not applicable with file\_url

image is not applicable with file\_url

wrong message type for file\_url

file\_url is not applicable in this context

| Name    | Internal server error                                                                         |
| ------- | --------------------------------------------------------------------------------------------- |
| message | The server encountered an unexpected condition which prevented it from fulfilling the request |
| code    | 2                                                                                             |
| status  | 500                                                                                           |

| Name    | Topup balance is required |
| ------- | ------------------------- |
| message | Sender balance is empty   |
| code    | 3                         |
| status  | 402                       |

| Name    | Duplicate error                  |
| ------- | -------------------------------- |
| message | Duplicate Viber message detected |
| code    | 4                                |
| status  | 400                              |

| Name    | Message Template error                  |
| ------- | --------------------------------------- |
| message | The message does not match any template |
| code    | 5                                       |
| status  | 400                                     |

| Name    | Authorization error |
| ------- | ------------------- |
| message | Unauthorized        |
| code    | 6                   |
| status  | 401                 |

## Viber example

{% tabs %}
{% tab title="cUrl" %}

```
curl --location --request POST 'https://web.it-decision.com/v1/api/send-viber' \
--header 'Authorization: Basic api key' \
--header 'Content-Type: application/json' \
--data-raw '{"source_addr": "Custom Company", "destination_addr": 8882222200,"message_type":106,"text":"Message content","image":"https://yourdomain.com/images/image.jpg","button_caption":"Join Us","button_action":"https://yourdomain.com/join-us","source_type":1,"callback_url":"https://yourdomain.com/viber-callback","validity_period":3600}'

```

{% endtab %}

{% tab title="С#" %}

```
var client = new RestClient("https://web.it-decision.com/v1/api/send-viber");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic api key");
request.AddHeader("Content-Type", "application/json");
var body = @"{""source_addr"": ""Custom Company"", ""destination_addr"": 8882222200,""message_type"":106,""text"":""Message content"",""image"":""https://yourdomain.com/images/image.jpg"",""button_caption"":""Join Us"",""button_action"":""https://yourdomain.com/join-us"",""source_type"":1,""callback_url"":""https://yourdomain.com/viber-callback"",""validity_period"":3600}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

```

{% endtab %}

{% tab title="Golang" %}

```
package main

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

func main() {

  url := "https://web.it-decision.com/v1/api/send-viber"
  method := "POST"

  payload := strings.NewReader(`{"source_addr": "Custom Company", "destination_addr": 8882222200,"message_type":106,"text":"Message content","image":"https://yourdomain.com/images/image.jpg","button_caption":"Join Us","button_action":"https://yourdomain.com/join-us","source_type":1,"callback_url":"https://yourdomain.com/viber-callback","validity_period":3600}`)

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

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

  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))
}

```

{% endtab %}

{% tab title="Java" %}

```
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"source_addr\": \"Custom Company\", \"destination_addr\": 8882222200,\"message_type\":106,\"text\":\"Message content\",\"image\":\"https://yourdomain.com/images/image.jpg\",\"button_caption\":\"Join Us\",\"button_action\":\"https://yourdomain.com/join-us\",\"source_type\":1,\"callback_url\":\"https://yourdomain.com/viber-callback\",\"validity_period\":3600}");
Request request = new Request.Builder()
  .url("https://web.it-decision.com/v1/api/send-viber")
  .method("POST", body)
  .addHeader("Authorization", "Basic api key")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();

```

{% endtab %}

{% tab title="JavaScript" %}

```
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic api key");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "source_addr": "Custom Company",
  "destination_addr": 8882222200,
  "message_type": 106,
  "text": "Message content",
  "image": "https://yourdomain.com/images/image.jpg",
  "button_caption": "Join Us",
  "button_action": "https://yourdomain.com/join-us",
  "source_type": 1,
  "callback_url": "https://yourdomain.com/viber-callback",
  "validity_period": 3600
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://web.it-decision.com/v1/api/send-viber", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

```

{% endtab %}

{% tab title="C – lib cUrl" %}

```
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://web.it-decision.com/v1/api/send-viber");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Authorization: Basic api key");
  headers = curl_slist_append(headers, "Content-Type: application/json");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\"source_addr\": \"Custom Company\", \"destination_addr\": 8882222200,\"message_type\":106,\"text\":\"Message content\",\"image\":\"https://yourdomain.com/images/image.jpg\",\"button_caption\":\"Join Us\",\"button_action\":\"https://yourdomain.com/join-us\",\"source_type\":1,\"callback_url\":\"https://yourdomain.com/viber-callback\",\"validity_period\":3600}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

```

{% endtab %}

{% tab title="NodeJs" %}

```
var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'web.it-decision.com',
  'path': '/v1/api/send-viber',
  'headers': {
    'Authorization': 'Basic api key',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "source_addr": "Custom Company",
  "destination_addr": 8882222200,
  "message_type": 106,
  "text": "Message content",
  "image": "https://yourdomain.com/images/image.jpg",
  "button_caption": "Join Us",
  "button_action": "https://yourdomain.com/join-us",
  "source_type": 1,
  "callback_url": "https://yourdomain.com/viber-callback",
  "validity_period": 3600
});

req.write(postData);

req.end();

```

{% endtab %}

{% tab title="PHP" %}

```
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://web.it-decision.com/v1/api/send-viber',
  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 =>'{"source_addr": "Custom Company", "destination_addr": 8882222200,"message_type":106,"text":"Message content","image":"https://yourdomain.com/images/image.jpg","button_caption":"Join Us","button_action":"https://yourdomain.com/join-us","source_type":1,"callback_url":"https://yourdomain.com/viber-callback","validity_period":3600}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Basic api key',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}

{% tab title="Python" %}

```
import http.client
import json

conn = http.client.HTTPSConnection("web.it-decision.com")
payload = json.dumps({
  "source_addr": "Custom Company",
  "destination_addr": 8882222200,
  "message_type": 106,
  "text": "Message content",
  "image": "https://yourdomain.com/images/image.jpg",
  "button_caption": "Join Us",
  "button_action": "https://yourdomain.com/join-us",
  "source_type": 1,
  "callback_url": "https://yourdomain.com/viber-callback",
  "validity_period": 3600
})
headers = {
  'Authorization': 'Basic api key',
  'Content-Type': 'application/json'
}
conn.request("POST", "/v1/api/send-viber", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

```

{% endtab %}

{% tab title="Ruby" %}

```
require "uri"
require "json"
require "net/http"

url = URI("https://web.it-decision.com/v1/api/send-viber")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Basic api key"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "source_addr": "Custom Company",
  "destination_addr": 8882222200,
  "message_type": 106,
  "text": "Message content",
  "image": "https://yourdomain.com/images/image.jpg",
  "button_caption": "Join Us",
  "button_action": "https://yourdomain.com/join-us",
  "source_type": 1,
  "callback_url": "https://yourdomain.com/viber-callback",
  "validity_period": 3600
})

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://en-api.decisiontele.com/viber-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
