Your code. The customer’s next message
Send OTPs and cash-on-delivery confirmations on WhatsApp from your backend, and get every outcome back through signed webhooks.
Sample values are fictional. There is no sandbox or test-mode key: requests send real messages, so use a recipient you control.
const key = process.env.WATIFICATION_API_KEY;
const response = await fetch(
'https://api.watification.com/api/v1/otp/messages',
{
method: 'POST',
headers: {
Authorization: `Bearer ${key}`,
'Content-Type': 'application/json',
'Idempotency-Key': 'login-001',
},
body: JSON.stringify({
to: '+15555550123',
senderId: 'sender-id',
template: { name: 'login_code', language: 'en' },
code: '483920',
reference: 'login-001',
}),
},
);
const result = await response.json();
if (!response.ok) {
throw new Error(JSON.stringify(result));
}An accepted request returns 202 with status queued. That means accepted, not delivered, and it does not verify the code.
What you can do from code
Each operation has its own guide and API reference page.
OTP delivery
Send a code your app generated, with an approved Authentication template.
POST/api/v1/otp/messagesOTP guideCOD confirmations
Ask a customer to confirm a COD order. Read the answer by GET or webhook.
POST/api/v1/cod-confirmationsCOD guideRefusal checks
Ask whether a delivery was refused and collect the reason.
POST/api/v1/cod-confirmations/{id}/refusal-checkRefusal-check requirementsTemplates
List the approved templates for a WhatsApp number.
GET/api/v1/templates?channelConnectionId={id}Send messages guideSigned webhooks
Receive message and COD outcomes, signed with HMAC-SHA256.
HEADERWatification-Signature: t={timestamp},v1={hmac}Webhook handling
From zero to your first OTP
Four steps. You need a connected WhatsApp number and an approved Authentication template.
Open the full quickstartCreate an API key
Open Developers > API keys in the dashboard, name the key and copy it. The full key is shown once, so store it in your backend’s secret storage.
Find your sender and template
Under Developers > Overview, copy the Sender ID and the name and language of an approved template.
Send your first OTP
Post the request from the sample above with a new Idempotency-Key. A 202 response means the message is queued.
Add a webhook endpoint
Add a public HTTPS URL, copy the secret, choose Send test event, then View deliveries to see the result.
Verify before you trust
Every delivery carries a Watification-Signature header. Compute an HMAC-SHA256 over the timestamp, a dot and the raw request body, and compare it in constant time. Do not parse the JSON first.
The docs version of this function also checks the input. Delivery can repeat, so make your handler safe to run twice.
Webhook handlingimport { createHmac, timingSafeEqual } from 'node:crypto';
const SIGNATURE = /^t=(\d+),v1=([0-9a-f]{64})$/;
// rawBody: the unparsed request Buffer.
// signature: the Watification-Signature header.
export function verifyWebhook(rawBody, signature, secret) {
const match = SIGNATURE.exec(signature ?? '');
if (!match) throw new Error('Invalid signature header');
const [, t, v1] = match;
if (Math.abs(Date.now() / 1000 - Number(t)) > 300)
throw new Error('Stale signature');
const expected = createHmac('sha256', secret)
.update(`${t}.`)
.update(rawBody)
.digest();
if (!timingSafeEqual(expected, Buffer.from(v1, 'hex')))
throw new Error('Invalid signature');
return JSON.parse(rawBody.toString('utf8'));
}Know the rules before you send
Four limits that shape every integration. Each one is in the docs.
- 20 requests per second, per API keyOn a rate-limit error, wait for the time in Retry-After, then retry.
- Approved templates onlyOTP needs an Authentication template. COD needs a Utility template with the required quick-reply buttons.
- No sandboxEvery request sends a real WhatsApp message, so test with a number you control.
- Message fees are separateYour plan allowances apply, and Meta bills message fees on its own, at Meta's price with no markup.
Everything is in the docs
Create an API key and send your first OTP
Join now, connect your WhatsApp number and follow the four quickstart steps.