العودة إلى لوحة التحكم

التوثيق

تعلّم كيفية استخدام Asyntai

الميزات
شريط Ask AI شريط البحث بالذكاء الاصطناعي بحث الذكاء الاصطناعي لووردبريس زحف الموقع فجوات المعرفة بطاقات المنتجات بطاقات المنتجات الديناميكية صور ديناميكية سياق المستخدم الأدوات المخصصة معلمات الروابط المراقبة المباشرة التحكم البشري التصعيد إشعارات الذكاء الاصطناعي التقرير اليومي تغذية البيانات في الوقت الفعلي تغذية البيانات في الوقت الفعلي - الحد الأقصى أعضاء الفريق تسجيل الدخول الموحد المصادقة الثنائية تضمين الصور رؤية الصور أداة الترجمة الترجمة والتوطين شفافية الذكاء الاصطناعي العملاء المحتملون التقاط العملاء المحتملين الذكي تذاكر الدعم الحجوزات تضمينات استبعاد الصفحات عناوين IP المحظورة سياسة الاحتفاظ بالبيانات وضع عدم الاحتفاظ إخفاء البيانات الشخصية مصنّف الردود Access Tags تثبيت إصدار الأداة سجل التدقيق النموذج الأذكى تفعيل التفكير اقتراحات الردود رسائل المتابعة تحويل الكلام إلى نص تنزيل النص الكامل الدردشة المضمّنة Iframe Embed

مرجع API

أنشئ تكاملات مخصصة مع Asyntai REST API

الحصول على مفتاح API

يتطلب خطة مدفوعة: الوصول إلى API متاح في خطط Starter و Standard و Pro. عرض الأسعار

نظرة عامة

The Asyntai API allows you to integrate AI-powered customer support into any application. Send messages and receive intelligent responses grounded in your website content and knowledge base.

المصادقة

تتطلب جميع طلبات API المصادقة باستخدام مفتاح API الخاص بك. يمكنك الحصول على مفتاح API من صفحة إعدادات API.

قم بتضمين مفتاح API الخاص بك في الطلبات باستخدام إحدى هذه الطرق:

  • ترويسة Authorization (موصى بها): Authorization: Bearer YOUR_API_KEY
  • ترويسة X-API-Key: X-API-Key: YOUR_API_KEY

حافظ على سرية مفتاح API الخاص بك. يمكن لأي شخص يمتلك مفتاحك الوصول إلى حسابك عبر API. لا تكشفه أبداً في الكود من جانب العميل.

الرابط الأساسي

https://asyntai.com/api/v1/

نقاط النهاية

POST /chat/

أرسل رسالة واستقبل رداً مُنشأً بالذكاء الاصطناعي.

نص الطلب

{
  "message": "What are your business hours?",
  "session_id": "user_123",      // optional
  "website_id": 1                 // optional
}
المعامل النوع مطلوب الوصف
message string نعم رسالة المستخدم لإرسالها إلى الذكاء الاصطناعي
session_id string لا معرّف فريد للمحادثة. استخدم نفس session_id للحفاظ على سجل المحادثة.
website_id integer لا معرّف الموقع المحدد. إذا لم يُقدَّم، يُستخدم موقعك الأساسي.

الاستجابة

{
  "success": true,
  "response": "Our business hours are Monday-Friday, 9 AM to 5 PM EST.",
  "session_id": "user_123"
}

مثال (cURL)

curl -X POST https://asyntai.com/api/v1/chat/ \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message": "What are your business hours?", "session_id": "user_123"}'

مثال (Python)

import requests

response = requests.post(
    "https://asyntai.com/api/v1/chat/",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json"
    },
    json={
        "message": "What are your business hours?",
        "session_id": "user_123"
    }
)

data = response.json()
print(data["response"])

مثال (JavaScript)

const response = await fetch("https://asyntai.com/api/v1/chat/", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    message: "What are your business hours?",
    session_id: "user_123"
  })
});

const data = await response.json();
console.log(data.response);

GET /websites/

عرض جميع المواقع المرتبطة بحسابك.

الاستجابة

{
  "success": true,
  "websites": [
    {
      "id": 1,
      "name": "My Website",
      "domain": "example.com",
      "is_primary": true
    }
  ]
}

مثال (cURL)

curl https://asyntai.com/api/v1/websites/ \
  -H "Authorization: Bearer YOUR_API_KEY"

POST /websites/

