Blog
WhatsApp OTP Verification: How It Works and How It Compares to SMS OTP
WaForge Team · · 3 min read
When someone signs up or logs in, you want to know that the phone number they typed is really theirs. The usual answer is a one-time code by SMS. WhatsApp OTP verification does the same job, but the code arrives in the person's WhatsApp chat.
What is WhatsApp OTP? #
OTP means one-time password: a short code that works once and expires quickly. With WhatsApp OTP, your app sends that code as a WhatsApp message to the phone number the user entered. If they can read the code and type it back, the number belongs to them.
It is used for the same things as SMS codes: confirming a phone number at sign-up, logging in without a password, and confirming a sensitive action such as changing account details.
How WhatsApp OTP verification works #
With WaForge the code is sent from your own WhatsApp number, the one you connect in the dashboard. The flow has four steps:
- The user enters their phone number on your site or app.
- Your server asks WaForge to send a code. WaForge sends "Your verification code is 123456. Valid for 5 minutes." on WhatsApp and returns a request ID.
- The user types the 6-digit code.
- Your server asks WaForge to check the code for that request ID. If the answer is verified, you mark the phone as verified.
Three rules keep the code safe. It expires after 5 minutes. Each code allows 5 attempts, and after that a new code must be sent. And WaForge stores codes only as one-way hashes, never as readable text.
WhatsApp OTP vs SMS OTP #
Setup. SMS codes need an SMS gateway, and in many countries a sender name approved by the carriers. WhatsApp OTP with WaForge needs neither: you scan a QR code once and the codes go out from your own number.
Who the code comes from. An SMS code often comes from a short number or a sender name the user has never seen. A WhatsApp code comes from your business number, in the same chat where the customer already talks to you.
Reach. This is the honest limit: the user must have WhatsApp on that number. Where almost everyone uses WhatsApp, that is rarely a problem. If part of your audience does not use it, keep SMS as a second option for those users.
Cost. SMS is usually billed per message, with a price that changes by country. WaForge plans include a monthly number of OTP codes, and only codes that WhatsApp accepted are counted. Checking a code is never counted. The numbers for each plan are on the pricing page.
Two ways to add it #
The API, for developers. Two calls from your server: one to send the code, one to verify it. It works from any language that can make an HTTPS request, and the WhatsApp OTP API guide has copy-ready examples in cURL, PHP, Laravel, Node.js and Python.
The widget, for any web page. If you do not want to build the form yourself, the WhatsApp OTP widget is a ready-made phone check: one div and one script tag. The visitor enters their number, receives the code, types it, and your page is told the phone is verified.
When the verified phone decides who gets access to an account, use the server-side API flow rather than the widget alone.
Good habits #
- Ask for the full international number, with the country code.
- Add your own limits per phone number and per visitor in front of the send call, so nobody can use your form to send codes to strangers.
- Keep your secret API key on your server, never in the page.
- Tell the user where to look: "We sent a code to your WhatsApp."
Start with one number #
Connect your WhatsApp number, create an API key and send your first code. The OTP API guide walks through it step by step, and the quota of each plan is on the pricing page.