Use Viber message templates
Viber message templates allow you to send pre-approved transactional notifications and one-time passwords (OTP) to end users at scale.
Template management endpoints (/viber/1/senders/{sender}/templates) are in Early Access. Your account must have the viber-bm:manage scope enabled before you can use these endpoints. Contact your Infobip account manager to enable the scope.
Create and register a Viber message template
You can create and register a Viber message template using the web interface or the Viber Business Messages API.
To ensure template approval, follow the constraints listed in Template body constraints and the compliance guidelines.
Message templates over the web interface
To create and register a Viber message template in the web interface:
- Log in and go to Channels and Numbers > Channels > Viber for Business.
- Select the Senders tab.
- Select the sender, then select Create a Template.
- Select the template category: Transactional or OTP.
- In the Design tab, enter the message content and insert parameters using the curly brace icon.
- Select Register Template and save the generated Template ID.
To view submitted templates, select View Templates for the sender on the Senders tab.
For detailed steps with screenshots, see Create and send templates.
Message templates over the API
Using the Viber Business Messages API, you can create, retrieve, send, and delete your templates.
| Method | Path | Success | Description |
|---|---|---|---|
| POST | /viber/1/senders/{sender}/templates | 201 Created | Register a new transactional or OTP template for your sender. |
| GET | /viber/1/senders/{sender}/templates/{templateId} | 200 OK | Retrieve a template and its approval status. |
| POST | /viber/2/messages | 200 OK | Send an approved template to one or more recipients. |
| DELETE | /viber/1/senders/{sender}/templates/{templateId} | 204 No Content | Permanently remove a template. |
All endpoints accept the following authentication methods: API key header (Authorization: App {api-key}), API key query parameter, HTTP Basic, or OAuth 2.0. For details, see API authentication.
For full endpoint specifications, see the Viber Business Messages API reference.
Template categories
There are two message template categories available, depending on your use case.
Transactional
Send non-OTP notifications such as order confirmations, delivery updates, and appointment reminders. Transactional templates support up to 8 named parameters for personalization.
For step-by-step instructions, see Transactional templates.
OTP
Send one-time passwords and verification codes for authentication flows. OTP templates must include a {{pin}} placeholder in the template body.
For step-by-step instructions, see Create and send templates.
Template body constraints
The following table describes the constraints that apply to all template categories.
| Constraint | Value |
|---|---|
| Maximum total length | 1000 characters, including all parameter values. |
| Maximum parameters | 8 |
| Variables at the start | The template body must begin with at least one non-placeholder character. |
| Variables back-to-back | Consecutive placeholders must be separated by at least one space. Example: {{firstName}} {{lastName}} is allowed. |
| Variables at the end | Non-OTP templates cannot end with a placeholder. Add a space after the final placeholder, followed by at least one non-space character.
NOTE Add the space before the punctuation mark, not only after the placeholder. Without the space, Viber treats the punctuation mark as part of the placeholder value, which puts a placeholder at the end of the template and causes template creation to fail. This rule does not apply to OTP templates, which can end with the |
| Per-parameter value length | Each parameter value must not exceed 125 characters. |
| OTP parameters | OTP templates must include a placeholder named {{pin}} and are allowed to end with that same placeholder. Example: Your verification code is {{pin}} is allowed. |
Template statuses
After creation, templates go through an approval process. The following statuses indicate where a template is in that process.
| Status | Meaning | Action |
|---|---|---|
| PENDING | Awaiting review | Wait and poll again. Send only after the status changes to APPROVED. |
| APPROVED | Passed review and ready to use | Proceed to send. |
| DECLINED | Did not pass review | Review the template text against the compliance guidelines and create a revised template. |
Approval typically completes within seconds but can take up to 24 hours. Common decline reasons include the last word being a placeholder or the content containing promotional material.
Supported languages
Templates support 40 languages. Specify the language code when creating a template.