{"openapi":"3.1.0","info":{"title":"AVENOR CX 360 — Public API","version":"1.0.0","description":"واجهة عامة لربط أنظمتكم بمنصّة AVENOR CX 360: المحادثات، الرسائل، التذاكر، العملاء، التقارير، والـWebhooks الصادرة.\nPublic API to integrate your systems with AVENOR CX 360: conversations, messages, tickets, contacts, reports, and outbound webhooks.\n\nالمصادقة: ترويسة `X-API-Key: avx_…` — يُنشأ المفتاح من لوحة الشركة › وثائق الربط.\nAuthentication: `X-API-Key: avx_…` header — create keys in the tenant console › Integration docs.\n\nحدّ المعدل: 300 طلباً/دقيقة لكل مفتاح؛ عند التجاوز 429 مع Retry-After.\nRate limit: 300 requests/minute per key; 429 with Retry-After when exceeded.","contact":{"name":"AVENOR CX","url":"https://360.avenor.sa/developers"}},"servers":[{"url":"https://360.avenor.sa/v1","description":"الإنتاج\nProduction"}],"tags":[{"name":"account","description":"الحساب\nAccount"},{"name":"channels","description":"القنوات\nChannels"},{"name":"conversations","description":"المحادثات\nConversations"},{"name":"messages","description":"الرسائل\nMessages"},{"name":"tickets","description":"التذاكر\nTickets"},{"name":"contacts","description":"العملاء\nContacts"},{"name":"reports","description":"التقارير\nReports"},{"name":"voice","description":"المكالمات\nVoice"},{"name":"webhooks","description":"Webhooks\nWebhooks"}],"paths":{"/whoami":{"get":{"operationId":"whoami","tags":["account"],"summary":"تحقّق من المفتاح ونطاقاته\nVerify the key and its scopes","description":"أول طلب تجرّبه: يؤكد أن المفتاح صالح ويعرض الشركة والنطاقات المتاحة.\nYour first call: confirms the key is valid and lists the tenant and granted scopes.\n\nالمصادقة تكفي بلا نطاق\nAuthentication only, no scope","security":[{"ApiKey":[]}],"x-scope":null,"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"ok":true,"tenant_id":"3f1c…","auth":"api_key","scopes":["conversations.view","tickets.create"]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/channels":{"get":{"operationId":"channels_list","tags":["channels"],"summary":"قنوات الشركة (بلا أسرار)\nTenant channels (no secrets)","description":"تحتاج `channel_id` لإرسال رسالة — خذه من هنا. المفاتيح والأسرار لا تخرج أبداً.\nYou need a `channel_id` to send a message — get it here. Credentials are never returned.\n\nالنطاق المطلوب: `conversations.view`\nRequired scope: `conversations.view`","security":[{"ApiKey":[]}],"x-scope":"conversations.view","responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"channels":[{"id":"9a2b…","type":"whatsapp","name":"واتساب المبيعات","address":"9665…","status":"active"}]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations":{"get":{"operationId":"conversations_list","tags":["conversations"],"summary":"الصندوق الموحّد\nUnified inbox","description":"النطاق المطلوب: `conversations.view`\nRequired scope: `conversations.view`","security":[{"ApiKey":[]}],"x-scope":"conversations.view","parameters":[{"name":"status","in":"query","required":false,"description":"حالة المحادثة\nConversation status","schema":{"type":"string","enum":["open","pending","resolved","closed"]}},{"name":"channel_id","in":"query","required":false,"description":"قصر النتائج على قناة\nRestrict to one channel","schema":{"type":"string"}},{"name":"q","in":"query","required":false,"description":"بحث في الموضوع واسم العميل ونص الرسائل\nSearch subject, contact name and message bodies","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"الحد الأقصى (افتراضي 50، أقصى 200)\nMax rows (default 50, max 200)","schema":{"type":"integer"}}],"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"conversations":[{"id":"c1…","subject":"استفسار عن الفاتورة","status":"open","priority":"normal","channel_type":"whatsapp","channel_name":"واتساب","contact_name":"سارة","last_message_at":"2026-09-14T08:00:00Z","message_count":3,"last_body":"…"}]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"conversations_create","tags":["conversations"],"summary":"بدء محادثة صادرة\nStart an outbound conversation","description":"يتعرّف على العميل بعنوانه على القناة (أو ينشئه)، ويفتح خيطاً — وإن مرّرت `body` تُرسل كأول رسالة.\nResolves (or creates) the contact by channel address and opens a thread — pass `body` to send it as the first message.\n\nالنطاق المطلوب: `conversations.update`\nRequired scope: `conversations.update`","security":[{"ApiKey":[]}],"x-scope":"conversations.update","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["channel_id","to"],"additionalProperties":false,"properties":{"channel_id":{"type":"string","minLength":36,"maxLength":36,"description":"معرّف القناة\nChannel id"},"to":{"type":"string","minLength":1,"maxLength":200,"description":"عنوان العميل على القناة: رقم/بريد/معرّف\nContact address on the channel: phone/email/id"},"subject":{"type":"string","maxLength":300,"description":"الموضوع (البريد)\nSubject (email)"},"body":{"type":"string","minLength":1,"maxLength":10000,"description":"أول رسالة (اختياري)\nFirst message (optional)"},"contact_name":{"type":"string","maxLength":120,"description":"اسم العميل إن كان جديداً\nContact name if new"},"purpose":{"type":"string","enum":["transactional","marketing"],"default":"transactional","description":"غرض الرسالة: خدمي (الافتراضي) أو تسويقي — التسويقي يُفحص ضد قائمة عدم الإزعاج ويُرفض بـ422 DNC_BLOCKED إن كان الرقم فيها\nMessage purpose: transactional (default) or marketing — marketing is checked against the Do-Not-Contact list and rejected with 422 DNC_BLOCKED"}}},"example":{"channel_id":"9a2b…","to":"+9665xxxxxxx","body":"أهلاً! كيف نساعدك؟"}}}},"responses":{"201":{"description":"أُنشئ\nCreated","content":{"application/json":{"example":{"conversation_id":"c1…","contact_id":"k1…","created":true,"message_id":"m1…","delivery_status":"sent","external_id":"wamid…"}}}},"202":{"description":"قُبلت وبقيت في الطابور الصادر — ستُرسل بإعادة المحاولة (تراجع أسّي حتى 8 محاولات)، وحالتها delivery_status: queued\nAccepted and left in the outbound queue — it will be retried (exponential backoff, up to 8 attempts); see delivery_status: queued","content":{"application/json":{"example":{"message_id":"m1…","delivery_status":"queued","attempts":1,"next_at":"2026-09-26T10:04:00Z"}}}},"400":{"description":"الجسم لا يطابق المخطط\nBody does not match the schema","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations/{id}":{"get":{"operationId":"conversations_get","tags":["conversations"],"summary":"محادثة برسائلها\nConversation with messages","description":"الرسائل تحمل حالة التسليم كاملة: delivery_status (حالتنا)، وprovider_status (نص المزوّد الخام)، وdelivered_at (وقت تأكيد التسليم من تقرير DLR — null قبله)، وtemplate وpurpose.\nMessages carry the full delivery state: delivery_status (ours), provider_status (raw provider text), delivered_at (confirmed delivery time from the DLR — null before it), plus template and purpose.\n\nالنطاق المطلوب: `conversations.view`\nRequired scope: `conversations.view`","security":[{"ApiKey":[]}],"x-scope":"conversations.view","parameters":[{"name":"id","in":"path","required":true,"description":"المعرّف (UUID)\nIdentifier (UUID)","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"conversation":{"id":"c1…","subject":"…","status":"open","channel_type":"email","contact_name":"…"},"messages":[{"id":"m1…","direction":"inbound","body":"…","created_at":"…","delivery_status":"received","provider_status":null,"delivered_at":null,"template":null,"purpose":null},{"id":"m2…","direction":"outbound","body":"…","created_at":"…","delivery_status":"sent","provider_status":"DELIVRD","delivered_at":"2026-09-26T10:05:12Z","template":null,"purpose":"transactional"}]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"غير موجود\nNot found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/conversations/{id}/reply":{"post":{"operationId":"conversations_reply","tags":["conversations"],"summary":"ردّ عبر قناة المحادثة\nReply through the conversation's channel","description":"النطاق المطلوب: `conversations.update`\nRequired scope: `conversations.update`","security":[{"ApiKey":[]}],"x-scope":"conversations.update","parameters":[{"name":"id","in":"path","required":true,"description":"المعرّف (UUID)\nIdentifier (UUID)","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["body"],"additionalProperties":false,"properties":{"body":{"type":"string","minLength":1,"maxLength":10000,"description":"نص الرد\nReply text"},"rich":{"type":"object","required":["kind"],"additionalProperties":false,"description":"قالبٌ غنيّ اختياري لقنوات ماسنجر: kind=button (text + 1–3 buttons) أو kind=generic (elements 1–10). يُرفض 422 RICH_INVALID خارج الحدود.\nOptional rich template for Messenger channels: kind=button (text + 1–3 buttons) or kind=generic (elements 1–10). Rejected with 422 RICH_INVALID outside the limits.","properties":{"kind":{"type":"string","enum":["button","generic"]},"text":{"type":"string","maxLength":2000},"buttons":{"type":"array","maxItems":10,"items":{"type":"object"}},"elements":{"type":"array","maxItems":20,"items":{"type":"object"}},"sharable":{"type":"boolean"}}}}},"example":{"body":"تم استلام طلبك وسنرد خلال ساعة."}}}},"responses":{"201":{"description":"أُنشئ\nCreated","content":{"application/json":{"example":{"id":"m2…","delivery_status":"sent"}}}},"202":{"description":"قُبلت وبقيت في الطابور الصادر — ستُرسل بإعادة المحاولة (تراجع أسّي حتى 8 محاولات)، وحالتها delivery_status: queued\nAccepted and left in the outbound queue — it will be retried (exponential backoff, up to 8 attempts); see delivery_status: queued","content":{"application/json":{"example":{"message_id":"m1…","delivery_status":"queued","attempts":1,"next_at":"2026-09-26T10:04:00Z"}}}},"400":{"description":"الجسم لا يطابق المخطط\nBody does not match the schema","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"غير موجود\nNot found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/messages":{"post":{"operationId":"messages_send","tags":["messages"],"summary":"إرسال مباشر (واتساب/SMS/بريد/تيليجرام)\nDirect send (WhatsApp/SMS/email/Telegram)","description":"يسجّل الرسالة في محادثة العميل (فتظهر للوكلاء في الصندوق) ثم يدفعها إلى الطابور الصادر نفسه الذي تمرّ به ردود اللوحة: المحاولة الأولى فورية (201 مع delivery_status: sent)، وما يفشل عند المزوّد يبقى في الطابور (202 مع queued) ويُعاد بتراجع أسّي حتى ثماني محاولات — فلا تضيع رسالة بفشل عابر. واتساب خارج نافذة 24 ساعة يُرفض بـ422 TEMPLATE_REQUIRED (القوالب تُرسل من اللوحة)، والتسويقي إلى رقم في قائمة عدم الإزعاج يُرفض بـ422 DNC_BLOCKED بلا إنشاء أي رسالة.\nRecords the message in the contact's conversation (agents see it in the inbox) and pushes it through the same outbound queue as console replies: the first attempt is immediate (201 with delivery_status: sent), and a provider failure leaves it queued (202) to be retried with exponential backoff up to eight attempts — no message is lost to a transient failure. WhatsApp outside the 24h window is rejected with 422 TEMPLATE_REQUIRED (templates are sent from the console), and marketing to a number on the Do-Not-Contact list is rejected with 422 DNC_BLOCKED without creating any message.\n\nالنطاق المطلوب: `conversations.update`\nRequired scope: `conversations.update`","security":[{"ApiKey":[]}],"x-scope":"conversations.update","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["channel_id","to","body"],"additionalProperties":false,"properties":{"channel_id":{"type":"string","minLength":36,"maxLength":36,"description":"معرّف القناة من /v1/channels\nChannel id from /v1/channels"},"to":{"type":"string","minLength":1,"maxLength":200,"description":"الوجهة: رقم بصيغة دولية / بريد / معرّف تيليجرام\nDestination: E.164 phone / email / Telegram chat id"},"body":{"type":"string","minLength":1,"maxLength":10000,"description":"النص\nText"},"subject":{"type":"string","maxLength":300,"description":"الموضوع (للبريد)\nSubject (email only)"},"contact_name":{"type":"string","maxLength":120,"description":"اسم العميل إن كان جديداً\nContact name if new"},"purpose":{"type":"string","enum":["transactional","marketing"],"default":"transactional","description":"غرض الرسالة: خدمي (الافتراضي) أو تسويقي — التسويقي يُفحص ضد قائمة عدم الإزعاج ويُرفض بـ422 DNC_BLOCKED إن كان الرقم فيها\nMessage purpose: transactional (default) or marketing — marketing is checked against the Do-Not-Contact list and rejected with 422 DNC_BLOCKED"}}},"example":{"channel_id":"9a2b…","to":"+9665xxxxxxx","body":"رمز التحقق: 4821"}}}},"responses":{"201":{"description":"أُنشئ\nCreated","content":{"application/json":{"example":{"message_id":"m1…","conversation_id":"c1…","contact_id":"k1…","created":false,"delivery_status":"sent","external_id":"…"}}}},"202":{"description":"قُبلت وبقيت في الطابور الصادر — ستُرسل بإعادة المحاولة (تراجع أسّي حتى 8 محاولات)، وحالتها delivery_status: queued\nAccepted and left in the outbound queue — it will be retried (exponential backoff, up to 8 attempts); see delivery_status: queued","content":{"application/json":{"example":{"message_id":"m1…","delivery_status":"queued","attempts":1,"next_at":"2026-09-26T10:04:00Z"}}}},"400":{"description":"الجسم لا يطابق المخطط\nBody does not match the schema","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/tickets":{"get":{"operationId":"tickets_list","tags":["tickets"],"summary":"التذاكر\nTickets","description":"مرتَّبة بأقرب موعدٍ مُعلَّق: العمل الجاري أولاً ثم المعلّقة (بانتظار العميل) ثم المنجزة، وداخل كل مجموعة الأقرب موعداً أولاً (المتجاوزة للمهلة في المقدمة)، ثم الأعلى أولويةً، ثم الأقدم. التذاكر بلا مواعيد (شركة بلا سياسة SLA افتراضية) في آخر مجموعتها. **تغيّر في 2026-09-30:** كان الترتيب بالأولوية أولاً. والمواعيد بالساعة الجدارية — ساعات العمل والعطلات لا تُستهلك بعد.\nOrdered by the nearest outstanding deadline: active work first, then pending (awaiting the customer), then completed; within each group the nearest deadline first (already-breached at the top), then higher priority, then oldest. Tickets with no deadlines (a tenant with no default SLA policy) come last within their group. **Changed on 2026-09-30:** previously ordered by priority first. Deadlines are wall-clock — business hours and holidays are not yet consumed.\n\nالنطاق المطلوب: `tickets.view`\nRequired scope: `tickets.view`","security":[{"ApiKey":[]}],"x-scope":"tickets.view","parameters":[{"name":"status","in":"query","required":false,"description":"الحالة\nStatus","schema":{"type":"string","enum":["new","open","pending","resolved","closed"]}},{"name":"priority","in":"query","required":false,"description":"الأولوية\nPriority","schema":{"type":"string","enum":["low","normal","high","urgent","critical"]}},{"name":"breached","in":"query","required":false,"description":"1 = المتجاوزة لـSLA فقط\n1 = SLA-breached only","schema":{"type":"string","enum":["1"]}},{"name":"q","in":"query","required":false,"description":"بحث في الموضوع أو الرقم\nSearch subject or number","schema":{"type":"string"}}],"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"tickets":[{"id":"t1…","number":"T-1042","subject":"…","status":"open","priority":"high","resolve_due_at":"…","sla_resolve_breached":false,"contact_name":"…","created_at":"…","origin":"agent"}]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"tickets_create","tags":["tickets"],"summary":"إنشاء تذكرة\nCreate a ticket","description":"الردّ يحمل `origin` = مصدر التذكرة: `api` لما يُفتح بمفتاح بوابة المطوّرين، `agent` لجلسة موظف، `bot` للوكيل الآلي. ومحادثةٌ واحدة تقبل عدة تذاكر بمفتاحك، ولا تقبل إلا تذكرةً آليةً واحدة.\nThe response carries `origin` — the ticket's source: `api` when opened with a developer API key, `agent` for a staff session, `bot` for the automated agent. One conversation accepts several tickets from your key, but only a single automated one.\n\nالنطاق المطلوب: `tickets.create`\nRequired scope: `tickets.create`","security":[{"ApiKey":[]}],"x-scope":"tickets.create","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["subject"],"additionalProperties":false,"properties":{"subject":{"type":"string","minLength":2,"maxLength":300,"description":"الموضوع\nSubject"},"description":{"type":"string","maxLength":20000,"description":"الوصف\nDescription"},"priority":{"type":"string","enum":["low","normal","high","urgent","critical"],"description":"الأولوية\nPriority"},"category":{"type":"string","maxLength":120,"description":"التصنيف — يحدّد سياسة SLA\nCategory — selects the SLA policy"},"contact_id":{"type":"string","description":"العميل\nContact"},"conversation_id":{"type":"string","description":"محادثة مرتبطة — يرث عميلها\nLinked conversation — inherits its contact"}}},"example":{"subject":"خطأ في الفاتورة","category":"فوترة","priority":"high"}}}},"responses":{"201":{"description":"أُنشئ\nCreated","content":{"application/json":{"example":{"id":"t1…","number":"T-1043","subject":"…","status":"new","priority":"high","resolve_due_at":"…","origin":"api"}}}},"400":{"description":"الجسم لا يطابق المخطط\nBody does not match the schema","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/tickets/{id}":{"get":{"operationId":"tickets_get","tags":["tickets"],"summary":"تذكرة بسجل أحداثها\nTicket with its event log","description":"النطاق المطلوب: `tickets.view`\nRequired scope: `tickets.view`","security":[{"ApiKey":[]}],"x-scope":"tickets.view","parameters":[{"name":"id","in":"path","required":true,"description":"المعرّف (UUID)\nIdentifier (UUID)","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"ticket":{"id":"t1…","number":"T-1043","status":"open"},"events":[{"type":"created","at":"…"}]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"غير موجود\nNot found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"operationId":"tickets_update","tags":["tickets"],"summary":"تحديث الحالة/الأولوية/التصنيف\nUpdate status/priority/category","description":"النطاق المطلوب: `tickets.update`\nRequired scope: `tickets.update`","security":[{"ApiKey":[]}],"x-scope":"tickets.update","parameters":[{"name":"id","in":"path","required":true,"description":"المعرّف (UUID)\nIdentifier (UUID)","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"status":{"type":"string","enum":["new","open","pending","resolved","closed"],"description":"الحالة\nStatus"},"priority":{"type":"string","enum":["low","normal","high","urgent","critical"],"description":"الأولوية\nPriority"},"assignee_id":{"type":["string","null"],"description":"معرّف الموظف أو null لإلغاء الإسناد\nUser id or null to unassign"},"category":{"type":["string","null"],"maxLength":120,"description":"التصنيف\nCategory"}}},"example":{"status":"resolved"}}}},"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"id":"t1…","number":"T-1043","status":"resolved","priority":"high","assignee_id":null,"resolved_at":"…"}}}},"400":{"description":"الجسم لا يطابق المخطط\nBody does not match the schema","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"غير موجود\nNot found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts":{"get":{"operationId":"contacts_list","tags":["contacts"],"summary":"العملاء وهوياتهم في القنوات\nContacts with their channel identities","description":"النطاق المطلوب: `conversations.view`\nRequired scope: `conversations.view`","security":[{"ApiKey":[]}],"x-scope":"conversations.view","parameters":[{"name":"q","in":"query","required":false,"description":"بحث بالاسم أو العنوان\nSearch by name or address","schema":{"type":"string"}}],"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"contacts":[{"id":"k1…","full_name":"سارة","is_lead":false,"conversations":2,"tickets":1,"identities":[{"channel":"whatsapp","address":"+9665…"}]}]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}":{"get":{"operationId":"contacts_get","tags":["contacts"],"summary":"ملف العميل 360\nContact 360 profile","description":"النطاق المطلوب: `conversations.view`\nRequired scope: `conversations.view`","security":[{"ApiKey":[]}],"x-scope":"conversations.view","parameters":[{"name":"id","in":"path","required":true,"description":"المعرّف (UUID)\nIdentifier (UUID)","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"contact":{"id":"k1…","full_name":"…"},"identities":[],"conversations":[],"tickets":[],"appointments":[]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"غير موجود\nNot found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/overview":{"get":{"operationId":"reports_overview","tags":["reports"],"summary":"مؤشرات الأداء وSLA والرضا\nKPIs, SLA and CSAT overview","description":"النطاق المطلوب: `reports.view`\nRequired scope: `reports.view`","security":[{"ApiKey":[]}],"x-scope":"reports.view","parameters":[{"name":"days","in":"query","required":false,"description":"نافذة الأيام (افتراضي 30، أقصى 365)\nWindow in days (default 30, max 365)","schema":{"type":"integer"}},{"name":"from","in":"query","required":false,"description":"بداية مدى مطلق (YYYY-MM-DD، بتوقيت UTC) — بديل عن days\nAbsolute range start (YYYY-MM-DD, UTC) — alternative to days","schema":{"type":"string"}},{"name":"to","in":"query","required":false,"description":"نهاية المدى المطلق (يشمل اليوم نفسه)\nAbsolute range end (inclusive of that day)","schema":{"type":"string"}},{"name":"agent_id","in":"query","required":false,"description":"قصر النتائج على وكيل واحد\nRestrict to a single agent","schema":{"type":"string"}},{"name":"channel_type","in":"query","required":false,"description":"قصر النتائج على نوع قناة\nRestrict to one channel type","schema":{"type":"string"}},{"name":"category","in":"query","required":false,"description":"قصر النتائج على تصنيف تذاكر\nRestrict to one ticket category","schema":{"type":"string"}}],"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"window_days":30,"conversations":{"total":310,"open":12},"tickets":{"total":120,"open":9,"breached":4,"reopened":2,"avg_first_response_minutes":14,"avg_resolution_minutes":240},"sla":{"compliance_percent":96.7,"indicator":"green"},"fcr":{"resolved":96,"first_contact":71,"percent":74},"csat":{"avg_score":4.6,"responses":41},"by_channel":[{"channel":"whatsapp","conversations":200}],"by_status":[{"status":"open","n":9}]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/calls":{"post":{"operationId":"calls_create","tags":["voice"],"summary":"بدء مكالمة صادرة\nStart an outbound call","description":"النطاق المطلوب: `voice.manage`\nRequired scope: `voice.manage`","security":[{"ApiKey":[]}],"x-scope":"voice.manage","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["to"],"additionalProperties":false,"properties":{"to":{"type":"string","minLength":3,"maxLength":32,"description":"الرقم بصيغة دولية\nE.164 number"},"from_extension":{"type":"string","maxLength":16,"description":"تحويلة الموظف التي تُوصل بالعميل\nAgent extension to bridge"}}},"example":{"to":"+9665xxxxxxx","from_extension":"1001"}}}},"responses":{"202":{"description":"قُبل الطلب\nAccepted","content":{"application/json":{"example":{"call_uuid":"7b0f6f0e-5c3a-4a53-9c4a-3f2f1f4e9a10","status":"dialing","from_extension":"1001","to_masked":"***4567"}}}},"400":{"description":"الجسم لا يطابق المخطط\nBody does not match the schema","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks":{"get":{"operationId":"webhooks_list","tags":["webhooks"],"summary":"اشتراكات الـWebhooks\nWebhook subscriptions","description":"النطاق المطلوب: `settings.integrations`\nRequired scope: `settings.integrations`","security":[{"ApiKey":[]}],"x-scope":"settings.integrations","responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"subscriptions":[{"id":"w1…","url":"https://…/hooks/avenor","events":["message.received"],"active":true,"last_status":200,"last_error":null,"last_delivery_at":"…","secret_hint":"whsec_ab…"}]}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"operationId":"webhooks_create","tags":["webhooks"],"summary":"اشتراك جديد — السرّ يظهر مرة واحدة\nNew subscription — the secret is shown once","description":"النطاق المطلوب: `settings.integrations`\nRequired scope: `settings.integrations`","security":[{"ApiKey":[]}],"x-scope":"settings.integrations","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url","events"],"additionalProperties":false,"properties":{"url":{"type":"string","minLength":8,"maxLength":500,"description":"عنوان https يستقبل POST\nhttps endpoint receiving POST"},"events":{"type":"array","minItems":1,"maxItems":10,"items":{"type":"string","enum":["conversation.created","message.received","ticket.created","ticket.updated"]},"description":"الأحداث المطلوبة\nSubscribed events"}}},"example":{"url":"https://example.com/hooks/avenor","events":["message.received","ticket.created"]}}}},"responses":{"201":{"description":"أُنشئ\nCreated","content":{"application/json":{"example":{"id":"w1…","url":"…","events":["message.received"],"active":true,"secret":"whsec_…"}}}},"400":{"description":"الجسم لا يطابق المخطط\nBody does not match the schema","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/webhooks/{id}":{"delete":{"operationId":"webhooks_delete","tags":["webhooks"],"summary":"إلغاء اشتراك\nRemove a subscription","description":"النطاق المطلوب: `settings.integrations`\nRequired scope: `settings.integrations`","security":[{"ApiKey":[]}],"x-scope":"settings.integrations","parameters":[{"name":"id","in":"path","required":true,"description":"المعرّف (UUID)\nIdentifier (UUID)","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"نجاح\nOK","content":{"application/json":{"example":{"deleted":true,"id":"w1…"}}}},"401":{"description":"مفتاح مفقود أو غير صالح (المفتاح لمسارات /v1 فقط)\nMissing or invalid key (keys work on /v1 routes only)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"المفتاح لا يملك النطاق المطلوب\nKey lacks the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"غير موجود\nNot found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"تجاوز حدّ المعدل — انظر Retry-After\nRate limited — see Retry-After","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"X-API-Key","description":"مفتاح يبدأ بـ`avx_`\nKey starting with `avx_`"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"رمز ثابت يُبرمَج عليه\nStable machine-readable code"},"message":{"type":"string","description":"رسالة عربية للعرض\nArabic human-readable message"},"request_id":{"type":"string","description":"يظهر مع 500 — أرفقه عند الإبلاغ\nPresent on 500 — quote it when reporting"}}}}}}},"x-scopes":["conversations.view","conversations.update","tickets.view","tickets.create","tickets.update","reports.view","voice.manage","settings.integrations"],"x-webhooks":{"events":["conversation.created","message.received","ticket.created","ticket.updated"],"headers":{"X-Avenor-Event":"اسم الحدث\nEvent name","X-Avenor-Timestamp":"ثوانٍ Unix وقت الإرسال\nUnix seconds at send time","X-Avenor-Signature":"sha256=HMAC-SHA256(secret, raw_body) بالست عشري\nsha256=hex HMAC-SHA256 of the raw body with the subscription secret"},"envelope":{"id":"uuid","event":"message.received","created_at":"ISO-8601","tenant_id":"uuid","data":{}},"delivery":"مهلة 10 ثوانٍ، محاولة إعادة واحدة بعد 1.5 ثانية، ويُعدّ أي ردّ 2xx نجاحاً\n10s timeout, one retry after 1.5s; any 2xx counts as delivered"}}