skip to content
February 18, 2025

How to Send OTP Message to WhatsApp with Sendwo API by PHP

- No Comments

Integrate Sendwo with your website or app using the new Sendwo API. This allows you to send WhatsApp messages, including OTPs, directly from your platform. This article provides a step-by-step guide on sending WhatsApp OTP messages via the API.

Step 1:

To get your API key, go to the Sendwo dashboard, click on your user account, and select "API Developer." Then, click the "Generate API Key" button.

User Account > API Developer > Generate API Key

image 16

WhatsApp offers two APIs: the Send API and the Subscriber/Contact API. This example demonstrates sending a WhatsApp message using the Send API, specifically using a PHP script to deliver an OTP.

For business-initiated messages or messages sent outside the 24-hour customer service window, a pre-approved message template is required. While direct messaging is possible with users active in a 24-hour chat window, template messages can be sent to any user, even those added manually as subscribers.

Step 2: (Creating Template Message for OTP)

To create a message template, go to your WhatsApp account's Message Template section within the WhatsApp Bot Manager.

WhatsApp > Bot Manager > Select Bot Account > Message Template

We'll start by creating a variable for our message template. This is necessary because each user will receive a unique OTP. To create the variable, click the "Create" button in the Template variables section.

image 17

Give a name for the variable and click on the save button. Now, from the message template settings click on the “Create” button to create a template.

image 18

Once the previous step is finished, a template creation form will appear. Provide a name and locale for the template. Select the appropriate category, and since this is an OTP template, choose "OTP" as the type. Adding a header is optional; if desired, select the "Header" type.

Compose the message in the body, including the generated OTP variable by selecting it from the provided list. A footer is also optional. Since this template doesn't require buttons, leave the footer setting as "None." Finally, click the "Save" button.

image 19

The template should be in the list after it has been created.

image 20

Click the check status button to discover if the template has been approved or not. They must immediately approve or disapprove.

image 21

Yes, the template was created and approved successfully.

Step 3:

To generate an API endpoint for sending a template message, navigate to "Generate API End-point : Send Template Message (GET)". Select the desired WhatsApp account (using your WhatsApp phone number) and choose the "OTP message template" from the available templates. This will use the template you recently created.

image 22

As soon we select the Message template it will ask us to put a name for it. Just put OTP on the field and click on the “Get API end-point”.

image 23

It will generate the API End-point. We will use this code in the PHP script to send OTP messages to WhatsApp users.

image 24

In the PHP script, we will put this generated code into a variable. Then we need to write a few lines of code.

We need to change the OPT-VALUE and SEND-TO-PHONE-NUMBER from the API end-point to variables. Just like below.

image 25

The final code will look like this after updating the values with variables.

[ Use must use your generated API End-point ]

If we just run this code, the message should be delivered to the WhatsApp number.

So, this is how we can utilize the WhatsApp API of Sendwo to deliver OTP messages to WhatsApp numbers.

About The Author:

Puneet Sharma

I'm Puneet Sharma, Cofounder of Sendwo. I'm building SendWo, a WhatsApp BSP, to empower businesses with cutting-edge AI-powered WhatsApp chatbots. Passionate about simplifying customer communication and driving growth through innovative WhatsApp solutions.

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms & ConditionsPrivacy PolicyRefund PolicyShipping Policy
Copyright © 2025 | SENDWO - Bulk WhatsApp Sender Software
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram