Skip to main content

How to Send OTP on WhatsApp Using Wati API

Updated over a week ago

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.

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 approved, you can trigger the OTP using WATI's /sendTemplateMessage API. This API allows your system to send the pre-approved authentication message to users.

API Endpoint:

https://{WATI_API_ENDPOINT}/api/v1/sendTemplateMessage

Click here to read more about the 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.

For more details, refer to the official WhatsApp Business API Authentication Templates Guide.

Note: For merchants who use the Wati API to send authentication OTP messages, you can enable SMS fallback to help ensure OTP delivery and maintain smooth business operations even if WhatsApp messages fail.

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 broadcast.

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.

Frequently Asked Questions (FAQs)

Authentication templates and OTP

1. What is an authentication template for OTP?

It is a pre-approved message format required by WhatsApp to send OTPs through Wati. It includes an OTP placeholder, preset verification text, and a button such as Copy Code or One-Tap Autofill.

2. What elements must be included in an authentication template?

It must contain a verification message with the OTP placeholder. Optional fields include a security disclaimer and an expiration warning. It must also include a button like Copy Code or One-Tap Autofill.

3. Can authentication templates include URLs, media, or emojis?

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

4. Do authentication templates need approval from WhatsApp?

Yes. You must submit the template and wait for WhatsApp’s approval before sending OTP messages.

Sending OTP through Wati API

5. How do I send OTP messages using Wati?

Once your authentication template is approved, you can send OTPs using Wati’s /sendTemplateMessage API.

6. What is the API endpoint for sending OTP messages?

The endpoint is: https://{WATI_API_ENDPOINT}/api/v1/sendTemplateMessage

Availability and fallback setup

7. Which Wati plans support authentication templates?

They are supported on the Growth, Pro, and Business plans. On legacy plans, they are supported on Standard and Professional plans.

8. What is SMS fallback and who can use it?

SMS fallback ensures OTP delivery by sending an SMS if the WhatsApp OTP fails. It is available only on the Wati Business plan.

9. How do I enable SMS fallback in Wati?

Connect your Twilio account in Wati under More → Integrations and enable automated SMS for failed broadcast. You must also create both WhatsApp and SMS OTP templates and map them together so fallback can work automatically.

Did this answer your question?