Send WhatsApp OTP from Your App via API

With Tanotif, your app can send WhatsApp OTPs with a single API request. Your server still generates and verifies the OTP code; Tanotif delivers it to the user's number through a WhatsApp template with variables, then reports its status to your callback URL.

How sending WhatsApp OTP with Tanotif works

  1. Your server generates the code, for example 6 random digits, then stores the code hash, expiry time, and attempt limit.
  2. Your server calls the Tanotif API at POST /api/whatsapp/message/send with the OTP template's template_key and the code as a variable.
  3. Tanotif sends the WhatsApp message to the user's number through a queue.
  4. The user enters the code in your app, and your server verifies it.

Tanotif does not yet provide built-in endpoints for generating and verifying OTPs, so steps 1 and 4 remain your app's responsibility. The upside is that you are free to choose the code length, expiry time, and retry rules.

Example WhatsApp OTP template and request

Create a template in the dashboard with the Authentication category. The OTP message text is set by Meta so that it is consistent and secure, for example:

*{{1}}* is your verification code. For your security, do not share this code.

This template automatically includes a Copy code button, and you can add an expiry note of 1 to 90 minutes. Once Meta approves the template, send the code from your server:

curl -X POST https://tanotif.com/api/whatsapp/message/send \
  -H "Content-Type: application/json" \
  -H "access_key: YOUR_ACCESS_KEY" \
  -d '{
    "template_key": "TEMPLATE_OTP_WHATSAPP",
    "data": [
      { "recipient": "081234567890", "variables": ["482913"] }
    ]
  }'

A 201 response contains a transaction_key for each recipient. The status of each message (sent, delivered, read, or failed) is sent to your callback URL. Examples in Node.js, PHP, and Python are available in the documentation.

Best practices for sending WhatsApp OTP securely

  • Store a hash of the code, not the code itself, and delete it once it has been used or has expired.
  • Limit verification attempts and resend requests per number or per account, and add a cooldown to the resend button.
  • Keep the code expiry on your server consistent with the expiry note in the template.
  • Monitor callbacks. A failed status is your signal to offer a fallback verification method. A delivered status means the message has reached the user's device.

WhatsApp OTP costs

OTP messages are sent through the WhatsApp Business Platform (Cloud API) by Meta using your own WhatsApp Business number. Per-message fees for the authentication category are billed directly by Meta, separately from your Tanotif subscription. See the details on the Pricing page.

Frequently asked questions

Does Tanotif generate and verify OTP codes?

Not yet. Tanotif delivers OTP codes generated by your application. Code generation, expiry, attempt limits and verification stay on your server. Built-in generate and verify OTP endpoints are not available yet.

How do I send an OTP via WhatsApp with Tanotif?

Create an Authentication category template in the dashboard and wait for Meta's approval, then call POST /api/whatsapp/message/send with the template_key and the OTP code as the only value in variables.

How do I know the OTP was delivered?

Set a callback URL in the dashboard. Tanotif sends a POST for every message status change (sent, delivered, read or failed), including the transaction_key and message_id.

Can I write my own OTP message text?

No. For Authentication templates the message text is defined by Meta to keep it consistent and secure. You can choose the language, add a copy-code button and an expiry note of 1 to 90 minutes.

Are Tanotif WhatsApp OTPs sent through Meta's Cloud API?

Yes. Messages are sent through the WhatsApp Business Platform (Cloud API) by Meta using your own WhatsApp Business number. Authentication message fees are billed directly by Meta.