API संदर्भ
Asyntai REST 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 के माध्यम से आपके खाते तक पहुँच सकता है। इसे कभी भी क्लाइंट-साइड कोड में उजागर न करें।
बेस URL
https://asyntai.com/api/v1/
एंडपॉइंट्स
POST /chat/
एक संदेश भेजें और AI-जनित प्रतिक्रिया प्राप्त करें।
अनुरोध बॉडी
{
"message": "What are your business hours?",
"session_id": "user_123", // optional
"website_id": 1 // optional
}
| पैरामीटर | प्रकार | आवश्यक | विवरण |
|---|---|---|---|
message |
string | हाँ | AI को भेजने के लिए उपयोगकर्ता का संदेश |
session_id |
string | नहीं | वार्तालाप के लिए अद्वितीय पहचानकर्ता। वार्तालाप इतिहास बनाए रखने के लिए समान session_id का उपयोग करें। |
website_id |
integer | नहीं | विशिष्ट वेबसाइट ID। यदि प्रदान नहीं किया गया है, तो आपकी प्राथमिक वेबसाइट का उपयोग करता है। |
प्रतिक्रिया
{
"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 | हाँ | जिस सत्र का इतिहास प्राप्त करना है उसकी सत्र ID |
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/
अपने हाल के चैट सत्रों की सूची बनाएं। सत्र ID खोजने के लिए इसका उपयोग करें, जिन्हें आप पूर्ण संदेश इतिहास प्राप्त करने के लिए /conversations/ को पास कर सकते हैं।
क्वेरी पैरामीटर
| पैरामीटर | प्रकार | आवश्यक | विवरण |
|---|---|---|---|
limit |
integer | नहीं | लौटाने के लिए हाल के सत्रों की संख्या (डिफ़ॉल्ट: 20, अधिकतम: 100) |
website_id |
string | नहीं | किसी विशिष्ट वेबसाइट ID द्वारा सत्र फ़िल्टर करें |
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 |
आगंतुक ने चैट कब खोली. यह केवल विजेट सत्रों के लिए उपलब्ध है, क्योंकि API से बनाए गए सत्र कभी विजेट नहीं खोलते. |
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 किसी विशिष्ट को लक्षित करने के लिए। आप अपनी वेबसाइट ID इसका उपयोग करके खोज सकते हैं GET /websites/.
दैनिक अपलोड सीमाएँ: ज्ञान आधार अपलोड (टेक्स्ट, URL, स्प्रेडशीट) आपके Free, Starter, Standard या Pro प्लान के आधार पर दैनिक वर्ण सीमा के अधीन हैं। यह प्रति दिन सभी ज्ञान आधार एंडपॉइंट्स पर अपलोड की गई कुल सामग्री पर लागू होता है।
| प्लान | वर्ण/दिन |
|---|---|
| Starter | 3,00,000 |
| Standard | 15,00,000 |
| Pro | 60,00,000 |
GET /knowledge/
अपनी ज्ञान आधार प्रविष्टियों की सूची बनाएं। ये वे सामग्री स्रोत हैं जिनका उपयोग आपका AI चैटबॉट प्रश्नों का उत्तर देने के लिए करता है।
क्वेरी पैरामीटर
| पैरामीटर | प्रकार | आवश्यक | विवरण |
|---|---|---|---|
limit |
integer | नहीं | लौटाने के लिए प्रविष्टियों की संख्या (डिफ़ॉल्ट: 50, अधिकतम: 100) |
website_id |
string | नहीं | वेबसाइट ID द्वारा फ़िल्टर करें (डिफ़ॉल्ट रूप से आपकी प्राथमिक वेबसाइट) |
प्रतिक्रिया
{
"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/
अपने ज्ञान आधार में कस्टम टेक्स्ट सामग्री जोड़ें। AI इसका उपयोग विज़िटर प्रश्नों का उत्तर देने के लिए करेगा।
अनुरोध बॉडी
{
"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 | हाँ | जहां से सामग्री प्राप्त करनी है वह URL |
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) स्प्रेडशीट अपलोड करें। प्रत्येक पंक्ति एक अलग ज्ञान प्रविष्टि बन जाती है, जो उत्पाद कैटलॉग, FAQ सूचियों, मूल्य तालिकाओं और निर्देशिकाओं के लिए आदर्श है।
अनुरोध
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"
सुझाव: आप वेबहुक्स को यहां से भी प्रबंधित कर सकते हैं API सेटिंग्स पेज से बिना कोई कोड लिखे।
GET /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/
रियल-टाइम इवेंट सूचनाएँ प्राप्त करने के लिए एक नया वेबहुक पंजीकृत करें।
उपलब्ध इवेंट्स
| इवेंट | विवरण |
|---|---|
message.received |
एक विज़िटर ने संदेश भेजा और प्रतिक्रिया प्राप्त की |
conversation.started |
एक नया चैट सत्र शुरू हुआ |
escalation.requested |
AI ने मानव एजेंट तक एस्केलेशन ट्रिगर किया |
takeover.started |
एक मानव एजेंट ने चैट सत्र अपने हाथ में लिया |
अनुरोध बॉडी
{
"url": "https://example.com/webhook",
"events": ["message.received", "escalation.requested"],
"website_id": "123"
}
| पैरामीटर | प्रकार | आवश्यक | विवरण |
|---|---|---|---|
url |
string | हाँ | वेबहुक POST अनुरोध प्राप्त करने के लिए HTTPS URL |
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"
}
}
वेबहुक्स सत्यापित करना: प्रत्येक वेबहुक में एक secret (केवल निर्माण पर दिखाया जाता है)। आपके URL पर हर POST में एक शामिल होता है X-Webhook-Signature header — आपके secret से साइन किया गया request body का 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}/
एक वेबहुक हटाएं। 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 |
Bad Request - अमान्य पैरामीटर या आवश्यक फ़ील्ड गायब हैं |
401 |
अनधिकृत - अमान्य या अनुपस्थित API कुंजी |
429 |
Too Many Requests - आपकी plan के लिए संदेश सीमा पूरी हो गई |
503 |
सेवा अनुपलब्ध - AI सेवा अस्थायी रूप से अनुपलब्ध |
दर सीमाएँ
API उपयोग आपके subscription plan द्वारा सीमित है:
- Free: 100 संदेश/माह
- Starter ($39/माह): 2,500 संदेश/माह
- Standard ($139/माह): 15,000 संदेश/माह
- Pro ($449/माह): 50,000 संदेश/माह
मदद चाहिए?
यदि आपके कोई प्रश्न हैं या कोई समस्या आती है, तो हमसे [email protected] पर संपर्क करें।