Skip to main content

🔐 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.
Authentication templates are the WhatsApp format for login codes, account verification and password resets. WhatsApp renders the copy, adds a Copy code button and, for one-tap and zero-tap templates, can autofill the code in your Android app.

Prerequisites

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.
Then copy its ID from GET /api/public/templates.
An authentication template only carries the code. WhatsApp writes the rest of the copy, so you can’t add your own text, links or media to it.

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

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 with Template is not valid for this channel. Either way nothing is sent from another number.
  • stage (query, smart endpoints) or stageId (body, structured endpoint): the pipeline stage to put the contact in.

Track delivery

For single sends (structured and smart), use the messageId 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

That is WhatsApp’s limit for authentication templates. Longer codes are rejected with OTP code must be 15 characters or less.
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 stage or another from-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 structured endpoint is not idempotent: every call sends a message.
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.
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.