Deliver one-time codes and verification messages through Direct Send.
Authentication Direct Send
Summary
Deliver one-time codes and verification messages through Direct Send.
Prerequisites
- Authorization: Bearer w91_live_xxx
- Content-Type: application/json for JSON requests
Set category to authentication for verification codes and similar authentication content. Authentication Direct Send is the most tightly restricted category: it accepts text messages only, uses a shorter time-to-live range, and cannot use a business-named template.
Warning
Authentication category access must be granted by Meta for the WABA. A valid Whats91 token is not sufficient.
| Constraint | Value |
|---|---|
| Allowed message type | text only |
| TTL range | 30 to 900 seconds |
| Body length | Maximum 1024 characters |
| Business-named template | Not supported; returns DIRECT_SEND_TEMPLATE_NAME_UTILITY_ONLY |
/api/v3/chatSend an authentication Direct Send message.
curl -X POST "https://graph.whats91.com/api/v3/chat" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"senderId": "919999999999",
"to": "918888888888",
"type": "text",
"text": "Your verification code is 123456.",
"category": "authentication",
"ttlSeconds": 300
}'{
"success": true,
"message": "Message accepted by Meta",
"data": {
"messageId": "wamid.xxxxx",
"status": "accepted",
"messageType": "text",
"directSend": {
"requested": true,
"category": "authentication",
"ttlSeconds": 300,
"templateName": null
}
},
"metadata": {
"apiVersion": "v3",
"requestId": "request-uid",
"processingTimeMs": 118
}
}Tip
Match the TTL to the lifetime of the code you are sending. A 300-second TTL on a five-minute code stops a delayed delivery arriving after the code has already expired.
SDK Examples
Use these examples as starting points for server-side implementations.
curl -X POST "https://graph.whats91.com/api/v3/chat" \
-H "Authorization: Bearer w91_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"senderId": "919999999999",
"to": "918888888888",
"type": "text",
"text": "Your verification code is 123456.",
"category": "authentication",
"ttlSeconds": 300
}'const response = await fetch("https://graph.whats91.com/api/v3/chat", {
method: "POST",
headers: {
"Authorization": "Bearer w91_live_xxx",
"Content-Type": "application/json"
},
body: JSON.stringify({
"senderId": "919999999999",
"to": "918888888888",
"type": "text",
"text": "Your verification code is 123456.",
"category": "authentication",
"ttlSeconds": 300
})
});
const data = await response.json();
console.log(data);$ch = curl_init("https://graph.whats91.com/api/v3/chat");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer w91_live_xxx",
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => json_encode([
"senderId" => "919999999999",
"to" => "918888888888",
"type" => "text",
"text" => "Your verification code is 123456.",
"category" => "authentication",
"ttlSeconds" => 300
])
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;import requests
response = requests.request(
"POST",
"https://graph.whats91.com/api/v3/chat",
headers={
"Authorization": "Bearer w91_live_xxx",
"Content-Type": "application/json",
},
json={
"senderId": "919999999999",
"to": "918888888888",
"type": "text",
"text": "Your verification code is 123456.",
"category": "authentication",
"ttlSeconds": 300
}
)
print(response.json())using System.Text;
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer w91_live_xxx");
var request = new HttpRequestMessage(HttpMethod.Post, "https://graph.whats91.com/api/v3/chat");
request.Content = new StringContent(
"""
{
"senderId": "919999999999",
"to": "918888888888",
"type": "text",
"text": "Your verification code is 123456.",
"category": "authentication",
"ttlSeconds": 300
}
""",
Encoding.UTF8,
"application/json"
);
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());