مرجع الـ API
WHMCS Webhook (قديم)
POST /api/v1/whmcs-webhook — نقطة استقبال أحداث WHMCS القديمة. استخدم وحدة WHMCS الجديدة بدلًا منها.
POST
/api/v1/whmcs-webhookتستقبل بيانات حدث من WHMCS، وترسل إشعار واتساب إلى العميل من الرقم الافتراضي المتصل في حسابك.
الترويسات
| الترويسة | القيمة |
|---|---|
X-API-Key |
مفتاحك (أو Authorization: Bearer <key>) |
Content-Type |
application/json |
جسم الطلب
| الحقل | النوع | إلزامي | الوصف |
|---|---|---|---|
action |
string | نعم | InvoiceCreated أو InvoicePaid أو TicketOpen |
phone |
string | نعم | رقم العميل (يُقبل phonenumber بديلًا) |
client_name |
string | لا | اسم العميل |
invoiceid |
string | مع أحداث الفواتير | رقم الفاتورة |
amount |
string | لا | مبلغ الفاتورة |
currency |
string | لا | العملة |
due_date |
string | لا | تاريخ الاستحقاق |
invoice_url |
string | لا | رابط الفاتورة |
ticketid |
string | مع TicketOpen |
رقم التذكرة |
subject |
string | لا | موضوع التذكرة |
ticket_url |
string | لا | رابط التذكرة |
lang |
string | لا | لغة الرسالة: ar (الافتراضي) أو en (تُقبل english وen_US …) |
تُقص القيم النصية إلى 500 حرف.
الاستجابة
200 OK
JSON
{ "success": true, "sent": true, "message_id": "wamid.HBgM..." }
عندما لا يوجد ما يُرسل (لا رقم هاتف، أو قيمة action غير مدعومة) تكون الاستجابة 200 مع "sent": false وسبب في reason. أما فشل الإرسال فيُعاد خطأً (أدناه) لا نجاحًا.
الأخطاء
| الحالة | الاستجابة |
|---|---|
401 |
{"error": "Invalid API key"} |
403 |
المستلم ألغى اشتراكه / محظور، أو حد الباقة (code)، أو plan_no_api / permission_denied |
422 |
{"success": false, "sent": false, "code": "outside_window", ...} — العميل خارج نافذة الـ 24 ساعة |
429 |
{"error": "Too many requests", ...} |
502 |
{"success": false, "sent": false, "code": "send_failed" | "no_instance", "error": "..."} |
أمثلة
curl -X POST https://waabek.com/api/v1/whmcs-webhook \
-H "X-API-Key: $WABEK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"action": "InvoicePaid",
"invoiceid": "1042",
"phone": "966500000000",
"client_name": "Sara Ahmed",
"amount": "99.00",
"currency": "USD"
}'
await fetch("https://waabek.com/api/v1/whmcs-webhook", {
method: "POST",
headers: {
"X-API-Key": process.env.WABEK_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
action: "InvoicePaid",
invoiceid: "1042",
phone: "966500000000",
client_name: "Sara Ahmed",
amount: "99.00",
currency: "USD",
}),
});
<?php
// Example WHMCS hook (includes/hooks/wabek_invoice_paid.php)
add_hook('InvoicePaid', 1, function ($vars) {
$invoice = localAPI('GetInvoice', ['invoiceid' => $vars['invoiceid']]);
$client = localAPI('GetClientsDetails', ['clientid' => $invoice['userid']]);
$ch = curl_init('https://waabek.com/api/v1/whmcs-webhook');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('WABEK_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'action' => 'InvoicePaid',
'invoiceid' => (string) $vars['invoiceid'],
'phone' => preg_replace('/\D/', '', $client['phonenumberformatted'] ?? $client['phonenumber']),
'client_name' => trim($client['firstname'] . ' ' . $client['lastname']),
'amount' => $invoice['total'],
'currency' => $invoice['currencycode'] ?? '',
]),
]);
curl_exec($ch);
curl_close($ch);
});
import os
import requests
requests.post(
"https://waabek.com/api/v1/whmcs-webhook",
headers={"X-API-Key": os.environ["WABEK_API_KEY"]},
json={
"action": "InvoicePaid",
"invoiceid": "1042",
"phone": "966500000000",
"client_name": "Sara Ahmed",
"amount": "99.00",
"currency": "USD",
},
timeout=15,
)