Create a new AI agent. This does the same thing as adding a website in your dashboard: it makes the agent, reads your site, and writes the first draft of the AI instructions.

Use this to set up customers from your own software. You get back the widget ID and the code to put on the website.

نص الطلب

الحقل النوع الوصف
domain string Required. The website address, for example example.com
name string Optional. A display name for the agent. Useful when one website has several agents.
crawl boolean Optional, true by default. Set it to false to create the agent without reading the website. Nothing is crawled and no instructions are written.
force boolean Optional, false by default. Set it to true to add a website you already have. The copy is stored with a number after it.

الاستجابة

{
  "success": true,
  "website": {
    "id": 42,
    "domain": "example.com",
    "name": "Support agent",
    "widget_id": "asyntai_ab12cd34ef56",
    "is_primary": true,
    "crawl_started": true,
    "instructions_status": "generating",
    "job_id": "8f2c1e90-..."
  },
  "embed_code": "<script>...</script>"
}

مثال (cURL)

curl -X POST https://asyntai.com/api/v1/websites/ \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"domain": "example.com", "name": "Support agent"}'

Reading a website takes a few minutes, so this call answers straight away. Check when the agent is ready with the next endpoint.

Errors

Code Meaning
403 You have reached the number of websites your plan allows. The answer tells you the limit.
409 Your account already has this website. Send force as true to add it again.

GET /websites/{id}/

Get one website and see whether it is ready. Use this after you create an agent, to wait until the website has been read and the AI instructions are written.

الاستجابة

{
  "success": true,
  "website": {
    "id": 42,
    "domain": "example.com",
    "name": "Support agent",
    "widget_id": "asyntai_ab12cd34ef56",
    "is_primary": true,
    "created_at": "2026-08-11T09:12:00+00:00",
    "ready": true,
    "instructions": {
      "status": "completed",
      "has_instructions": true,
      "characters": 3421
    },
    "crawl": {
      "job_id": "8f2c1e90-...",
      "status": "completed",
      "pages_crawled": 47,
      "pages_found": 50,
      "max_pages": 50,
      "completed_at": "2026-08-11T09:15:31+00:00",
      "error": ""
    },
    "knowledge_items": 47
  },
  "embed_code": "<script>...</script>"
}

The ready field is true when nothing is still running. A crawl that failed also counts as ready, because it has finished. Look at the crawl status to see what happened.

مثال (cURL)

curl https://asyntai.com/api/v1/websites/42/ \
  -H "Authorization: Bearer YOUR_API_KEY"

GET PATCH /websites/{id}/settings/

Read or change the chat widget settings for one website. These are the same settings you see on the Customize page: colours, the name of the assistant, the first message, lead capture, and everything else.

Reading the settings

A GET request returns every setting with its current value, plus a locked list. Locked shows the settings your plan cannot change, and which plans they need.

{
  "success": true,
  "settings": {
    "ai_support_name": "AI Assistant",
    "widget_color": "#6366f1",
    "initial_message": "Hi, how can I help you?",
    "hide_branding": false,
    "...": "..."
  },
  "locked": {
    "hide_branding": ["pro", "enterprise"],
    "widget_style": ["pro", "enterprise"]
  }
}

Changing the settings

A PATCH request changes only the settings you send. Everything you leave out stays as it is.

curl -X PATCH https://asyntai.com/api/v1/websites/42/settings/ \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ai_support_name": "Ava", "widget_color": "#0f172a", "use_emoji": true}'
{
  "success": true,
  "updated": ["ai_support_name", "use_emoji", "widget_color"],
  "settings": { "...": "..." },
  "locked": { "...": "..." }
}

Plans

Each setting needs its own plan, the same as in the dashboard. For example, hiding the Asyntai branding needs the Pro plan, and voice input needs Standard.

Plan needed الإعدادات Examples
Any paid plan 25 widget_color, ai_support_name, initial_message
Starter وأعلى 22 profile_picture, conversation_starters_enabled
Standard وأعلى 25 speech_to_text_enabled, image_vision_enabled, escalation_enabled
Pro 6 hide_branding, widget_style

If you send a setting your plan does not allow, the whole request is refused with code 403 and nothing is saved. The same happens if any value is wrong, for example a colour that is not a hex code. Your settings never end up half changed.

GET PUT /websites/{id}/instructions/

Read or replace the AI instructions for one website. These are the rules that tell the assistant who it is, what it may say, and what it must not say. They are the same instructions you edit in the dashboard.

