🔐 What you’ll build
You’ll send a one-time verification code (OTP) to a customer over WhatsApp, using an authentication template and the Vambe API, and follow its delivery.Prerequisites
- ✅ Connected WhatsApp Business API
- ✅ An approved authentication template on the number you send from
- ✅ Valid Vambe API key from the developers page
Getting an authentication template
You can create it in either place:- In Vambe: Templates → create a template with the Authentication category. Choose whether to add the security recommendation (“For your security, do not share this code.”) and how many minutes the code is valid.
- In WhatsApp Manager (Meta): create it there and sync your templates in Vambe. Vambe imports it with its security recommendation, expiration and button type, ready to send.
GET /api/public/templates.
Choose an endpoint
The code is never rewritten or extracted by AI. The structured endpoint sends
variables[0] as is; the smart endpoints only trim spaces around it (" 482913 " is sent as 482913), so store the trimmed value if you compare it later.
Send a code
- Structured
- Smart
- Bulk
The phone goes in the path (country code, digits only) and the code is the only variable:Response (201):
Optional parameters
from-phone-number(query): the number to send from, when you have more than one, written exactly as it is registered in Vambe (digits with country code, e.g.56211111111).- Structured endpoint: if the number isn’t one the template is approved on, the request fails with
Template cant be sent from this phone number. - Smart endpoints: if it doesn’t match any WhatsApp number of your account (mistyped, or formatted differently), the request fails with
from-phone-number … is not a WhatsApp number of this account. If it’s one of your numbers but the template isn’t approved on it, it fails withTemplate is not valid for this channel. Either way nothing is sent from another number.
- Structured endpoint: if the number isn’t one the template is approved on, the request fails with
stage(query, smart endpoints) orstageId(body, structured endpoint): the pipeline stage to put the contact in.
Track delivery
For single sends (structured and smart), use themessageId from the response with GET /api/public/whatsapp/message/status/. It starts as accepted and moves through sent, delivered and read, or ends in failed with WhatsApp’s reason. A 404 right after sending means the message is still being registered: retry after a few seconds.
Bulk sends don’t return message IDs. If you need to follow each code, send them one by one.
Rules to keep in mind
Codes are up to 15 characters
Codes are up to 15 characters
That is WhatsApp’s limit for authentication templates. Longer codes are rejected with
OTP code must be 15 characters or less.Repeating a request does not resend the code
Repeating a request does not resend the code
The smart endpoints are idempotent: a request identical to a previous one within 10 minutes counts as one send and returns the original response. “Identical” means the same template, the whole body,
stage and from-phone-number:- Retrying the exact same request sends nothing new, so to resend a code to the same phone inside that window, generate a new code.
- Any other difference, such as a timestamp or request ID in the body, a different
stageor anotherfrom-phone-number, makes it a new request and sends the code again. If you rely on this protection against duplicate sends, retry with exactly the same body.
The recipient needs a phone number
The recipient needs a phone number
WhatsApp only delivers authentication templates to phone numbers. A contact Vambe knows only by its WhatsApp username (BSUID), without a phone, can’t receive one.
Treat the code as a secret
Treat the code as a secret
Generate a new random code for every attempt, keep its expiration short (it should match the minutes set on the template) and never log it in plain text on your side.
Error reference
Next steps
Send template messages
Send your other templates with variables.
Create templates
Design and submit templates for approval.
