Summary

This guide explains how to send a One-Time Password (OTP) via WhatsApp using Wati's API. You'll learn how to create an authentication template, get approval, and trigger OTP messages using the /sendTemplateMessage API.

Availability

  • Authentication templates are available to Wati customers on the Growth, Pro, and Business plans.

  • If you are on a Wati's legacy plan, authentication templates are available on the Standard and Professional plans.

Instructions

Please refer to this video walkthrough to learn about sending OTPs on WhatsApp via Wati:

Step 1: Create an Authentication Template

Before sending OTPs, you need to create an authentication template message and get approval from WhatsApp. This template ensures a consistent format for authentication messages.

Required Elements in the Authentication Template:

An authentication template with OTP buttons must include:

  • Verification message: A preset text containing the OTP placeholder.

  • <VERIFICATION_CODE> is your verification code.

  • Security disclaimer (optional): For your security, do not share this code.

  • Expiration warning (optional): This code expires in <NUM_MINUTES> minutes.

  • Button: Either a Copy Code or One-Tap Autofill button.

Important notes

  • URLs, media, and emojis are not supported in authentication templates.

  • These templates reduce the risk of being paused, as they consist only of preset text and buttons.

Once you submit the template, wait for WhatsApp's approval before proceeding to the next step.

Step 2: Send OTP Using the API

Once your authentication template is approved, use Wati's /sendTemplateMessage API to send the pre-approved OTP message to your users.

API Endpoint:

POST https://live-mt-server.wati.io/{tenantId}/api/v1/sendTemplateMessage

Replace {tenantId} with your Wati tenant ID.

Request parameters

Query parameters

Use either of the following parameters to specify the recipient's WhatsApp number:

  • whatsappNumber: The recipient's WhatsApp phone number.

  • target: The recipient's phone number.

Request body

Include the following fields in the request body:

Parameter

Description

template_name

Name of the approved authentication message template.

broadcast_name

Name used to identify the message broadcast.

parameters[]

Array of parameters containing the dynamic values, such as the OTP, used in the template.

channel_number

WhatsApp phone number or channel used to send the message.

Note: If you use the Wati API to send authentication OTP messages, you can enable SMS fallback to help deliver OTPs when WhatsApp message delivery fails.

Using Send Template Message V3 API

Can you send AUTHENTICATION templates (Copy Code) via the POST /api/ext/v3/messageTemplates/send endpoint?

Yes. A few things to know when sending authentication templates (OTP codes) through this endpoint:

  • Parameter name: Use {{1}} for the OTP/code value.

  • Code expiry: 90 minutes is the maximum expiry time allowed by Meta.

  • Template setup: Authentication templates must be created using Meta's preset authentication template format, or selected from the template library - they can't be built as freeform templates.

For the complete request parameters, response format, and error codes for sending message templates (including authentication templates), see the Send Message Template API V3 reference.

Set up SMS fallback if WhatsApp OTP fails

Follow these steps to set up SMS as a fallback if a WhatsApp OTP message fails:

Step 1: Upgrade to the Wati Business plan

SMS fallback is only available on the Business plan.

Step 2: Connect Wati with Twilio

In Wati, go to More → Integrations.
Add your Twilio account and turn on Send automated SMS for failed campaign.

Step 3: Create a WhatsApp OTP template

In Wati, create the message template that will be used for WhatsApp authentication OTP.

Step 4: Create an SMS OTP template

Create a matching SMS template and map it to the WhatsApp OTP template you created in Step 3.

Step 5: Send the WhatsApp OTP using Wati API

When your system calls the Wati API to send the WhatsApp OTP template, Wati will automatically send the SMS fallback through Twilio if the WhatsApp delivery fails.

Tip: To know more about authentication templates, refer to the official guide by Meta.

Frequently Asked Questions (FAQs)

OTP authentication templates

1. Which Wati plans support WhatsApp authentication templates?

WhatsApp authentication templates are available on the following Wati plans:

  • Current plans: Growth, Pro, and Business.

  • Legacy plans: Standard and Professional.

2. What are the requirements and restrictions for WhatsApp authentication templates?

A WhatsApp authentication template must include:

  • Verification message: Preset text containing the OTP placeholder, such as {{VERIFICATION_CODE}} is your verification code.

  • Button: Either a Copy Code or One-Tap Autofill button.

The following elements are optional:

  • Security disclaimer: For example, "For your security, do not share this code."

  • Expiration warning: For example, "This code expires in minutes."

Additional restrictions:

  • URLs, media, and emojis are not supported.

  • Templates must use Meta's preset authentication format or a template from the template library. Freeform templates are not supported.

  • WhatsApp must approve the template before it can be used to send OTP messages.

Sending OTP messages using Wati APIs

3. How can I send WhatsApp OTP messages using the Wati API?

You can send WhatsApp OTP messages using Wati's /sendTemplateMessage API after WhatsApp approves your authentication template.

API endpoint:

POST https://live-mt-server.wati.io/{tenantId}/api/v1/sendTemplateMessage

Replace {tenantId} with your Wati tenant ID.

Use either whatsappNumber or target as a query parameter to specify the recipient's WhatsApp phone number.

Include the following fields in the request body:

  • template_name: Name of the approved authentication template.

  • broadcast_name: Name used to identify the message broadcast.

  • parameters[]: Array containing dynamic values, such as the OTP.

  • channel_number: WhatsApp phone number or channel used to send the message.

4. Can I send WhatsApp authentication OTP templates using the Send Template Message V3 API?

Yes. You can send authentication templates, including Copy Code OTP templates, using the POST /api/ext/v3/messageTemplates/send endpoint.

Keep the following requirements in mind:

  • Parameter name: Use {{1}} for the OTP or verification code value.

  • Code expiry: The maximum expiry time allowed by Meta is 90 minutes.

  • Template format: Use Meta's preset authentication template format or select a template from the template library. Freeform templates are not supported.

Refer to the Send Message Template API V3 reference for the complete request parameters, response format, and error codes.

SMS fallback for WhatsApp OTP messages

5. How can I enable SMS fallback if WhatsApp OTP delivery fails?

Wati supports automatic SMS fallback through Twilio when WhatsApp OTP delivery fails. This feature is available only on the Wati Business plan.

To enable SMS fallback, you need:

  • An active Wati Business plan.

  • A connected Twilio account in Wati.

  • The Send automated SMS for failed campaign option enabled under More → Integrations.

  • A WhatsApp OTP template created in Wati.

  • A matching SMS OTP template mapped to the WhatsApp OTP template.

Once configured, Wati automatically sends the SMS fallback through Twilio when your system uses the Wati API to send a WhatsApp OTP template and WhatsApp delivery fails.

Did this answer your question?