Reading

{
  "success": true,
  "instructions": "You are the support agent for Acme Tools...",
  "characters": 1979,
  "version": 7,
  "mode": "instructions",
  "ask_questions": true,
  "generation_status": "completed",
  "being_edited_by": null
}

Replacing

A PUT request replaces the whole text, the same as saving in the dashboard. There is no append mode. To add a paragraph, read the instructions, add your text, then write it back.

curl -X PUT https://asyntai.com/api/v1/websites/42/instructions/ \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"instructions": "You are the support agent for Acme Tools...", "version": 7}'

نص الطلب

الحقل النوع الوصف
instructions string Required. The complete new text. It replaces everything that was there.
version number Optional but recommended. The version you read. If somebody changed the instructions since then, your write is refused instead of overwriting their work.
mode string Optional. Either instructions or general.
ask_questions boolean Optional. Whether the assistant asks a follow-up question at the end of its answers.
force boolean Optional, false by default. Needed only when your new text is less than half the length of the current text.

How your instructions are protected

Instructions can take hours to write, so a write can be refused to protect them:

Code Meaning
400 Your new text is less than half the length of the current text. This catches a script that sends empty or cut-off text over instructions somebody spent hours on. Send force as true if you meant it.
409 The instructions changed after you read them. Read them again, apply your change, then write.
423 Somebody is editing the instructions in the dashboard right now. The answer tells you who. Try again in a couple of minutes.

Every change also saves a copy of the previous text, so an earlier version can always be restored from the dashboard.

GET /conversations/

استرجاع سجل المحادثة لجلسة محددة.

معاملات الاستعلام

المعامل النوع مطلوب الوصف
session_id string نعم معرّف الجلسة لاسترجاع السجل
limit integer لا الحد الأقصى للرسائل المُرجعة (الافتراضي: 50، الحد الأقصى: 100)

الاستجابة

{
  "success": true,
  "session_id": "user_123",
  "messages": [
    {
      "role": "user",
      "content": "What are your business hours?",
      "timestamp": "2024-01-15T10:30:00Z"
    },
    {
      "role": "assistant",
      "content": "Our business hours are Monday-Friday, 9 AM to 5 PM EST.",
      "timestamp": "2024-01-15T10:30:01Z",
      "sender_type": "ai",
      "agent_name": null,
      "response_time_ms": 1840.5
    }
  ]
}

يتم تخزين السؤال وإجابته في سجل واحد، لذلك يحمل كلاهما نفس timestamp. لا تطرح أحدهما من الآخر لقياس سرعة الرد، لأن النتيجة تكون دائمًا صفرًا. استخدم response_time_ms، وهو الوقت الفعلي الذي استغرقته الإجابة، بالمللي ثانية.

تكون قيمة sender_type هي ai عندما يجيب روبوت الدردشة، وhuman عندما يتولى أحد وكلائك الدردشة. ويحتوي agent_name على الاسم المعروض لذلك الوكيل.

مثال (cURL)

curl "https://asyntai.com/api/v1/conversations/?session_id=user_123&limit=20" \
  -H "Authorization: Bearer YOUR_API_KEY"

GET /sessions/

عرض جلسات المحادثة الأخيرة. استخدم هذا لاكتشاف معرّفات الجلسات، والتي يمكنك تمريرها إلى /conversations/ لاسترجاع سجل الرسائل الكامل.

معاملات الاستعلام

المعامل النوع مطلوب الوصف
limit integer لا عدد الجلسات الأخيرة المُرجعة (الافتراضي: 20، الحد الأقصى: 100)
website_id string لا تصفية الجلسات حسب معرّف موقع محدد
source string لا تصفية حسب مصدر الجلسة: widget، api، whatsapp، instagram، messenger، gorgias، freshchat، zapier

الاستجابة

{
  "success": true,
  "sessions": [
    {
      "session_id": "session_abc123def",
      "source": "widget",
      "message_count": 5,
      "first_message": "What are your business hours?",
      "first_message_at": "2024-01-15T10:30:00Z",
      "last_message_at": "2024-01-15T10:35:00Z",
      "first_response_time_ms": 1840.5,
      "first_human_response_at": null,
      "started_at": "2024-01-15T10:29:58Z",
      "ended_at": "2024-01-15T10:41:12Z",
      "taken_over_at": null,
      "website_domain": "example.com"
    }
  ]
}

