Send Text Message

إرسال رسالة نصية عبر WhatsApp Cloud API.

POST/api/whatsapp/send/text🔒 Bearer JWT

Body

الحقلالنوعالوصف
to*stringرقم المستلم بصيغة دولية بدون +. مثال: 966500000000
text*stringنص الرسالة.
agentIdstringمعرّف الوكيل المُرسِل (للتتبّع).
agentNamestringاسم الوكيل المُرسِل (يظهر في الواجهة).
replyToIdstringمعرّف رسالة الرد عليها (quoted reply).

مثال طلب

curl -X POST https://operix.operixdigital.com/api/whatsapp/send/text \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "966500000000",
    "text": "مرحباً! كيف يمكنني مساعدتك؟",
    "agentId": "rashid",
    "agentName": "راشد"
  }'

مثال استجابة

{
  "messaging_product": "whatsapp",
  "contacts": [{ "input": "966500000000", "wa_id": "966500000000" }],
  "messages": [{ "id": "wamid.HBgL..." }]
}

الاستجابة من Meta مباشرة. الـ wamid يُحفَظ في DB أيضاً للـ tracking.

قاعدة الـ 24 ساعة
تستطيع إرسال نص حر فقط خلال 24 ساعة من آخر رسالة من العميل. خارجها استخدم POST /send/template.

Errors

الكودالرسالةالسبب
401Unauthorized
500Invalid OAuth access tokenالـ WHATSAPP_ACCESS_TOKEN خاطئ أو منتهي.
500Recipient phone number not in allowed listرقم اختباري — أضف الرقم لـ Meta أو فعّل production phone.