The Viber channel object for [Advanced transactional](https://www.bulkgate.com/en/docs/advanced-api/advanced-transactional/2.0/). It goes into the `channel` object under the `viber` key - see [Cascade](https://www.bulkgate.com/en/docs/advanced-api/advanced-cascade/).

> [!IMPORTANT]
> Promotional messages use a **different** Viber object under the same key - it carries a button and an image instead of templates. See [Viber – promotional](https://www.bulkgate.com/en/docs/advanced-api/advanced-viber-promotional/).

```json
{
	"viber": {
		"sender": "BulkGate",
		"expiration": 300
	}
}
```

## Viber object

| PARAMETER NAME      | VALUE                                                                                                                                             | MANDATORY | DEFAULT VALUE |
|:--------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------|:---------:|:-------------:|
| text                | Text of the Viber message. Overrides the top-level `text`, see [Which text is used](https://www.bulkgate.com/en/docs/advanced-api/advanced-cascade/)                                     |    No     |    `null`     |
| sender              | Registered Viber sender. Needs to be registered first. For registration contact support [here](https://www.bulkgate.com/en/contact-us/)                              |  **Yes**  |       -       |
| expiration          | Time limit in seconds after which the next channel in the cascade is used. Values below `60` are ignored and replaced by the default               |    No     |     `300`     |
| template_id         | Key of an approved Viber template with a leading `@` (e.g. `@order-confirmation`), or the template ID at Viber. **When it is filled in, the message is sent as a template** and `text` is not used |    No     |    `null`     |
| template_language   | Code of the template language version. Most languages have a two-letter code (`cs`, `en`), the exceptions are `fr_FR`, `es_ES`, `pt_BR`, `pt_PT`, `zh-Hans` and `zh-Hant` |    No     |     `en`      |
| template_parameters | Associative array of template parameters, for e.g.: `{"code": "0451"}`                                                                            |    No     |     `[]`      |

> [!IMPORTANT]
> `template_id` is what switches the message to a template - not `use_template`. The `use_template` parameter is still accepted for backward compatibility, but on this endpoint it has no effect.

Every transactional Viber message has to run on a template approved by Viber in advance. How to register a template is described on the [Viber template registration](https://www.bulkgate.com/en/helpdesk/viber/viber-template-registration/) page.

> [!WARNING]
> **Without `template_id` the message is not billed at the transactional rate.** A Viber message sent through this endpoint without a template goes out at the **promotional** rate; only a message running on an approved template is billed as transactional.

## Example of full request

Viber first, SMS as the fallback. The top-level `text` is used by both legs of the cascade; `expiration` says how long we wait for Viber before switching to SMS.

```http-json
POST /api/2.0/advanced/transactional HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json

{
	"application_id": 451,
	"application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
	"number": ["420777777777"],
	"text": "Your order 4517 has been shipped.",
	"channel": {
		"viber": {
			"sender": "BulkGate",
			"expiration": 120
		},
		"sms": {
			"sender_id": "gText",
			"sender_id_value": "BulkGate"
		}
	}
}
```

The same message as an approved template. `template_id` switches the Viber leg to the template, so the top-level `text` reaches only the SMS leg - and the Viber leg is billed at the transactional rate.

```http-json
POST /api/2.0/advanced/transactional HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json

{
	"application_id": 451,
	"application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
	"number": ["375291234567"],
	"text": "Your verification code is 0451.",
	"channel": {
		"viber": {
			"sender": "BulkGate",
			"template_id": "TEMPLATE_ID",
			"template_language": "en",
			"template_parameters": {"code": "0451"}
		},
		"sms": {
			"sender_id": "gText",
			"sender_id_value": "BulkGate"
		}
	}
}
```

The response is the same for every channel - see [Advanced transactional](https://www.bulkgate.com/en/docs/advanced-api/advanced-transactional/2.0/).