حقول الطابع الزمني لإعداد التقارير

الحقل الوصف
started_at وقت فتح الزائر للدردشة. متاح لجلسات الأداة فقط، لأن الجلسات التي تُنشأ عبر واجهة برمجة التطبيقات لا تفتح أداة أبدًا.
first_message_at وقت تخزين أول رسالة في المحادثة.
first_response_time_ms المدة التي استغرقتها الإجابة الأولى، بالمللي ثانية. استخدم هذا لقياس زمن الرد الأول.
first_human_response_at وقت إرسال أحد وكلائك للرد الأول. تكون القيمة null عندما يتولى روبوت الدردشة المحادثة بأكملها.
taken_over_at وقت تولي الوكيل الدردشة من روبوت الدردشة.
last_message_at وقت تخزين آخر رسالة في المحادثة.
ended_at وقت مغادرة الزائر للدردشة. لا تحتوي الدردشة على حالة محلولة أو مغلقة، لأن الزائر يمكنه دائمًا العودة وطرح سؤال آخر.

جميع الطوابع الزمنية بتوقيت UTC وتستخدم تنسيق ISO 8601. لا يمكنك تغيير المنطقة الزمنية. حوّل القيم في أداة إعداد التقارير الخاصة بك.

مثال (cURL)

curl "https://asyntai.com/api/v1/sessions/?limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

GET /leads/

استرجاع العملاء المحتملين المجمعين — عناوين البريد الإلكتروني وأرقام الهواتف التي قدمها الزوار خلال محادثات الدردشة.

معاملات الاستعلام

المعامل النوع مطلوب الوصف
limit integer لا عدد العملاء المحتملين المُرجعين (الافتراضي: 50، الحد الأقصى: 100)
website_id string لا تصفية العملاء المحتملين حسب معرّف موقع محدد

الاستجابة

{
  "success": true,
  "leads": [
    {
      "session_id": "session_abc123def",
      "email": "[email protected]",
      "phone": "+1234567890",
      "page_url": "https://example.com/pricing",
      "started_at": "2024-01-15T10:30:00Z"
    }
  ]
}
الحقل النوع الوصف
session_id string معرف جلسة الدردشة. مرره إلى /conversations/ لرؤية سجل الدردشة الكامل.
email سلسلة نصية أو null عنوان البريد الإلكتروني المقدم من الزائر، أو null إذا لم يتم جمعه
phone سلسلة نصية أو null رقم الهاتف المقدم من الزائر، أو null إذا لم يتم جمعه
page_url سلسلة نصية أو null عنوان URL للصفحة التي كان الزائر يتحدث فيها
started_at string طابع زمني ISO 8601 لوقت بدء جلسة الدردشة

مثال (cURL)

curl "https://asyntai.com/api/v1/leads/?limit=20" \
  -H "Authorization: Bearer YOUR_API_KEY"

مثال (Python)

import requests

response = requests.get(
    "https://asyntai.com/api/v1/leads/",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    params={"limit": 20}
)

leads = response.json()["leads"]
for lead in leads:
    print(f"{lead['email'] or ''} | {lead['phone'] or ''}")

GET /account/

احصل على معلومات حسابك وإحصائيات الاستخدام.

الاستجابة

{
  "success": true,
  "account": {
    "email": "[email protected]",
    "plan": "starter",
    "messages_used": 150,
    "messages_limit": 2500
  }
}

مثال (cURL)

curl https://asyntai.com/api/v1/account/ \
  -H "Authorization: Bearer YOUR_API_KEY"

مواقع متعددة؟ نقاط نهاية قاعدة المعرفة تستخدم موقعك الأساسي افتراضياً. إذا كان لديك مواقع متعددة، مرّر website_id لاستهداف موقع محدد. يمكنك العثور على معرّفات مواقعك باستخدام GET /websites/.

حدود الرفع اليومية: تخضع عمليات رفع قاعدة المعرفة (نص، رابط، جدول بيانات) لحد يومي من الأحرف بناءً على خطتك. ينطبق هذا على إجمالي المحتوى المرفوع عبر جميع نقاط نهاية قاعدة المعرفة يومياً.

الخطة الأحرف/اليوم
Starter300,000
Standard1,500,000
Pro6,000,000

GET /knowledge/

عرض إدخالات قاعدة المعرفة الخاصة بك. هذه هي مصادر المحتوى التي يستخدمها روبوت المحادثة الذكي للإجابة على الأسئلة.

