Guide

How to add WhatsApp OTP verification to your website

To add WhatsApp OTP to a website: link a WhatsApp number to WAppOTP by QR, create an API key, call /v1/otp/send from your server when the user submits their phone, then call /v1/otp/verify with the code they enter and mark the phone as verified if valid is true.

This guide takes about 15 minutes. You need a WhatsApp account on a phone you control and a server that can make HTTPS requests. Examples use Node.js, PHP and Python; the REST API works from any language.

Updated

Step 1: Connect a WhatsApp number

  1. Sign up for a free WAppOTP account and create a project.
  2. In Connections, click to add a number and scan the QR code from WhatsApp → Linked Devices.
  3. Use a dedicated number for production so personal chats stay separate.

Step 2: Create an API key

In Developers, create a secret server key and keep it in an environment variable such as WAPPOTP_KEY. Never put a secret key in browser code; for browser-only sites use an origin-restricted publishable key instead.

Step 3: Send the code

Node.js
import { WhatsAppOtpClient } from "@whatsappotp/sdk";

const otp = new WhatsAppOtpClient({
  baseUrl: "https://api.wappotp.com",
  apiKey: process.env.WAPPOTP_KEY
});

// When the user submits their phone number:
const { verificationId } = await otp.sendOtp({ to: "+639171234567" });
// Store verificationId in the user's session.

Step 4: Verify the code

PHP
$otp = new WhatsAppOtp\Client('https://api.wappotp.com', getenv('WAPPOTP_KEY'));
$result = $otp->verifyOtp($_SESSION['verificationId'], $_POST['code']);

if ($result['valid']) {
    // Mark the phone number as verified.
}

Same flow in Python

Python
import os
from whatsappotp import Client

otp = Client("https://api.wappotp.com", os.environ["WAPPOTP_KEY"])
sent = otp.send_otp("+639171234567")
result = otp.verify_otp(sent["verificationId"], code_from_user)
if result["valid"]:
    ...  # phone verified

Security checklist

  • Always verify on the server; never trust a client-side "verified" flag.
  • Send an Idempotency-Key header so retries don't send duplicate codes.
  • Rely on WAppOTP's expiry, attempt limits and per-phone/per-IP rate limits, and add CAPTCHA on public sign-up forms.
  • Subscribe to the otp.verified webhook if other services need to know.
  • Enable fallback to SMS or email for users who don't receive WhatsApp.

Frequently asked questions

How long does a WhatsApp OTP stay valid?

A few minutes (the send response includes expiresIn in seconds). After that the user requests a new code.

What does the WhatsApp OTP message say?

It contains the code and how many minutes it is valid, so it reads clearly in the notification preview.

Can I test without a paid plan?

Yes. The free plan includes a monthly OTP allowance, and the docs include a live "Try it" console.

Start sending in minutes

Free plan, no card and no Meta approval. Link your WhatsApp number by QR and make your first API call today.

Create a free account

Related