WhatsApp OTP & Verification

Use WhatsApp as an additional channel for one-time passwords and account verification where your users already have WhatsApp. Generate and check the code in your own backend, and send it with one REST call.

Why Use WhatsApp for OTP & Verification?

Discover the advantages of using WhatsApp as your communication channel

One-Time Passwords

Send secure OTP codes for login verification, transaction approval, and sensitive account actions with automatic expiry.

Two-Factor Authentication

Add an extra layer of security with WhatsApp-based 2FA that users prefer over traditional SMS verification.

Account Verification

Verify new user accounts during registration by sending confirmation codes directly to their WhatsApp number.

Phone Number Verification

Confirm phone number ownership by sending verification codes through WhatsApp, ensuring the number is active and reachable.

Encrypted in Transit

WhatsApp encrypts messages between devices. Treat the code as sensitive anyway: keep it short-lived, single-use and never log it.

Useful Where SMS Is Costly or Slow

Messages usually arrive within seconds when the phone is online, but delivery is not guaranteed. Keep a fallback such as email or SMS for users who do not receive the code.

How It Works with QuackAPI

Get up and running in three simple steps

1

Generate OTP in Your Backend

Generate a secure one-time password in your application backend and store it with an expiry time for validation.

2

Send OTP via QuackAPI API

Call our REST API to send the code to the user's WhatsApp number in a short, clear message.

3

Verify the Code

When the user enters the code, validate it against your stored OTP, check it has not expired, and invalidate it after one use. Rate limit attempts and resends.

Implementation Example

See how easy it is to implement with just a few lines of code

send-otp.js
import { randomInt } from "node:crypto";

// Use a cryptographically secure random number, never Math.random(), for codes.
const otp = randomInt(100000, 1000000);

const response = await fetch(
  "https://quackapi.com/v1/messages/chat",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-api-key": "wa_your_api_key_here"
    },
    body: JSON.stringify({
      deviceId: 1,
      to: "923001234567",
      body: `Your QuackAPI verification code is: ${otp}. This code expires in 5 minutes. Do not share this code.`
    })
  }
);

const result = await response.json();
console.log(result); // { success: true, messageId: 43, status: "queued" }

Ready to Get Started?

Create your free QuackAPI account and start sending WhatsApp messages in minutes. No credit card required.