معاملات الاستعلام

المعامل النوع مطلوب الوصف
limit integer لا عدد الإدخالات المُرجعة (الافتراضي: 50، الحد الأقصى: 100)
website_id string لا التصفية حسب معرّف الموقع (الافتراضي: موقعك الأساسي)

الاستجابة

{
  "success": true,
  "entries": [
    {
      "id": "abc-123-def",
      "type": "text",
      "title": "Business Hours",
      "description": "Manual text content (150 words)",
      "created_at": "2024-01-15T10:30:00Z"
    },
    {
      "id": "ghi-456-jkl",
      "type": "url",
      "title": "About Us - Example",
      "description": "Content from https://example.com/about",
      "created_at": "2024-01-14T09:00:00Z"
    }
  ]
}

مثال (cURL)

curl "https://asyntai.com/api/v1/knowledge/?limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

POST /knowledge/text/

أضف محتوى نصياً مخصصاً إلى قاعدة المعرفة. سيستخدم الذكاء الاصطناعي هذا للإجابة على أسئلة الزوار.

نص الطلب

{
  "title": "Return Policy",
  "content": "We offer a 30-day return policy on all items. Items must be unused and in original packaging. Refunds are processed within 5-7 business days.",
  "website_id": "123"
}
المعامل النوع مطلوب الوصف
title string نعم عنوان لهذا الإدخال المعرفي
content string نعم المحتوى النصي (10 أحرف كحد أدنى)
website_id string لا الموقع المستهدف (الافتراضي: موقعك الأساسي)

الاستجابة

{
  "success": true,
  "id": "abc-123-def",
  "title": "Return Policy",
  "chunks_created": 1
}

مثال (cURL)

curl -X POST "https://asyntai.com/api/v1/knowledge/text/" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "Return Policy", "content": "We offer a 30-day return policy..."}'

POST /knowledge/url/

أضف صفحة ويب إلى قاعدة المعرفة. سيتم جلب المحتوى واستخراجه تلقائياً.

نص الطلب

{
  "url": "https://example.com/faq",
  "website_id": "123"
}
المعامل النوع مطلوب الوصف
url string نعم الرابط لجلب المحتوى منه
website_id string لا الموقع المستهدف (الافتراضي: موقعك الأساسي)

الاستجابة

{
  "success": true,
  "id": "abc-123-def",
  "title": "FAQ - Example",
  "url": "https://example.com/faq",
  "chunks_created": 5
}

مثال (cURL)

curl -X POST "https://asyntai.com/api/v1/knowledge/url/" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/faq"}'

POST /knowledge/spreadsheet/

ارفع جدول بيانات CSV أو Excel (.xlsx) إلى قاعدة المعرفة. يصبح كل صف إدخالاً معرفياً منفصلاً، وهو مثالي لكتالوجات المنتجات وقوائم الأسئلة الشائعة وجداول الأسعار والأدلة.

الطلب

أرسل كـ multipart/form-data (رفع ملف)، وليس JSON.

المعامل النوع مطلوب الوصف
file ملف نعم ملف .csv أو .xlsx. يجب أن يكون الصف الأول عناوين الأعمدة. الحد الأقصى للصفوف لكل رفع: Starter 500، Standard 2,000، Pro 10,000. يتم اقتطاع الصفوف الزائدة.
website_id string لا الموقع المستهدف (الافتراضي: موقعك الأساسي)

الاستجابة

{
  "success": true,
  "id": "abc-123-def",
  "title": "products.csv",
  "rows_processed": 15,
  "chunks_created": 15
}

مثال (cURL)

curl -X POST "https://asyntai.com/api/v1/knowledge/spreadsheet/" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "[email protected]"

GET /knowledge/{id}/

اقرأ عنصرًا واحدًا من قاعدة المعرفة، بما في ذلك النص المخزَّن له. القيمة id تأتي من استجابة GET /knowledge/.

يُعاد المحتوى للعناصر التي أضفتها أنت: النصوص والملفات وجداول البيانات وعناوين URL المفردة والفيديوهات. يظهر زحف الموقع في القائمة لكن لا تُعاد صفحاته، لأن المصدر هو موقعك العام الخاص. في هذه الحالة تكون قيمة content هي null ويوضح الحقل reason السبب.

الاستجابة

