Template Variables Validations

Validation rules

Validation rules for variables used in Viber OTP templates.


Supported variable types

Variables in OTP templates are validated as one of two types:

TypeDescriptionMax length
TextLetters, digits, spaces, and special characters50 characters
NumberA single numeric value (integer)50 digits

Validation rules by type

Text

RuleDetails
ContentLetters, digits, spaces, and special characters are allowed.
LengthMaximum 50 characters.
LinksNot allowed. Do not include URLs or clickable links in text variables.

Examples — valid

  • MyApp
  • Verification code
  • Acme Bank (Support)
  • You requested a password reset

Examples — invalid

  • https://example.com/verify — links are not allowed
  • A string longer than 50 characters — exceeds maximum length

Number

RuleDetails
ContentA single numeric value only (no decimals unless the template expects them; for validity time, use integers).
SpacesNo spaces before or after the number.
LengthMaximum 50 digits.

Examples — valid

  • 123456 (e.g. PIN)
  • 5, 10, 15 (e.g. validity in minutes)

Examples — invalid

  • 5 — spaces before or after
  • 5 minutes — non-numeric text
  • 1.5 — only use if the template explicitly supports decimals (for OTP validity, use integers)

Which parameters are Text vs Number?

Use the type that matches the template variable. From the templates inventory:

API parameter (camelCase)TypeUsed in templates
pinTextAll (typically digits, but can include letters if your flow allows)
businessPlatformNameText3, 6, 9
pinTypeText5, 7
businessPlatformActionNameText8
codeReasonText9
codeValidityTimeNumber4, 5, 6 (minutes)

Ensure codeValidityTime is sent as a number (e.g. 5, 1), not a string (e.g. "5" may or may not be accepted depending on the API).


Quick checklist

Before sending an OTP request:

  • Text parameters: No URLs or links; length ≤ 50 characters.
  • Number parameters: Single numeric value, no leading/trailing spaces; codeValidityTime in minutes for templates 4, 5, and 6.
  • Template ID: Use the correct template ID for your chosen template (for template 6, use 6c929cef-29b4-4349-bc9d-2a07bdbb6e43).
  • Required parameters: All variables required by the chosen template are present and non-empty.