ستورد جهات الاتصال مع موافقتهم، صاوب template تسويقي، صيفطو للناس اللي وافقو، تابع النتيجة لكل رقم، ودير متابعة مع اللي جاوبو أو ضغطو على الروابط.
كتستورد لائحة الزبناء ديالك، Meta كتوافق على template تسويقي وحد، وطلب API وحد لكل دفعة كيصيفطو. كل زبون كيوصلو رسالة WhatsApp من اسم شركتك: "مرحبا John، التخفيض ديال الشتا كيبدا اليوم: 20% على كلشي حتى الأحد." وإلا بغا ما يتوصلش بعروض، كيكتب STOP وما كيتوصلش بحتى واحدة أخرى.
app2email كيصيفط غير للناس اللي عندهم الحق يتوصلو بيه. الأرقام اللي فـ لائحة Do Not Call كيتجاوزوهم، وإلا كان قاعدة opt-in مفعّلة، كيتجاوزو حتى الناس اللي ما عندهمش سجل opt-in. كتوصلك النتيجة لكل رقم (تم القبول، توصّل، تقرا، جاوب، فشل، تجاوز) كأحداث webhook، من API، كملف CSV، وفي صفحة تقرير الحملة فسجل النشاط (Activity Log).
GET /compliance/export.csv كيجمع الثلاثة فملف وحد.403 whatsapp_payment_issue).| الصلاحية | شنو كتدير بيها فهاد الدليل |
|---|---|
contacts:manage | استيراد جهات الاتصال، تسجيل الموافقة، حفظ الشرائح (POST /contacts/import، POST /contacts/{identity}/consent، POST /segments) |
settings:manage | تفعيل قاعدة opt-in وتسجيل الموافقات (PUT /settings/optin، POST /optins) |
dnc:manage | لائحة Do Not Call (POST /donotcall، GET /donotcall) وتصدير الامتثال |
templates:manage | صنع الـ template التسويقي (POST /templates) |
messages:send | صيفط الـ broadcast، إلغاؤه، وإرسال متابعة (POST /messages، POST /broadcasts/{code}/cancel، POST /broadcasts/{code}/retarget) |
messages:read | حالة الـ template، جهات الشريحة، نتائج الـ broadcast، النقرات، الاستعمال، صحة الرقم |
webhooks:manage | زيد الـ webhook اللي كيستقبل الأحداث (POST /webhooks) |
المفتاح Default (اللي تصنع قبل ما المفاتيح كيكون عندها صلاحيات) عندو غير messages:send، messages:read، dnc:manage وwebhooks:manage. صنع مفتاح بالصلاحيات اللي فوق، ولا بـ Full access (*). GET /v1/YOUR_NUMBER/me كيبين صلاحيات المفتاح اللي عندك.
جرّب الأول. sandbox key على رقمك انتا (مفتاح فيه علامة sandbox، فصفحة مفاتيح API) كيدير كل تشيك على الصيفط بشكل حقيقي وما كيصيفط والو لـ WhatsApp. الجواب فيه "sandbox": true، وmessage ids كتبدا بـ wamid.SANDBOX.، وأحداث message.status كتوصل.
حاضر: استيراد جهات الاتصال، حفظ الشرائح، الـ opt-ins ولائحة Do Not Call كيبدلو بياناتك الحقيقية، حتى بـ sandbox key. صنع الـ templates، وPUT /settings/optin وretarget (ما عدا dry_run) كيجاوبو 403 sandbox_key.
بلا حساب خالص، POST https://api.app2email.com/v1/account/sandbox (بلا key، بلا body)، ولا الأداة create_sandbox ديال سيرفر Management MCP، كيعطيك instant sandbox key لرقم التجربة 12025550100. عندو template MARKETING اسمو weekend_offer، والزبون المزيف 12025550104 كيكتب STOP: كتوصلك contact.opted_out، والـ template التسويقي الجاي ليه كيجاوب 403 recipient_opted_out. هاد المفتاح عندو غير شوية طلبات (GET /templates، POST /messages، GET /events وشي حاجات أخرى)، فطلبات الجهات والـ broadcast ديال هاد الدليل خاصها مفتاح على رقمك انتا. شوف Sandbox.
صيفط ملف CSV فيه سطر العناوين. الأعمدة اللي app2email كيعرفها هي phone (ولا identity، number، mobile)، name (ولا first_name + last_name)، tags (مفصولة بـ |)، consent_marketing (yes ولا no)، consent_source، consent_text، consent_evidence، consent_at وsource. كل عمود آخر كيولي حقل مخصص. الأرقام كيكونو بكود الدولة أولا، أرقام فقط. حتى 5000 سطر فكل طلب.
phone,name,first_name,tags,consent_marketing,consent_source,consent_text,consent_evidence,consent_at
61412345678,John Smith,John,vip|newsletter,yes,web form,"Yes, send me offers on WhatsApp",https://example.com/forms/123,2026-10-01T09:00:00Z
61498765432,Mary Jones,Mary,newsletter,yes,checkout,"Yes, send me offers on WhatsApp",order 5521,2026-10-12T02:30:00Zcurl -s https://api.app2email.com/v1/YOUR_NUMBER/contacts/import \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: text/csv" \
--data-binary @contacts.csvimport { readFile } from "node:fs/promises";
const res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/contacts/import", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.A2E_KEY}`,
"Content-Type": "text/csv",
},
body: await readFile("contacts.csv"),
});
console.log(res.status, await res.json());import os, requests
with open("contacts.csv", "rb") as f:
res = requests.post(
"https://api.app2email.com/v1/YOUR_NUMBER/contacts/import",
headers={
"Authorization": f"Bearer {os.environ['A2E_KEY']}",
"Content-Type": "text/csv",
},
data=f,
)
print(res.status_code, res.json())شنو كترجع: شحال من سطر تسجل، والأسطر اللي تتجاوزو مع السبب. الباقي تسجل.
{
"success": true,
"request_id": "i2gka",
"rows": 120,
"saved": 118,
"created": 90,
"updated": 28,
"skipped": 2,
"errors": [
{
"row": 7,
"problem": "'0412' must be a WhatsApp number with country code, digits only (8 to 15 digits), or a business-scoped user id like 61.AbC123"
}
],
"note": "Rows with a problem were skipped (the first 50 are listed); the rest were saved."
}نفس الطلب كيقبل application/json: لائحة جهات بنفس الشكل ديال POST /contacts. ملي شي واحد يوافق من بعد (فورم ديال الويب، خانة فالخلاص)، سجل ذلك عند الجهة مع الدليل ديالو:
curl -s https://api.app2email.com/v1/YOUR_NUMBER/contacts/61412345678/consent \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: application/json" \
-d '{
"marketing": true,
"source": "web form",
"text": "Yes, send me offers on WhatsApp",
"evidence": "https://example.com/forms/123"
}'سجّل غير الموافقة اللي عندك فالحقيقة.
قاعدة opt-in هي إعداد ديال الرقم. ملي تكون مفعّلة، الـ templates من نوع MARKETING كيتصيفطو غير للأرقام اللي عندها سجل opt-in. الباقيين كيتجاوزو بسبب recipient_not_opted_in. الـ templates ديال Utility والردود ما كيتأثروش. هي مطفية بشكل افتراضي.
سجلات opt-in كتتحفظ بعيدة على الموافقة ديال الجهة، فسجل كل شي واحد وافق هنا كذلك. حتى 1000 فكل طلب، الكل ولا والو.
curl -s https://api.app2email.com/v1/YOUR_NUMBER/optins \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: application/json" \
-d '{
"numbers": [
{ "number": "61412345678", "name": "John", "source": "web form", "note": "ticked the box", "at": "2026-10-01T09:00:00Z" },
{ "number": "61498765432", "name": "Mary", "source": "checkout", "at": "2026-10-12T02:30:00Z" }
]
}'
curl -s -X PUT https://api.app2email.com/v1/YOUR_NUMBER/settings/optin \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: application/json" \
-d '{ "require_optin_for_marketing": true }'const headers = {
Authorization: `Bearer ${process.env.A2E_KEY}`,
"Content-Type": "application/json",
};
await fetch("https://api.app2email.com/v1/YOUR_NUMBER/optins", {
method: "POST",
headers,
body: JSON.stringify({
numbers: [
{ number: "61412345678", name: "John", source: "web form", note: "ticked the box", at: "2026-10-01T09:00:00Z" },
{ number: "61498765432", name: "Mary", source: "checkout", at: "2026-10-12T02:30:00Z" },
],
}),
});
await fetch("https://api.app2email.com/v1/YOUR_NUMBER/settings/optin", {
method: "PUT",
headers,
body: JSON.stringify({ require_optin_for_marketing: true }),
});headers = {"Authorization": f"Bearer {os.environ['A2E_KEY']}"}
requests.post(
"https://api.app2email.com/v1/YOUR_NUMBER/optins",
headers=headers,
json={
"numbers": [
{"number": "61412345678", "name": "John", "source": "web form", "note": "ticked the box", "at": "2026-10-01T09:00:00Z"},
{"number": "61498765432", "name": "Mary", "source": "checkout", "at": "2026-10-12T02:30:00Z"},
]
},
)
requests.put(
"https://api.app2email.com/v1/YOUR_NUMBER/settings/optin",
headers=headers,
json={"require_optin_for_marketing": True},
)شنو كترجع: {"success": true, "request_id": "o9ahv", "saved": 2} للـ opt-ins، و{"require_optin_for_marketing": true} للإعداد. GET /v1/YOUR_NUMBER/optins?number=61412345678 كيتشيك على رقم وحد (opted_in true ولا false).
الـ templates التسويقية ما كيتصيفطوش لرقم فلائحة Do Not Call، مهما كانت سجلات opt-in كتقول. الناس اللي كيكتبو STOP كيتزادو من app2email بوحدو. زيد اللي تيخرجو فبلاصة أخرى (الكاشي، لائحة الإيميل ديالك، مكالمة تليفونية). حتى 1000 رقم، الكل ولا والو.
curl -s https://api.app2email.com/v1/YOUR_NUMBER/donotcall \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: application/json" \
-d '{
"numbers": [
"61400111222",
{ "number": "61400333444", "name": "Sam", "note": "Unsubscribed in our CRM" }
]
}'const res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/donotcall", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.A2E_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
numbers: ["61400111222", { number: "61400333444", name: "Sam", note: "Unsubscribed in our CRM" }],
}),
});
console.log(await res.json());res = requests.post(
"https://api.app2email.com/v1/YOUR_NUMBER/donotcall",
headers={"Authorization": f"Bearer {os.environ['A2E_KEY']}"},
json={"numbers": ["61400111222", {"number": "61400333444", "name": "Sam", "note": "Unsubscribed in our CRM"}]},
)
print(res.json())شنو كترجع: الأرقام اللي added (تزادو)، اللي already_on_list (كانو فاللائحة من قبل)، وشحال دابا فاللائحة.
{
"success": true,
"request_id": "d4nca",
"added": ["61400111222", "61400333444"],
"already_on_list": [],
"count": 37
}GET /v1/YOUR_NUMBER/donotcall?number=61400111222 كيتشيك على رقم وحد (on_list). DELETE /v1/YOUR_NUMBER/donotcall/61400111222 كيخرج رقم من اللائحة: دير هادشي غير ملي الشخص طلب يرجع يتوصل بالعروض.
كتب العرض بـ placeholder مرقّم لـ الاسم الأول، وعطي قيمة مثال ليه فـ example، وزيد footer كيقول كيفاش يوقف. STOP وترجماتو هما كلمات الاعتراض اللي app2email كيعرف من قبل.
curl -s https://api.app2email.com/v1/YOUR_NUMBER/templates \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "winter_sale",
"language": "en",
"category": "MARKETING",
"components": [
{
"type": "BODY",
"text": "Hi {{1}}, our winter sale starts today: 20% off everything until Sunday. Shop now: https://www.example.com/sale",
"example": { "body_text": [["John"]] }
},
{ "type": "FOOTER", "text": "Reply STOP to opt out" }
]
}'const res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/templates", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.A2E_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "winter_sale",
language: "en",
category: "MARKETING",
components: [
{
type: "BODY",
text: "Hi {{1}}, our winter sale starts today: 20% off everything until Sunday. Shop now: https://www.example.com/sale",
example: { body_text: [["John"]] },
},
{ type: "FOOTER", text: "Reply STOP to opt out" },
],
}),
});
console.log(res.status, await res.json());res = requests.post(
"https://api.app2email.com/v1/YOUR_NUMBER/templates",
headers={"Authorization": f"Bearer {os.environ['A2E_KEY']}"},
json={
"name": "winter_sale",
"language": "en",
"category": "MARKETING",
"components": [
{
"type": "BODY",
"text": "Hi {{1}}, our winter sale starts today: 20% off everything until Sunday. Shop now: https://www.example.com/sale",
"example": {"body_text": [["John"]]},
},
{"type": "FOOTER", "text": "Reply STOP to opt out"},
],
},
)
print(res.status_code, res.json())شنو كترجع (HTTP 201): الـ template دابا عند Meta للمراجعة.
{
"success": true,
"request_id": "c3ppl",
"template": {
"id": "2234567890",
"name": "winter_sale",
"language": "en",
"category": "MARKETING",
"status": "PENDING"
},
"note": "Submitted to WhatsApp for review (minutes to a day). You get a template.status_changed webhook event with the result, or GET https://api.app2email.com/v1/4976659348270/templates/winter_sale."
}المراجعة كتدوم من دقايق حتى ليوم. الحدث template.status_changed كيقولك النتيجة (status APPROVED مع can_send: true، ولا REJECTED مع reason)، ولا سول GET /v1/YOUR_NUMBER/templates/winter_sale. example_request ديالو طلب كامل تقدر تنسخو، وquality_score (GREEN، YELLOW ولا RED) كيبين من بعد كيفاش الناس كيتفاعلو معاه. للمسار الكامل ديال المراجعة شوف صيفط إشعارات الطلبيات والمواعيد بالـ templates.
الـ templates كيتملكو حساب WhatsApp Business: كل رقم فهاد الحساب يقدر يستعملهم.
الشريحة هي فلتر محفوظ على جهات الاتصال. كل شرط خاصو يتحقق: tags_any، tags_all، consent_marketing، last_inbound_days (كتب ليك فآخر N يوم)، وsearch. حتى 100 شريحة.
curl -s https://api.app2email.com/v1/YOUR_NUMBER/segments \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Newsletter, consented",
"filter": { "tags_any": ["newsletter"], "consent_marketing": true }
}'const res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/segments", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.A2E_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Newsletter, consented",
filter: { tags_any: ["newsletter"], consent_marketing: true },
}),
});
const { segment } = await res.json();
console.log(segment.id, segment.contacts);res = requests.post(
"https://api.app2email.com/v1/YOUR_NUMBER/segments",
headers={"Authorization": f"Bearer {os.environ['A2E_KEY']}"},
json={"name": "Newsletter, consented", "filter": {"tags_any": ["newsletter"], "consent_marketing": True}},
)
segment = res.json()["segment"]
print(segment["id"], segment["contacts"])شنو كترجع (HTTP 201): الشريحة، مع شحال من جهة كتطابق دابا.
{
"success": true,
"request_id": "s5gmt",
"segment": {
"id": 12,
"name": "Newsletter, consented",
"filter": { "tags_any": ["newsletter"], "consent_marketing": true },
"contacts": 240,
"created": "2026-11-21T01:00:00Z",
"updated": "2026-11-21T01:00:00Z"
}
}GET /v1/YOUR_NUMBER/segments/12/contacts?limit=200 كيعطيك الجهات اللي كتطابق، صفحة بصفحة (next_cursor). الشريحة فلتر، ماشي نسخة: الجهة اللي كتسحب موافقتها كتخرج منها.
recipients كيعطي كل رقم قيمهم الخاصة: هنا الاسم الأول من الاستيراد. صيفط طلب وحد لكل دفعة حتى max_numbers_per_request رقم (فـ GET /usage وGET /me؛ حد الـ broadcast، حتى 1000).
"background": true كيجاوب فالحين ملي يتشيكو الكل، ويصيفط من بعد.campaign_name هو اسم الـ broadcast فسجل النشاط تحت Broadcasts.Idempotency-Key تابع للدفعة: إلا خدمتك تخدم مرتين فـ 24 ساعة، الدفعة ما كتتصيفطش مرة أخرى.curl -s https://api.app2email.com/v1/YOUR_NUMBER/messages \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: winter-sale-2026-batch-0" \
-d '{
"type": "template",
"campaign_name": "Winter sale 2026",
"background": true,
"template": { "name": "winter_sale", "language": { "code": "en" } },
"recipients": [
{
"to": "61412345678",
"components": [{ "type": "body", "parameters": [{ "type": "text", "text": "John" }] }]
},
{
"to": "61498765432",
"components": [{ "type": "body", "parameters": [{ "type": "text", "text": "Mary" }] }]
}
]
}'const BASE = "https://api.app2email.com/v1/YOUR_NUMBER";
const headers = {
Authorization: `Bearer ${process.env.A2E_KEY}`,
"Content-Type": "application/json",
};
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function call(path, init = {}) {
for (;;) {
const res = await fetch(BASE + path, { ...init, headers: { ...headers, ...init.headers } });
if (res.status === 429) {
const body = await res.json();
if (body.error.code !== "rate_limited") throw new Error(`${body.error.code}: ${body.error.how_to_fix}`);
await sleep(Number(res.headers.get("Retry-After") ?? 5) * 1000);
continue;
}
const body = await res.json();
if (!res.ok) throw new Error(`${body.error.code}: ${body.error.how_to_fix}`);
return body;
}
}
// 1. Everyone the segment matches, page by page
const contacts = [];
let cursor = "";
do {
const page = await call(`/segments/12/contacts?limit=200${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ""}`);
contacts.push(...page.contacts);
cursor = page.next_cursor;
} while (cursor);
// 2. The most numbers per request
const { max_numbers_per_request: max } = await call("/usage");
// 3. One request per batch, each with its own Idempotency-Key
for (let i = 0, n = 0; i < contacts.length; i += max, n++) {
const batch = contacts.slice(i, i + max);
const body = await call("/messages", {
method: "POST",
headers: { "Idempotency-Key": `winter-sale-2026-batch-${n}` },
body: JSON.stringify({
type: "template",
campaign_name: `Winter sale 2026 (${n + 1})`,
background: true,
template: { name: "winter_sale", language: { code: "en" } },
recipients: batch.map((c) => ({
to: c.identity,
components: [
{ type: "body", parameters: [{ type: "text", text: c.custom_fields?.first_name || c.name || "there" }] },
],
})),
}),
});
if (body.status === "pending_approval") console.log("waiting for approval:", body.approval.url);
else console.log(body.status, body.broadcast.code, body.queued, body.skipped);
}import os, time, requests
BASE = "https://api.app2email.com/v1/YOUR_NUMBER"
HEADERS = {"Authorization": f"Bearer {os.environ['A2E_KEY']}"}
def call(method, path, **kw):
while True:
res = requests.request(method, BASE + path, headers={**HEADERS, **kw.pop("headers", {})}, **kw)
body = res.json()
if res.status_code == 429 and body["error"]["code"] == "rate_limited":
time.sleep(int(res.headers.get("Retry-After", "5")))
continue
if not res.ok:
raise RuntimeError(f"{body['error']['code']}: {body['error']['how_to_fix']}")
return body
# 1. Everyone the segment matches, page by page
contacts, cursor = [], None
while True:
page = call("GET", "/segments/12/contacts", params={"limit": 200, **({"cursor": cursor} if cursor else {})})
contacts += page["contacts"]
cursor = page.get("next_cursor")
if not cursor:
break
# 2. The most numbers per request
size = call("GET", "/usage")["max_numbers_per_request"]
# 3. One request per batch, each with its own Idempotency-Key
for n, i in enumerate(range(0, len(contacts), size)):
batch = contacts[i : i + size]
body = call(
"POST",
"/messages",
headers={"Idempotency-Key": f"winter-sale-2026-batch-{n}"},
json={
"type": "template",
"campaign_name": f"Winter sale 2026 ({n + 1})",
"background": True,
"template": {"name": "winter_sale", "language": {"code": "en"}},
"recipients": [
{
"to": c["identity"],
"components": [
{
"type": "body",
"parameters": [
{"type": "text", "text": c.get("custom_fields", {}).get("first_name") or c.get("name") or "there"}
],
}
],
}
for c in batch
],
},
)
if body["status"] == "pending_approval":
print("waiting for approval:", body["approval"]["url"])
else:
print(body["status"], body["broadcast"]["code"], body.get("queued"), body.get("skipped"))شنو كترجع (HTTP 202): التشيكات نجحو والصيفط بدا. احتفظ بـ broadcast.code: كل طلب من بعد على هاد الـ broadcast كيستعملو.
{
"success": true,
"request_id": "t7wpe",
"status": "queued",
"from": "4976659348270",
"template": { "name": "winter_sale", "language": "en", "category": "MARKETING" },
"broadcast": {
"name": "Winter sale 2026",
"code": "k3XbQ9rTzP2mWv7a1c9e",
"report_url": "https://www.app2email.com/dashboard/log/broadcast/k3XbQ9rTzP2mWv7a1c9e",
"status_url": "https://api.app2email.com/v1/4976659348270/broadcasts/k3XbQ9rTzP2mWv7a1c9e"
},
"recipients": 2,
"queued": 2,
"skipped": 0,
"results": [],
"note": "Sending in the background. GET broadcast.status_url for progress and the result for each number, or use the broadcast.completed webhook."
}كل رقم كيتشيك قبل ما يتصيفط أي شي. الأرقام فلائحة Do Not Call، وإلا كانت قاعدة opt-in مفعّلة والرقم بلا سجل opt-in، كيتجاوزو وكيتحسبو، ما كيتصيفطوش.
جرّب الأول. زيد "dry_run": true لنفس الـ body. كل شي كيتشيك بحال صيفط حقيقي (قيم الـ template، الأرقام، لائحة Do Not Call، قاعدة opt-in، الحد الشهري)، والجواب كيبين الرسالة بالضبط لكل رقم. ما كيتصيفط والو، ما كيتسجلش، وما كيتحسبش، والـ Idempotency-Key ما كيتحسبش.
مباشرة للشريحة. "segment": "Newsletter, consented" (الـ id ولا الاسم بالضبط) بدل recipients كيصيفط لكل جهات الشريحة فطلب وحد. القيم كتجي من كل جهة لـ template بـ placeholders مسمّاة ({{first_name}}، صاوب بـ "parameter_format": "NAMED"): parameter بـ parameter_name وبلا text كيتعمّر من custom_fields ديال الجهة (name من اسم الجهة).
{
"segment": "Newsletter, consented",
"type": "template",
"campaign_name": "November offer",
"template": {
"name": "november_offer",
"language": { "code": "en" },
"components": [
{ "type": "body", "parameters": [{ "type": "text", "parameter_name": "first_name" }] }
]
}
}زيد send_at (ISO 8601 بمنطقة زمنية، من دقيقة حتى 29 يوم قدام) لنفس الـ body. الصباح فمنطقة زمنية الزبناء ديالك غالبا كيخدم أحسن من نص الليل.
{
"type": "template",
"campaign_name": "Winter sale 2026",
"template": { "name": "winter_sale", "language": { "code": "en" } },
"recipients": [
{ "to": "61412345678", "components": [{ "type": "body", "parameters": [{ "type": "text", "text": "John" }] }] }
],
"send_at": "2026-12-01T09:00:00+11:00"
}الجواب HTTP 202 بـ status: "scheduled"، وscheduled_for (UTC)، وscheduled (شحال من رسالة)، وcode ديال الـ broadcast. كل شي كيتشيك مرة وحدة، وlائحة Do Not Call والحد الشهري كيتشيكو مرة أخرى ملي يجي الوقت، باش شي واحد يقول STOP فالوسط ما يتوصلش بيه.
GET /v1/YOUR_NUMBER/broadcasts/{code} كيخدم وقت ما الـ broadcast كيتصيفط.
curl -s https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7a1c9e \
-H "Authorization: Bearer $A2E_KEY"
# one row per message, for a spreadsheet
curl -s https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7a1c9e/results.csv \
-H "Authorization: Bearer $A2E_KEY" -o winter-sale.csvconst res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7a1c9e", {
headers: { Authorization: `Bearer ${process.env.A2E_KEY}` },
});
const { broadcast, counts } = await res.json();
console.log(broadcast.status, counts);res = requests.get(
"https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7a1c9e",
headers={"Authorization": f"Bearer {os.environ['A2E_KEY']}"},
)
body = res.json()
print(body["broadcast"]["status"], body["counts"])شنو كترجع: الـ broadcast، عدادو، ونتيجة وحدة لكل رقم. status هو scheduled، inprogress، completed، cancelled، missed، interrupted، pending ولا unknown. كل نتيجة هي الرسالة (بـ status، وtimes، وreply ديال الزبون)، ولا skipped، not_sent ولا pending مع reason.
{
"success": true,
"request_id": "b6rsl",
"broadcast": {
"code": "k3XbQ9rTzP2mWv7a1c9e",
"name": "Winter sale 2026",
"created": "2026-12-01T09:00:00Z",
"status": "completed",
"sent_by": "api",
"template": { "name": "winter_sale", "language": "en" },
"report_url": "https://www.app2email.com/dashboard/log/broadcast/k3XbQ9rTzP2mWv7a1c9e"
},
"counts": {
"numbers": 240,
"skipped_do_not_call": 3,
"skipped_monthly_limit": 0,
"posted": 237,
"accepted": 236,
"sent": 236,
"delivered": 229,
"read": 171,
"failed": 1,
"replied": 19,
"opted_out": 2
},
"results": [
{
"message_id": "wamid.HBgLNjE0MTIzNDU2NzgVAgARGBJTQU1QTEVfVEVTVF9FVkVOVAA=",
"to": "61412345678",
"status": "read",
"sent_by": "api",
"broadcast_code": "k3XbQ9rTzP2mWv7a1c9e",
"text": "Hi John, our winter sale starts today: 20% off everything until Sunday. Shop now: https://www.example.com/sale",
"times": {
"submitted": "2026-12-01T09:00:00Z",
"accepted": "2026-12-01T09:00:01Z",
"sent": "2026-12-01T09:00:02Z",
"delivered": "2026-12-01T09:00:04Z",
"read": "2026-12-01T09:14:40Z"
},
"reply": { "at": "2026-12-01T09:15:10Z", "text": "Do you have it in blue?" },
"conversation_url": "https://www.app2email.com/conversation/61412345678_4976659348270_..."
},
{ "to": "61400111222", "status": "skipped", "reason": "On the Do Not Call list" }
]
}results.csv فيه سطر لكل رسالة: الرقم، الحالة، message_id، وقت كل خطوة، الجواب، والخطأ (ومعاهم clicks وfirst_click_at ملي الروابط تتتبعات). القيم اللي كتبدا بـ =، +، - ولا @ كيتزاد ليها ' قدامها، باش السبريدشيت ما يحسبهومش كصيغ. GET /v1/YOUR_NUMBER/broadcasts كيعطيك آخر broadcasts ديالك، من الجديد للقديم.
ثمن غالط فالعرض؟ POST /v1/YOUR_NUMBER/broadcasts/{code}/cancel (صلاحية messages:send) كيوقف broadcast ديال API ملي يكون مجدول ولا مازال كيتصيفط.
curl -s -X POST https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7a1c9e/cancel \
-H "Authorization: Bearer $A2E_KEY"const res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7a1c9e/cancel", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.A2E_KEY}` },
});
console.log(res.status, await res.json());res = requests.post(
"https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7a1c9e/cancel",
headers={"Authorization": f"Bearer {os.environ['A2E_KEY']}"},
)
print(res.status_code, res.json())شنو كترجع: HTTP 200 لـ broadcast مجدول (ما تصيفطش والو)، ولا HTTP 202 لواحد كيتصيفط دابا: الرسائل اللي وصلت لـ WhatsApp تبقى مصيفطة، والباقي ما كيتصيفطش.
{
"success": true,
"request_id": "u1nqd",
"broadcast": { "code": "k3XbQ9rTzP2mWv7a1c9e", "status": "cancelling" },
"note": "Cancelling. Messages already handed to WhatsApp stay sent; the rest are not sent. GET https://api.app2email.com/v1/4976659348270/broadcasts/k3XbQ9rTzP2mWv7a1c9e shows the result."
}حدث broadcast.completed كيجي من بعد بـ status: "cancelled". الـ broadcasts اللي خلصو، واللي تبدا من لوحة التحكم، كيجاوبو 409 broadcast_not_cancellable.
broadcast ديال API: صاوب اللائحة اللي جاية بنفسك من النتيجة. كل نتيجة فـ GET /broadcasts/{code} فيها status ديال الرسالة وreply ديال الزبون، فتقدر تختار مثلا كلشي اللي قرا العرض وما جاوبش، وتصيفطلهم template تاني بـ POST /messages كيفما فوق.
const { results } = await (await fetch(`${BASE}/broadcasts/k3XbQ9rTzP2mWv7a1c9e`, { headers })).json();
const readNoReply = results.filter((r) => r.status === "read" && !r.reply).map((r) => r.to);broadcast اللي تبدا من صفحة Broadcast فلوحة التحكم فيه جوج حوايج زيادة يقدر API يستعملهم:
https://www.app2email.com/l/<code> لأي رابط فقيم الـ broadcast. GET /broadcasts/{code}/clicks كيعطيك المجموع، والنقرات الفريدة، نسبة النقر، ونقرات كل متلقي (معاينات الروابط والـ crawlers ما كيتحسبوش). نفس الأرقام كاينين فـ clicks ديال GET /broadcasts/{code}، وحدث link.clicked كيوصل لكل نقرة.POST /broadcasts/{code}/retarget كيصاوب broadcast جديد بنفس الـ template والقيم والميديا، لـ audience وحدة: not_read، read_not_clicked، clicked، replied (جاوب فـ 7 أيام من الصيفط) ولا not_replied. عد الأول بـ dry_run:curl -s https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7/retarget \
-H "Authorization: Bearer $A2E_KEY" \
-H "Content-Type: application/json" \
-d '{ "audience": "read_not_clicked", "dry_run": true }'const res = await fetch("https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7/retarget", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.A2E_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ audience: "read_not_clicked", dry_run: true }),
});
console.log(await res.json());res = requests.post(
"https://api.app2email.com/v1/YOUR_NUMBER/broadcasts/k3XbQ9rTzP2mWv7/retarget",
headers={"Authorization": f"Bearer {os.environ['A2E_KEY']}"},
json={"audience": "read_not_clicked", "dry_run": True},
)
print(res.json())شنو كترجع: مع dry_run، العدد (HTTP 200). بلا dry_run، HTTP 202 والـ broadcast الجديد، اللي كيتصيفط فالخلفية.
{
"success": true,
"request_id": "c3rtg",
"audience": "read_not_clicked",
"recipients": 131,
"broadcast": {
"code": "Mx8Pq2Lw5Rt7Yz3",
"name": "Summer sale - read not clicked",
"status": "inprogress",
"status_url": "https://api.app2email.com/v1/4976659348270/broadcasts/Mx8Pq2Lw5Rt7Yz3",
"report_url": "https://www.app2email.com/dashboard/log/broadcast/Mx8Pq2Lw5Rt7Yz3"
},
"note": "The new broadcast is sending in the background."
}لائحة Do Not Call والحد ديال الباقة كيتشيكو مرة أخرى، وحد الموافقة ديال المفتاح والسقف اليومي كيتطبقو. Retarget وresume وretry خدامين غير على broadcasts ديال لوحة التحكم: لائحة ديال API كتجاوب 403 broadcast_not_resumable.
المتابعة رسالة تسويقية أخرى، كتتحسب من جديد. صيفطها لمجموعة صغيرة مهتمة (clicked، replied)، ماشي لكلشي اللي ما اهتمش بالأول.
الزبون كيشوف رسالة من اسم شركتك فيها العرض، واسمه الأول، و footer "Reply STOP to opt out". ملي يجاوب، النافذة ديال 24 ساعة كتفتح وتقدر تجاوب بنص حر من API ولا بالإيميل.
من جهتك كتوصلك هاد الأحداث (زيد webhook بـ POST /v1/YOUR_NUMBER/webhooks وurl عام بـ https؛ صلاحية webhooks:manage). ما عندكش عنوان عام دابا؟ GET /v1/YOUR_NUMBER/events?wait=25 كيعطيك نفس الأحداث.
message.status لكل رسالة، ملي تتحرك: sent، delivered، read، ولا failed. broadcast_code كيقول لأي broadcast كتنتمي، وpricing.category كيقول كيفاش Meta حسبات.
{
"id": "evt_Xq3k9m2Lw8Rt5Yp1Zs01",
"type": "message.status",
"created": "2026-12-01T09:00:04.000Z",
"number": "4976659348270",
"data": {
"message_id": "wamid.HBgLNjE0MTIzNDU2NzgVAgARGBJTQU1QTEVfVEVTVF9FVkVOVAA=",
"to": "61412345678",
"status": "delivered",
"timestamp": "2026-12-01T09:00:04.000Z",
"sent_by": "api",
"broadcast_code": "k3XbQ9rTzP2mWv7a1c9e",
"whatsapp_status": "delivered",
"recipient_user_id": "AU.1234567890123456",
"pricing": { "billable": true, "pricing_model": "PMP", "type": "regular", "category": "marketing" }
}
}message.failed ملي الرسالة ما توصلش. واحد كتشوفو مع التسويق هو خطأ Meta 131049: WhatsApp حبس الرسالة لأن الشخص توصل بالتسويق بزاف فالفترة الأخيرة. ما تصيفطهاش مرة أخرى فـ 24 ساعة؛ إلا عاودتي بكري كتطول الحظر.
{
"id": "evt_Pa3k9m2Lw8Rt5Yp1Zs011",
"type": "message.failed",
"created": "2026-12-01T09:00:03.000Z",
"number": "4976659348270",
"data": {
"message_id": "wamid.HBgLNjE0MTIzNDU2NzgVAgARGBJTQU1QTEVfVEVTVF9FVkVOVAA=",
"to": "61412345678",
"status": "failed",
"timestamp": "2026-12-01T09:00:03.000Z",
"sent_by": "broadcast",
"whatsapp_status": "failed",
"error": {
"code": 131049,
"message": "This message was not delivered to maintain healthy ecosystem engagement.",
"title": "This message was not delivered to maintain healthy ecosystem engagement.",
"error_code": "marketing_per_user_limit",
"how_to_fix": "WhatsApp held this marketing message back: the person has had many marketing messages lately. Do not send it again within 24 hours, because retrying sooner keeps the block longer.",
"is_retriable": false,
"retry_after_seconds": 86400
}
}
}message.received ملي الزبون يجاوب: text لجواب مكتوب، وbutton لزر مضغوط.
contact.opted_out ملي الزبون يزيد راسو فلائحة Do Not Call. source هو stop_promotions (ضغط "Stop promotions")، whatsapp_stop ولا keyword (كتب كلمة الاعتراض).
{
"id": "evt_Xq3k9m2Lw8Rt5Yp1Zs01",
"type": "contact.opted_out",
"created": "2026-12-01T09:20:00.000Z",
"number": "4976659348270",
"data": {
"number": "61412345678",
"name": "John Smith",
"source": "stop_promotions",
"detail": "Stop promotions",
"timestamp": "2026-12-01T09:20:00.000Z"
}
}link.clicked لكل نقرة على رابط متتبع (broadcasts ديال لوحة التحكم). first_click كيكون true للنقرة الأولى ديال رابط هاد المتلقي.
{
"id": "evt_Cmp3k9m2Lw8Rt5Yp1Zs01",
"type": "link.clicked",
"created": "2026-11-19T01:00:00.000Z",
"number": "4976659348270",
"data": {
"contact": "61412345678",
"url": "https://example.com/sale",
"broadcast_code": "k3XbQ9rTzP2mWv7",
"sequence_id": null,
"step_id": null,
"first_click": true,
"clicks": 1,
"browser": "Chrome",
"timestamp": "2026-11-19T01:00:00.000Z"
}
}broadcast.completed مرة وحدة لكل broadcast، ملي يكون سالا، ولا تلغا، ولا فات وقتو المجدول.
{
"id": "evt_Xq3k9m2Lw8Rt5Yp1Zs01",
"type": "broadcast.completed",
"created": "2026-12-01T09:04:00.000Z",
"number": "4976659348270",
"data": {
"code": "k3XbQ9rTzP2mWv7a1c9e",
"name": "Winter sale 2026",
"status": "completed",
"sent_by": "api",
"numbers": 240,
"posted": 237,
"accepted": 236,
"errors": 1,
"skipped_do_not_call": 3,
"skipped_monthly_limit": 0,
"status_url": "https://api.app2email.com/v1/4976659348270/broadcasts/k3XbQ9rTzP2mWv7a1c9e",
"report_url": "https://www.app2email.com/dashboard/log/broadcast/k3XbQ9rTzP2mWv7a1c9e"
}
}GET /v1/YOUR_NUMBER/stats?from=&to= كيجمع عدد وnسب المصيفط والموصّل والمقري والفاشل والجواب، لفترة معينة، عبر كل broadcasts.
جوج فواتير:
skipped_monthly_limit) ولا كيجاوب 429 monthly_limit_reached.قدّر قبل ما تصيفط بـ حاسبة أثمان WhatsApp. ومن بعد، meta_pricing فـ GET /v1/YOUR_NUMBER/usage كيعد رسائل شهر الفاتورة بفئات Meta مع تكلفة تقريبية، وGET /v1/YOUR_NUMBER/usage/meta كيعطيها لكل يوم.
ملي Meta تكون دخلات الحساب ديالك لـ Marketing Messages API ديالها، الـ templates التسويقية كيمشيو بهاد الطريق بشكل افتراضي (إعداد الرقم messages.marketing_route، auto). GET /v1/YOUR_NUMBER/marketing كيبين الطريق، وsent_via فجواب الصيفط كيقول بأي طريق تصيفطات الرسالة. الطلب ديالك ما كيتبدلش.
WhatsApp كيراقب كيفاش الناس كيتفاعلو مع رسائلك. البلوكاج والبلاغات الكثار كينزلو تقييم الجودة ديالك. من بعد:
quality_score ديال الـ template (فـ GET /templates/{name}) كيولي YELLOW، من بعد RED، والـ template بـ RED ممكن يتوقف (422 template_paused، خطأ Meta 132015)؛paused_by_meta، والسبب فـ status_notes)؛ صلّح السبب، وPOST /broadcasts/{code}/resume كيكمل.GET /v1/YOUR_NUMBER/health (صلاحية messages:read) كيبين quality_rating وmessaging_limit ديال الرقم:
{
"success": true,
"request_id": "h7q2m",
"health": {
"can_send_message": "AVAILABLE",
"quality_rating": "GREEN",
"messaging_limit": "TIER_2K",
"throughput": "STANDARD",
"status": "CONNECTED",
"name_status": "APPROVED",
"account_mode": "LIVE"
},
"fetched_at": "2026-11-06T01:00:00.000Z"
}كيفاش تخلي التقييم أخضر:
last_inbound_days ففلتر الشريحة)، وراقب القراءات والاعتراضات ديال الدفعة الأولى قبل ما تصيفط الباقي.كل حدث فيه الـ header X-App2email-Signature: t=<unix seconds>,v1=<hex>. القيمة v1 هي HMAC-SHA256 ديال "<t>.<raw body>"، بسر الـ webhook (whsec_... مع البادئة) كمفتاح. تشيك على كل v1= (كاينين جوج ملي السر القديم يبقى محفوظ بعد التبديل)، احسبو على الـ body الخام كيفما وصل، وارفض t قديم. X-Hub-Signature-256: sha256=<hex> (HMAC-SHA256 ديال الـ body الخام، بالسر الحالي غير) كاين كذلك، للكود اللي مكتوب لـ webhooks ديال Meta.
import crypto from "node:crypto";
import express from "express";
export function verifyWebhook(rawBody, header, secret, toleranceSeconds = 300) {
const t = /(?:^|,)\s*t=(\d+)/.exec(header ?? "")?.[1];
const v1 = [...(header ?? "").matchAll(/(?:^|,)\s*v1=([0-9a-f]+)/g)].map((m) => m[1]);
if (!t || v1.length === 0 || Math.abs(Date.now() / 1000 - Number(t)) > toleranceSeconds) return false;
const expected = crypto.createHmac("sha256", secret).update(t + ".").update(rawBody).digest("hex");
return v1.some((v) => v.length === expected.length && crypto.timingSafeEqual(Buffer.from(v), Buffer.from(expected)));
}
const app = express();
app.post("/app2email", express.raw({ type: "application/json" }), async (req, res) => {
if (!verifyWebhook(req.body, req.get("X-App2email-Signature"), process.env.WEBHOOK_SECRET)) return res.sendStatus(401);
if (await alreadySeen(req.get("X-App2email-Delivery"))) return res.sendStatus(200); // a retry
const event = JSON.parse(req.body);
res.sendStatus(200); // answer within 10 seconds, then do the work
switch (event.type) {
case "message.status":
case "message.failed":
await saveStatus(event.data.broadcast_code, event.data.to, event.data.message_id, event.data.status, event.data.error);
break;
case "contact.opted_out":
await markUnsubscribed(event.data.number, event.data.source); // in your CRM too
break;
case "broadcast.completed":
await saveBroadcastTotals(event.data);
break;
}
});import hashlib, hmac, json, os, re, time
from flask import Flask, request
def verify_webhook(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
t = re.search(r"(?:^|,)\s*t=(\d+)", header or "")
v1 = re.findall(r"(?:^|,)\s*v1=([0-9a-f]+)", header or "")
if not t or not v1 or abs(time.time() - int(t.group(1))) > tolerance:
return False
expected = hmac.new(secret.encode(), t.group(1).encode() + b"." + raw_body, hashlib.sha256).hexdigest()
return any(hmac.compare_digest(v, expected) for v in v1)
app = Flask(__name__)
@app.post("/app2email")
def app2email():
raw = request.get_data()
if not verify_webhook(raw, request.headers.get("X-App2email-Signature"), os.environ["WEBHOOK_SECRET"]):
return "", 401
if already_seen(request.headers.get("X-App2email-Delivery")):
return "", 200 # a retry
event = json.loads(raw)
queue.put(event) # handle it after answering
return "", 200 # within 10 secondsجاوب بـ 2xx فـ 10 ثواني. ولا الحدث كيتعاود بعد 10 ثواني، 1 دقيقة، 5 دقايق، 30 دقيقة، ثم 1، 2، 4، 8 و16 ساعة. X-App2email-Delivery (الـ id ديال الحدث، evt_...) نفسو فكل إعادة، فخزّنو وتجاوز الحدث اللي عالجتيه.
الأحداث ممكن توصل بترتيب غالط: read يمكن يجي قبل delivered. خزّن أبعد حالة لكل message_id وما ترجعهاش لور. فـ broadcast، سجّل السجلات ديالك بـ broadcast_code وto.
عطي كل دفعة Idempotency-Key تابع للحملة وللدفعة، ماشي للمحاولة: winter-sale-2026-batch-0، winter-sale-2026-batch-1. نفس الطلب بنفس المفتاح فـ 24 ساعة ما كيتصيفطش مرة أخرى؛ كيرجع الجواب الأول، بالـ header Idempotent-Replayed: true.
422 idempotency_key_reused. خلّي الدفعات بنفس الترتيب، ولا استعمل مفاتيح جديدة لائحة جديدة.409 idempotency_request_in_progress. استنى وعاود بنفس المفتاح.409 idempotency_request_interrupted. شي رسائل ممكن تكون تصيفطات: شوف GET /broadcasts قبل ما تصيفط بمفتاح جديد.المفتاح كيتحفظ 24 ساعة. وخزّن كذلك broadcast.code ديال كل دفعة فقاعدة البيانات ديالك، وما ترجعش تصيفط دفعة عندها واحد.
صيفط اللائحة بطلب وحد لكل دفعة، ماشي طلب لكل رقم. كل جواب فيه X-RateLimit-Limit، وX-RateLimit-Remaining، وX-RateLimit-Reset (الثواني حتى يرجع كامل)، وX-RateLimit-Policy؛ limits فـ GET /me كيبين requests_per_second وburst ديال المفتاح. ملي تعديت الحد كتاخد 429 rate_limited مع header Retry-After وerror.retry_after_seconds: استنى هاد المدة، من بعد صيفط نفس الطلب.
500، 502، 503 ولا timeout: عاود المحاولة شي مرات بانتظار كيزيد، بنفس Idempotency-Key.429 whatsapp_rate_limit ولا 429 too_many_messages_to_recipient: حد WhatsApp نفسو. وقف دقايق، ماشي ثواني.429 monthly_limit_reached، 429 monthly_cap_reached ولا 429 daily_cap_reached: حد ديال الباقة، ولا الرقم، ولا المفتاح. ما تعاودش حتى يتجدد، ولا زيد الحد.4xx آخر: ما تعاودش بنفس الطلب. قرر حسب error.code وتبع how_to_fix. error.is_retriable كيقولك واش نفس الطلب ممكن يخدم من بعد.المفتاح ممكن يكون عندو سقف يومي وبوابة موافقة (GET /me كيبينهم). الصيفط لعدد جهات أكثر من اللي كتسمح به البوابة كيجاوب HTTP 202 بـ status: "pending_approval" وapproval.url: هادا مش خطأ. شي واحد من الفريق كيوافق فلوحة التحكم، حدث approval.resolved كيجي، والرسائل كتمشي. ما تصيفطش نفس اللائحة بطريقة أخرى فهاداك الوقت. هادي شبكة أمان مزيانة لمفتاح كيصيفط تسويق.
contact.opted_out كيقولك. زيد كلمات الاعتراض ديالك بـ PUT /v1/YOUR_NUMBER/settings/number و{"compliance": {"stop_keywords_extra": ["UNSUBSCRIBE"]}} (صلاحية settings:manage).POST /contacts/{identity}/consent بـ "marketing": false)، باش الشرائح بـ consent_marketing: true ما تحسبوش، وحطو فلائحة Do Not Call إلا خرج من مكان آخر.403 recipient_stopped_marketing (خطأ Meta 131050). إلا رجع فعّلو، كيوصل contact.updated بـ change: "marketing_resumed".GET /v1/YOUR_NUMBER/compliance/export.csv (صلاحية dnc:manage) كيعطيك سجلات الموافقة ولائحة Do Not Call والـ opt-ins فملف وحد، السجلات اللي قانون Spam Act 2003 كيتوقع منك تقدر تبينها.broadcast هو template، فيقدر يتصيفط فأي وقت. ملي الزبون يجاوب، النافذة ديال 24 ساعة كتفتح وتقدر تجاوب بنص عادي، وصور، وأزرار (app2email كيوقف 15 دقيقة قبل). GET /v1/YOUR_NUMBER/conversations/61412345678 كيبين window_state وwindow_closes_at. إلا كانت آخر رسالة ديالو هي الاعتراض نفسو، الجواب كيجاوب 403 recipient_opted_out حتى يكتب من جديد.
كل خطأ كيجي JSON فيه error.code، وmessage، وhow_to_fix، وrequest_id تقدر تعطيه للدعم. شوف Errors لكل الأكواد وLimits للحدود.
| الكود | متى | شنو تدير |
|---|---|---|
403 insufficient_scope | المفتاح ناقصو صلاحية (details.required_scope) | استعمل مفتاح فيه الصلاحيات اللي فالجدول فوق |
403 sandbox_key | صنع template، PUT /settings/optin ولا retarget بـ sandbox key | استعمل مفتاح عادي لهاد الطلبات |
400 invalid_csv | الـ CSV ما فيهش سطر العناوين، ولا ما فيهش سطر جهة | صيفط سطر العناوين وسطر واحد على الأقل، حتى 5000 سطر |
400 invalid_template_category | category ماشي MARKETING ولا UTILITY ولا AUTHENTICATION | استعمل MARKETING للعروض |
422 template_not_approved | الـ template فالمراجعة، مرفوض، موقوف، ولا معطّل | استنى الموافقة، ولا صلّحو؛ شوف GET /templates/{name} |
422 template_parameters_invalid | القيم ما كيطابقوش الـ template | صلّح الـ body من details.problems وexample_request |
422 template_paused | خطأ Meta 132015: موقوف بسبب الجودة الضعيفة | استعمل template آخر، ولا بدّل هادا؛ صيفط لعدد أقل، ولناس مناسبين أكثر |
400 too_many_recipients | أكثر من الأرقام اللي يقدر الرقم يصيفطهم فطلب وحد | قسّم لدفعات ديال details.max_recipients |
400 to_and_recipients | to وrecipients مع بعض | استعمل واحد منهم |
400 segment_and_recipients | segment مع to، ولا recipient، ولا recipients | استعمل segment وحدو |
400 segment_empty | الشريحة ما كتطابق والو جهة | شوف GET /segments/{id}/contacts، زيد جهات، ولا بدّل الفلتر |
404 segment_not_found | ما كاينش شريحة بهاد الـ id ولا الاسم | GET /segments كيعطيهم؛ استعمل الـ id ولا الاسم بالضبط |
403 recipient_opted_out | رقم وحد، وهو فلائحة Do Not Call | ما تصيفطش ليه تسويق؛ فلائحة كيتجاوز |
403 recipient_not_opted_in | رقم وحد، قاعدة opt-in مفعّلة، وما عندوش سجل opt-in | سجل موافقتو الأول بـ POST /optins؛ فلائحة كيتجاوز |
403 recipient_stopped_marketing | خطأ Meta 131050: وقف التسويق منك فـ WhatsApp | ما تصيفطش ليه templates تسويقية |
422 marketing_per_user_limit | خطأ Meta 131049: توصل بزاف بالتسويق مؤخرا | ما تعاودش الصيفط فـ 24 ساعة |
403 messaging_limit_restricted | خطأ Meta 131064: Meta نزلات حد الرسائل بسبب فئات templates غالطة | شيّك على فئات الـ templates ديالك؛ الحد كيرجع بعد مدة Meta |
403 whatsapp_payment_issue | خطأ Meta 131042: Meta ما قدرتش تحسب من حساب WhatsApp ديالك | زيد ولا صلّح وسيلة الخلاص فـ WhatsApp Manager |
400 send_at_too_far | send_at أبعد من 29 يوم | استعمل وقت من دقيقة حتى 29 يوم من دابا، بمنطقة زمنية |
422 idempotency_key_reused | نفس Idempotency-Key، وbody مختلف | استعمل مفتاح جديد للائحة مختلفة |
429 rate_limited | طلبات بزاف لهاد المفتاح | استنى Retry-After ثانية، من بعد عاود |
429 whatsapp_rate_limit | حد WhatsApp (Meta 130429، 131048 وغيرهم) | بطّئ، وعاود بعد دقيقة ولا أكثر |
429 monthly_limit_reached | رسائل الباقة خلصو هاد الشهر | استنى شهر الفاتورة الجاي، ولا زيد فالباقة |
429 daily_cap_reached | السقف اليومي ديال المفتاح | استنى حتى نص الليل UTC، ولا زيد السقف |
409 broadcast_not_cancellable | الـ broadcast خلص، تلغى من قبل، ولا تبدا من لوحة التحكم | غير صيفطات ديال API المجدولة ولا اللي مازالت كتتصيفط تقدر تتلغى |
403 broadcast_not_resumable | Retarget، resume ولا retry على لائحة ديال API | لائحة ديال API: صيفط الأرقام اللي بغيتي بـ POST /messages من جديد |
400 invalid_retarget_audience | audience ماشي وحدة من الخمسة | استعمل not_read، read_not_clicked، clicked، replied ولا not_replied |
409 broadcast_nothing_to_send | ما بقاش حتى واحد فهاد الجمهور | ما كاين والو تدير |
403 campaign_approval_needed | Retarget غادي يصيفط أكثر من حد الموافقة ديال المفتاح | بدا من لوحة التحكم، ولا استعمل مفتاح بلا حد موافقة |
استقبل الرسائل بـ webhook موقع، وجاوب بنص وأزرار وقوائم.
template ديال utility لكل طلبية ولا حجز، مع حالة التسليم والقراءة.
ربط وكيل بسيرفر MCP باش يقرا ويصيفط الرسائل.
خلّي مالك المحادثة يحدد، باش البوت يتنحى ملي شي واحد يجاوب.
صيفط طلب خلاص فالمحادثة، وتوصل بحدث ملي يتخلص.