Send OTP codes on WhatsApp
Many people check WhatsApp before SMS, which makes it a natural channel for login codes. There are two ways to send them, and the right one depends on how many you send.
- 1User asks for a code
- 2Your server creates the OTP
- 3Wabot API sends it on WhatsApp
- 4User types the code
Ways to send an OTP
| SMS | Official WhatsApp API | Wabot | |
|---|---|---|---|
| Setup in India | DLT sender and template registration | Meta business verification and an approved template | Link your number with a QR scan |
| Cost | Per SMS | Per authentication message | No per-message fee |
| Copy-code button | No | Yes | No |
| Sent from | A registered sender ID | Your verified business number | Your own WhatsApp number |
| Best for | Users without WhatsApp | High-volume logins and payments | Low-volume codes, internal tools, testing |
Send an OTP from Python
Create a random six-digit code, store it with an expiry, and send it with one call to the Wabot API.
import secrets, time, requests
API_KEY = "YOUR_KEY"
MY_NUMBER = "919812345678"
codes = {} # phone -> (code, expires_at); use your database in production
def send_otp(phone):
code = f"{secrets.randbelow(1_000_000):06d}"
codes[phone] = (code, time.time() + 600)
requests.post(
"https://api.wabot.online/send",
headers={"X-API-Key": API_KEY},
json={"number": MY_NUMBER, "to": phone, "isGroup": "N",
"message": f"{code} is your Acme login code. It expires in 10 minutes. Do not share it."},
timeout=30,
).raise_for_status()
def check_otp(phone, entered):
code, expires = codes.pop(phone, (None, 0)) # single use
return code == entered and time.time() < expires- Related:
- Build a WhatsApp bot in Python
Start a 7-day free trial and send your first code in minutes.
Start free trialOTP message templates
Login code
[code] is your [App] login code. It expires in 10 minutes. Don’t share it with anyone.
Verify your number
Your [App] verification code is [code]. If you didn’t ask for it, ignore this message.
Confirm an action
Use [code] to confirm [action] on [App]. [App] will never call you to ask for this code.
When to use the official API instead
Wabot sends from a regular WhatsApp number, so WhatsApp’s normal limits and spam checks apply. If you send thousands of codes a day, or codes that approve payments, use WhatsApp’s official authentication templates, which are built for that volume and add a copy-code button.
Send your first OTP today
Link a number, copy your API key and send codes from your own WhatsApp. 7-day free trial, no card.
7-day free trial · No card · Your own WhatsApp number
Frequently asked questions
Can I send OTPs on WhatsApp for free?
Free for 7 days during the trial, which sends up to 1,000 messages a day per number. After that, Wabot has no per-message fee on any plan.
Is it OK to send OTPs from a normal WhatsApp number?
Sending codes that people asked for is normal messaging. At high volume it can trigger WhatsApp’s spam limits, so use the official API for large-scale logins.
How long should an OTP last?
Five to ten minutes is common. Make each code single-use and limit wrong attempts.
More from Wabot
- WhatsApp DP viewer
- WhatsApp number checker
- WhatsApp text formatter
- WhatsApp chat widget
- Avoid a WhatsApp ban
- WhatsApp Business Web
- Message many WhatsApp groups
- Tag everyone in a group
- WhatsApp proxy
- Waiting for this message
- WhatsApp read receipts
- WhatsApp bot in Python
- WhatsApp introduction messages
- Formal WhatsApp messages
- WhatsApp quick replies
- WhatsApp report samples
- Turn off blue ticks
- WhatsApp vs Business
- Free WhatsApp tools
- WhatsApp menu card