توثيق الربط المبرمج (API)
دليل المطورين لربط الأنظمة الخارجية مع منصة واتس ناو وإرسال الرسائل برمجياً.
المصادقة (Authentication)
تتطلب جميع الطلبات تمرير مفاتيح المصادقة الخاصة بحسابك في الترويسة (Headers).
X-Header-App-Id: YOUR_APP_ID
X-Header-Authorization: YOUR_TOKEN
ملاحظة: يمكنك الحصول على المفاتيح الخاصة بك من لوحة التحكم > الإعدادات > الربط المبرمج.
إرسال رسالة (Send Message)
إرسال رسالة نصية أو وسائط إلى جهة اتصال.
POST
https://app.wainow.com/api/v1/send-messageجسم الطلب (Body Params)
| Parameter | Type | Required | Description |
|---|---|---|---|
| phone | string | Yes | Recipient's phone number in international format (e.g. 966500000000) |
| body | string | Conditional | Text message body (Required if media_src is not provided) |
| media_src | string | Optional | Direct URL to media file (Image) |
cURL Example
curl -X POST https://app.wainow.com/api/v1/send-message \
-H "X-Header-App-Id: YOUR_APP_ID" \
-H "X-Header-Authorization: YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"phone": "966500000000",
"body": "مرحبا بك في متجرنا"
}'استجابة ناجحة (Success Response)
{
"success": true,
"message_id": "wamid.HBgMOTY2...",
"status": "sent"
}إرسال قالب معتمد (Send Template)
إرسال قالب واتساب معتمد مع متغيراته — مثل رمز التحقق (OTP). يصل الرد فوراً مع رقم الرسالة.
POST
https://app.wainow.com/api/v1/send-templateجسم الطلب (Body Params)
| Parameter | Type | Required | Description |
|---|---|---|---|
| phone | string | Yes | Recipient in international format (e.g. 966500000000) |
| template_name | string | Conditional | Approved template name (required if template_id is not provided) |
| template_id | string | Conditional | Template uuid from GET /api/v1/whats_app_templates, or its Meta template id (digits, as shown in WhatsApp Manager) |
| language | string | Optional | Template language (e.g. ar, en_US) — required when the name exists in more than one language |
| code | string | Optional | OTP shortcut: fills {{1}} (and the copy-code button of an Authentication template) |
| variables | array | object | Optional | Body values in order: ["v1","v2"] or {"1":"v1","2":"v2"} |
| header_text | string | Optional | Value of the header {{1}}, when the header has a variable |
| header_media_url | string | Optional | https URL that replaces the image/video/document header for this send |
| buttons | object | Optional | Button values by index, e.g. {"0":"ORDER-42"} for a URL button with {{1}} |
| whatsapp_config_id | string | Optional | Number to send from: its uuid or Meta phone_number_id (default: the number a Meta template id belongs to, else the primary number) |
مثال: رمز تحقق (OTP)
curl -X POST https://app.wainow.com/api/v1/send-template \
-H "X-Header-App-Id: YOUR_APP_ID" \
-H "X-Header-Authorization: YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"phone": "966500000000",
"template_name": "otp_login",
"language": "ar",
"code": "482913"
}'مع قالب من فئة Authentication يملأ code المتغير {{1}} وزر نسخ الرمز معاً. الرمز 15 خانة كحد أقصى.
مثال: قالب بعدة متغيرات
{
"phone": "966500000000",
"template_name": "order_shipped",
"language": "ar",
"variables": ["محمد", "ORD-1042"],
"buttons": { "0": "ORD-1042" }
}استجابة ناجحة (Success Response)
{
"success": true,
"message_id": "wamid.HBgMOTY2...",
"status": "sent",
"template": { "id": "…", "name": "otp_login", "language": "ar" }
}