Skip to main content

Viber Templates Management

Viber message templates allow you to create pre-approved message formats for sending transactional messages and OTPs to your customers via Viber. Templates support dynamic parameters that can be substituted at send time.

๐Ÿ“˜ Admin Role Required

Creating Viber templates requires an admin role on the account.

Template Categoriesโ€‹

Viber templates currently support two categories:

CategoryDescription
TransactionalFor sending transactional messages such as order confirmations, shipping updates, and appointment reminders.
OTPFor sending one-time passwords and verification codes.

Creating a Template via APIโ€‹

To create a Viber template, send a POST request to the following endpoint:

POST /api/v1/accounts/{accountId}/channels/{viberChannelId}/templates

Path Parametersโ€‹

ParameterTypeRequiredDescription
accountIdstringYesYour account ID.
viberChannelIdstringYesThe Viber channel ID to associate the template with.

Request Bodyโ€‹

FieldTypeRequiredDescription
namestringYesA unique name for the template. Use lowercase letters, numbers, and underscores only.
categorystringYesTemplate category. Supported values: Transactional, OTP.
languagestringYesLanguage code for the template (e.g., en for English, id for Indonesian).
textstringYesThe template message text. Use {{parameter_name}} syntax for dynamic parameters.
paramsarrayYesList of parameter definitions used in the template text.
params[].namestringYesThe parameter name, matching the placeholder in the template text.
params[].typestringYesThe parameter type. Currently only TEXT is supported.
varExamplearrayYesExample values for each parameter, used during the template review process.
varExample[].namestringYesThe parameter name, matching a params entry.
varExample[].examplestringYesAn example value for the parameter.

Authenticationโ€‹

Include your API key in the request header:

Authorization: Bearer {your_api_key}

Examplesโ€‹

Transactional Templateโ€‹

This example creates an order confirmation template with three dynamic parameters:

curl -X POST \
'https://connect.8x8.com/api/v1/accounts/{accountId}/channels/{viberChannelId}/templates' \
-H 'Authorization: Bearer {your_api_key}' \
-H 'Content-Type: application/json' \
-d '{
"name": "test_order_confirmation_001",
"category": "Transactional",
"language": "en",
"text": "Hello {{customer_name}}, your order {{order_id}} has been confirmed. Estimated delivery: {{delivery_date}}. Thank you!",
"params": [
{
"name": "customer_name",
"type": "TEXT"
},
{
"name": "order_id",
"type": "TEXT"
},
{
"name": "delivery_date",
"type": "TEXT"
}
],
"varExample": [
{
"name": "customer_name",
"example": "John"
},
{
"name": "order_id",
"example": "ORD-12345"
},
{
"name": "delivery_date",
"example": "2026-08-01"
}
]
}'

Request body breakdown:

FieldValueDescription
nametest_order_confirmation_001Unique template identifier
categoryTransactionalTransactional message category
languageenEnglish language
textHello {{customer_name}}, your order...Template text with three placeholders
params3 parameterscustomer_name, order_id, delivery_date โ€” all of type TEXT
varExample3 examplesSample values for each parameter

OTP Templateโ€‹

This example creates a simple OTP verification template:

curl -X POST \
'https://connect.8x8.com/api/v1/accounts/{accountId}/channels/{viberChannelId}/templates' \
-H 'Authorization: Bearer {your_api_key}' \
-H 'Content-Type: application/json' \
-d '{
"name": "otp_login_en",
"category": "OTP",
"language": "en",
"text": "Your verification code is {{pin}}. Valid for 5 minutes. Team 8x8",
"params": [
{
"name": "pin",
"type": "TEXT"
}
],
"varExample": [
{
"name": "pin",
"example": "123456"
}
]
}'

Template Parametersโ€‹

Parameters allow you to insert dynamic content into your template messages at send time. Each parameter in the template text must:

  1. Be wrapped in double curly braces: {{parameter_name}}
  2. Have a corresponding entry in the params array with a name and type
  3. Have a corresponding entry in the varExample array with a sample value

Parameter Namingโ€‹

  • Use descriptive, lowercase names with underscores (e.g., customer_name, order_id)
  • Parameter names in text, params, and varExample must match exactly

Best Practicesโ€‹

  • Template names: Use descriptive names with underscores that indicate the purpose and language (e.g., order_confirmation_en, otp_login_id)
  • Parameters: Provide realistic example values in varExample to help during the review process
  • Text content: Keep messages concise and relevant to the template category
  • Language: Set the correct language code that matches the template text content

API Referenceโ€‹

For the full API specification, see the Add Viber Template API reference.