Verify API

Send OTP Codes Over WhatsApp With the Telnyx Verify API

Send one-time passwords through WhatsApp using the Telnyx Verify API. One request sends the code, one request verifies it. No separate WhatsApp Business API integration required.

By Harpreet Singh Seehra

A WhatsApp OTP is a one-time password delivered through WhatsApp to confirm a user's identity during signup, login, payment approval, or account recovery. With the Telnyx Verify API, your app sends a WhatsApp OTP with one POST request and checks the submitted code with a second POST request. The API manages the OTP lifecycle across SMS, WhatsApp, and voice.

WhatsApp gives verification teams another delivery channel for users who already use it. WhatsApp reports more than 2 billion users in over 180 countries. That reach matters when SMS delivery is uneven or when users expect messages in a branded WhatsApp thread.

WhatsApp OTP overview

The Telnyx Verify API manages three parts of the verification flow. It generates the code, delivers the code, and validates the code when the user submits it. If you are building your first verification flow, start with the OTP guide and the Verify overview.

When you set the verification channel to whatsapp, Telnyx sends the OTP through WhatsApp instead of SMS. Your application keeps the same two-step pattern. Start the verification. Then verify the submitted code.

You do not need a separate WhatsApp Business API integration, custom template management, or a second verification code path. The WhatsApp Business API integration is handled by Telnyx behind the scenes.

Note: WhatsApp OTP works for users who can receive WhatsApp messages. Keep SMS or voice fallback for users without WhatsApp access or for failed delivery paths.

How WhatsApp OTP works

The WhatsApp verification flow has four user-facing steps. Your app requests the code. Telnyx delivers it through WhatsApp. The user enters the code. Your app sends the submitted code back to Telnyx for validation.

Verification flow

1

App requests OTP

2

Verify generates code

3

WhatsApp delivers code

4

User submits code

5

Verify checks code

Request the OTP

Your application sends a POST request with the user's phone number, your Verify Profile ID, and type set to whatsapp.

Deliver the code

Telnyx generates the OTP and sends it to the user's WhatsApp inbox. You can receive webhook events as the verification moves through the delivery pipeline.

Check the submitted code

The user enters the OTP in your app, website, or mobile flow. Your app sends that code back to Telnyx. Telnyx returns the verification result.

Send a WhatsApp OTP

Use this request to start a WhatsApp verification.

bash
curl -X POST https://api.telnyx.com/v2/verifications \
 -H "Authorization: Bearer YOUR_TELNYX_KEY" \
 -H "Content-Type: application/json" \
 -d '{
 "phone_number": "+15551234567",
 "verify_profile_id": "YOUR_VERIFY_PROFILE_ID",
 "type": "whatsapp"
 }'

The field that sets the delivery channel is "type": "whatsapp". That tells Telnyx to send the OTP through WhatsApp.

If you wanted to send the same verification over SMS instead, you would use "type": "sms". The rest of the request stays the same.

The verify_profile_id refers to a Verify Profile created in the Telnyx Mission Control Portal. This profile controls settings such as code length, expiration time, and enabled verification channels.

Verify the code

Once the user enters the OTP, send it back to Telnyx using the verification endpoint.

bash
curl -X POST https://api.telnyx.com/v2/verifications/by_phone_number/+15551234567/actions/verify \
 -H "Authorization: Bearer YOUR_TELNYX_KEY" \
 -H "Content-Type: application/json" \
 -d '{
 "code": "12345"
 }'

Replace +15551234567 with the phone number used in the original request. Replace 12345 with the code submitted by the user.

A successful response means the code is valid. If the code is incorrect or expired, Telnyx returns an error response. That is the core integration. One request sends the OTP. One request verifies it.

Track delivery with webhooks

Telnyx can send webhook events to your configured endpoint as the verification progresses. These events help your app show status, store audit logs, and start fallback rules when a message fails or expires.