{
  "success": true,
  "id": "abc-123-def",
  "type": "text",
  "title": "Business Hours",
  "description": "Manual text content (150 words)",
  "created_at": "2024-01-15T10:30:00Z",
  "chunks_count": 3,
  "content": "We are open Monday to Friday, 9am to 5pm...",
  "content_available": true,
  "char_count": 43
}

مثال (cURL)

curl "https://asyntai.com/api/v1/knowledge/abc-123-def/" \
  -H "Authorization: Bearer YOUR_API_KEY"

DELETE /knowledge/{id}/

حذف إدخال من قاعدة المعرفة. يمكن العثور على id من استجابة GET /knowledge/.

الاستجابة

{
  "success": true,
  "message": "Knowledge base entry deleted"
}

مثال (cURL)

curl -X DELETE "https://asyntai.com/api/v1/knowledge/abc-123-def/" \
  -H "Authorization: Bearer YOUR_API_KEY"

نصيحة: يمكنك أيضاً إدارة webhooks من إعدادات API الصفحة دون كتابة أي كود.

GET /webhooks/

عرض webhooks المسجلة لديك.

الاستجابة

{
  "success": true,
  "webhooks": [
    {
      "id": "abc-123-def",
      "url": "https://example.com/webhook",
      "events": ["message.received", "escalation.requested"],
      "is_active": true,
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}

مثال (cURL)

curl "https://asyntai.com/api/v1/webhooks/" \
  -H "Authorization: Bearer YOUR_API_KEY"

POST /webhooks/

سجّل webhook جديداً لاستقبال إشعارات الأحداث في الوقت الفعلي.

الأحداث المتاحة

الحدث الوصف
message.received أرسل زائر رسالة واستقبل رداً
conversation.started بدأت جلسة محادثة جديدة
escalation.requested أطلق الذكاء الاصطناعي تصعيداً إلى وكيل بشري
takeover.started تولّى وكيل بشري جلسة محادثة

نص الطلب

{
  "url": "https://example.com/webhook",
  "events": ["message.received", "escalation.requested"],
  "website_id": "123"
}
المعامل النوع مطلوب الوصف
url string نعم رابط HTTPS لاستقبال طلبات webhook من نوع POST
events array نعم قائمة الأحداث للاشتراك فيها (انظر الجدول أعلاه)
website_id string لا الموقع المستهدف (الافتراضي: موقعك الأساسي)

الاستجابة

{
  "success": true,
  "webhook": {
    "id": "abc-123-def",
    "url": "https://example.com/webhook",
    "events": ["message.received", "escalation.requested"],
    "secret": "whsec_abc123...",
    "created_at": "2024-01-15T10:30:00Z"
  }
}

التحقق من webhooks: يتضمن كل webhook secret (يُعرض فقط عند الإنشاء). كل طلب POST إلى رابطك يتضمن X-Webhook-Signature ترويسة — HMAC-SHA256 لنص الطلب موقّع بسرّك.

مثال (cURL)

curl -X POST "https://asyntai.com/api/v1/webhooks/" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/webhook", "events": ["message.received"]}'

DELETE /webhooks/{id}/

حذف webhook. يمكن العثور على id من استجابة GET /webhooks/.

الاستجابة

{
  "success": true,
  "message": "Webhook deleted"
}

مثال (cURL)

curl -X DELETE "https://asyntai.com/api/v1/webhooks/abc-123-def/" \
  -H "Authorization: Bearer YOUR_API_KEY"

استجابات الأخطاء

تتبع جميع استجابات الأخطاء هذا التنسيق:

{
  "success": false,
  "error": "Error message describing what went wrong"
}
رمز الحالة الوصف
400 طلب غير صالح - معاملات غير صحيحة أو حقول مطلوبة مفقودة
401 غير مصرّح - مفتاح API غير صالح أو مفقود
429 طلبات كثيرة جداً - تم الوصول إلى حد الرسائل لخطتك
503 الخدمة غير متاحة - خدمة الذكاء الاصطناعي غير متاحة مؤقتاً

حدود المعدل

استخدام API محدود بخطة اشتراكك:

  • Free: 100 رسالة/شهر
  • Starter ($39/شهر): 2,500 رسالة/شهر
  • Standard ($139/شهر): 15,000 رسالة/شهر
  • Pro ($449/شهر): 50,000 رسالة/شهر

تحتاج مساعدة؟

إذا كان لديك أي أسئلة أو واجهت مشاكل، تواصل معنا على [email protected].