Send a WhatsApp text message through the API: the address, the fields and the 24-hour window
The reference for the text message address of ArabyBot's API: the fields, the maximum text length, the 24-hour window, an example request and response, and every refusal.
On this page 7
The short answer
With a POST request to the messages/text address carrying the recipient's number and the message text, up to 4,096 characters, with the send key in the header. Free text is accepted within 24 hours of the customer's last message, Meta's rule and not ours; outside that time you send an approved template. So it suits your system answering a customer who has just written to you.
Also asked as: «ابعت رسالة واتساب من الكود» · «ارسال رسالة واتساب api بدون قالب» · «ايه هي نافذة 24 ساعة في واتساب api» · «send whatsapp text message api» · «can i send a whatsapp message without a template»
The address and authentication
POST https://app.arabybot.com/api/v1/messages/text
Send the send key in the header Authorization: Bearer abk_… or X-Api-Key. You create the key on the «Developer tools» page of the ArabyBot dashboard, and it is shown once when it is made. The call goes from your server, so never put the key in a page a visitor opens or in a mobile app.
The fields
to(required) The recipient's number with its country code.text(required) The message text, up to 4,096 characters.from(optional) The number to send from when the account has more than one.reference(optional) A reference from your system, up to a hundred characters, that prevents sending twice.
An example request
cURL
curl -X POST https://app.arabybot.com/api/v1/messages/text \
-H "Authorization: Bearer abk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{ "to": "966501234567", "text": "Your order 1042 is ready for pickup.", "reference": "order-1042-ready" }' PHP
$ch = curl_init('https://app.arabybot.com/api/v1/messages/text');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer abk_YOUR_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'to' => '966501234567',
'text' => 'Your order 1042 is ready for pickup.',
'reference' => 'order-1042-ready',
]),
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch); Python
import requests
r = requests.post(
'https://app.arabybot.com/api/v1/messages/text',
headers={
"Authorization": "Bearer abk_YOUR_KEY",
},
json={
"to": "966501234567",
"text": "Your order 1042 is ready for pickup.",
"reference": "order-1042-ready",
},
timeout=30,
)
print(r.status_code, r.json()) Node.js
// Node.js 18+
const r = await fetch('https://app.arabybot.com/api/v1/messages/text', {
method: 'POST',
headers: {"Authorization": "Bearer abk_YOUR_KEY", "Content-Type": "application/json"},
body: JSON.stringify({
"to": "966501234567",
"text": "Your order 1042 is ready for pickup.",
"reference": "order-1042-ready"
}),
});
console.log(r.status, await r.json());
The response
200
{ "success": true, "id": 513, "message_id": "wamid.…", "status": "accepted", "to": "966501234567" } - The response has the same shape the template address returns: the message id and its status.
The refusals
Every refusal comes back as JSON with "success": false, an error_code, and a message in Arabic in message and in English in message_en:
- 422
NO_TEXT: The message was not put intext. - 422
TEXT_TOO_LONG: The text is longer than 4,096 characters. - 400
BAD_JSON: The request body is not valid JSON. - 402
MONTHLY_LIMIT: The account reached its plan's monthly sending limit. - 409
NO_NUMBER: No WhatsApp number is connected to the account, or the number infromis not one of its numbers. - 422
BAD_PHONE: The recipient number is not valid; write it with the country code. - 422
META_REFUSED: WhatsApp refused the message; Meta's code is inmeta_codeand its text inmeta_message. - 503
TRY_AGAIN: WhatsApp is busy or the message could not be recorded for a moment; repeat the same request with the same reference after a minute. - 401
NO_KEY: The key was not sent in the header. - 401
INVALID_KEY: The key is wrong or was revoked; create one under «Developer tools». - 402
SUBSCRIPTION_EXPIRED: The account's subscription has ended. - 403
NOT_IN_PLAN: The account's plan does not include «Developer tools». - 429: The key passed 600 requests a minute; wait the time written in the
Retry-Afterheader. - 500
SERVER: A failure on our side; try again, and tell support if it repeats.
The limits
600 requests a minute per key. Whatever exceeds the pace WhatsApp accepts for your number waits in a queue, comes back with the status queued, then goes out by itself, so no message is lost. Meta's own limits on your number, how many people you may start conversations with in a day and the quality rating, stay as they are behind this API.
The full send API reference · All APIs for developers
Frequently asked questions
When does WhatsApp refuse the text message?
When 24 hours have passed since the customer's last message. The request comes back with the code META_REFUSED and Meta's own code and text. Outside that time send an approved template from the template address.
What is the maximum message length?
4,096 characters. Anything longer is refused with the code TEXT_TOO_LONG before it reaches WhatsApp.
Read next
Try the agent before you pay anything
The agent that will answer your customers is the one answering you now: ask it from the chat button here or on WhatsApp. Your account is free with no credit card, and the free trial on your own number or page is activated after you contact our team on customer-service WhatsApp.