Webhook eventMeaningUse
verify.sentThe OTP message was sentStart a status timer.
verify.deliveredWhatsApp confirmed delivery to the user's deviceShow delivery state.
verify.completedThe user submitted the correct codeComplete the user action.
verify.failedThe verification failed, expired, or could not be completedTrigger retry or fallback rules.

For example, if WhatsApp delivery fails, your application can fall back to SMS without requiring the user to restart the verification process. Plan those rules before launch. The SMS 2FA, 2FA guide, and number verification resources cover common policy choices.

Choose the right verification channel

Use WhatsApp when the user has WhatsApp and expects messages there. Use SMS when reach is the main requirement. Use voice when a text-based path fails or the user needs an audible code.

Use the Telnyx SMS API when your verification stack also needs standalone global messaging. It supports 10DLC, toll-free, and shortcodes. Use the Telnyx Voice API when a fallback must call the user. It supports programmable voice with WebSocket support.

You switch channels by changing a single field in the request body. That makes it easier to build flexible verification flows. Try WhatsApp first. Fall back to SMS if needed. Use voice for users who cannot receive text-based messages.

Why Telnyx for WhatsApp OTPs

Without Telnyx Verify, sending OTPs through WhatsApp means working directly with the WhatsApp Business API. You manage templates, handle delivery events, and maintain additional integration logic. Telnyx abstracts that complexity.

One API for all channels

SMS, WhatsApp, and voice through a single Verify API. Switch by changing one field.

Less operational complexity

Telnyx handles WhatsApp template management, delivery events, and verification status tracking behind the scenes.

Global reach

WhatsApp is used across many international markets. Add WhatsApp verification without provisioning local numbers or country-specific messaging logic.

Built-in fallback

If WhatsApp delivery fails, fall back to SMS or voice without requiring the user to restart the verification process.

Try the example app

Telnyx provides a working Python Flask example that shows how to send, verify, and track WhatsApp OTPs. Clone the whatsapp-verify-otp-python example from GitHub.

The example includes routes for sending the OTP, validating the submitted code, receiving verification webhooks, and environment variable configuration for your Telnyx API key and Verify Profile ID.

Getting started

To start sending OTPs over WhatsApp with Telnyx:

Setup checklist:
  1. Sign up for a Telnyx account
  2. Create a Verify Profile in the Mission Control Portal
  3. Enable WhatsApp as a verification channel
  4. Clone the example app
  5. Set your TELNYX_API_KEY and VERIFY_PROFILE_ID
  6. Run the app and test the verification flow

You can find the full Verify API documentation at developers.telnyx.com.

FAQ

How is WhatsApp OTP different from SMS OTP?
WhatsApp OTPs arrive in a branded WhatsApp message thread instead of a standard SMS text. Users who already use WhatsApp may find this more familiar. WhatsApp delivery can also be more reliable in markets where SMS delivery rates are uneven.
Do I need a separate WhatsApp Business API integration?
No. Telnyx handles the WhatsApp Business API integration, message formatting, and template management behind the scenes. You send a verification request through the Verify API and Telnyx delivers the code through WhatsApp.
Can I fall back from WhatsApp to SMS?
Yes. If WhatsApp delivery fails, your application can send a new verification request with "type": "sms". The user does not need to restart the verification process. Use webhook events like verify.failed to trigger fallback logic.
What does WhatsApp OTP cost with Telnyx?
Verify API via WhatsApp Messaging costs $0.03 per successful verification plus WhatsApp API pricing. You are charged only for verifications that complete successfully. Check the Verify API product page for current pricing details.
What do I need before sending WhatsApp OTPs?
You need a WhatsApp Business Account (WABA) with an approved authentication template, and a Verify profile configured with WhatsApp as a channel. Create or update your Verify profile in the Mission Control Portal under Identity and Verify.

Start sending WhatsApp OTPs todayUse one API for SMS, WhatsApp, and voice verification. No separate integration required.

Get started free
Share on Social

Sign up for emails of our latest articles and news