API-referens
Bygg anpassade integrationer med Asyntai REST API
Betalt abonnemang krävs: API-åtkomst är tillgänglig för Starter-, Standard- och Pro-abonnemang. Visa priser
Översikt
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.
Autentisering
Alla API-förfrågningar kräver autentisering med din API-nyckel. Du kan hämta din API-nyckel från sidan API-inställningar.
Inkludera din API-nyckel i förfrågningar med en av dessa metoder:
- Authorization-header (rekommenderat):
Authorization: Bearer YOUR_API_KEY - X-API-Key-header:
X-API-Key: YOUR_API_KEY
Håll din API-nyckel hemlig. Alla som har din nyckel kan komma åt ditt konto via API:et. Exponera den aldrig i kod på klientsidan.
Bas-URL
https://asyntai.com/api/v1/
Endpoints
POST /chat/
Skicka ett meddelande och ta emot ett AI-genererat svar.
Begäranstext
{
"message": "What are your business hours?",
"session_id": "user_123", // optional
"website_id": 1 // optional
}
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
message |
sträng | Ja | Användarens meddelande att skicka till AI |
session_id |
sträng | Nej | Unik identifierare för konversationen. Använd samma session_id för att behålla konversationshistoriken. |
website_id |
heltal | Nej | Specifikt webbplats-ID. Om det inte anges används din primära webbplats. |
Svar
{
"success": true,
"response": "Our business hours are Monday-Friday, 9 AM to 5 PM EST.",
"session_id": "user_123"
}
Exempel (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"}'
Exempel (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"])
Exempel (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/
Lista alla webbplatser kopplade till ditt konto.
Svar
{
"success": true,
"websites": [
{
"id": 1,
"name": "My Website",
"domain": "example.com",
"is_primary": true
}
]
}
Exempel (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.
Begäranstext
| Fält | Typ | Beskrivning |
|---|---|---|
domain |
sträng | Required. The website address, for example example.com |
name |
sträng | 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. |
Svar
{
"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>"
}
Exempel (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.
Svar
{
"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.
Exempel (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 | Inställningar | Examples |
|---|---|---|
| Any paid plan | 25 | widget_color, ai_support_name, initial_message |
| Starter och högre | 22 | profile_picture, conversation_starters_enabled |
| Standard och högre | 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}'
Begäranstext
| Fält | Typ | Beskrivning |
|---|---|---|
instructions |
sträng | 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 |
sträng | 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/
Hämta konversationshistorik för en specifik session.
Frågeparametrar
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
session_id |
sträng | Ja | Sessions-ID:t för att hämta historik för |
limit |
heltal | Nej | Max meddelanden att returnera (standard: 50, max: 100) |
Svar
{
"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
}
]
}
En fråga och dess svar sparas i samma post, så båda har samma timestamp. Dra inte det ena från det andra för att mäta svarshastigheten, eftersom resultatet alltid blir noll. Använd response_time_ms, som är den verkliga tid svaret tog, i millisekunder.
sender_type är ai när chattboten svarade och human när någon av dina agenter tog över chatten. agent_name innehåller visningsnamnet för den agenten.
Exempel (cURL)
curl "https://asyntai.com/api/v1/conversations/?session_id=user_123&limit=20" \
-H "Authorization: Bearer YOUR_API_KEY"
GET /sessions/
Lista dina senaste chattsessioner. Använd detta för att hitta sessions-ID:n, som du sedan kan skicka till /conversations/ för att hämta hela meddelandehistoriken.
Frågeparametrar
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
limit |
heltal | Nej | Antal senaste sessioner att returnera (standard: 20, max: 100) |
website_id |
sträng | Nej | Filtrera sessioner efter ett specifikt webbplats-ID |
source |
sträng | Nej | Filtrera efter sessionskälla: widget, api, whatsapp, instagram, messenger, gorgias, freshchat, zapier |
Svar
{
"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"
}
]
}
Tidsstämpelfält för rapportering
| Fält | Beskrivning |
|---|---|
started_at |
När besökaren öppnade chatten. Endast tillgängligt för widgetsessioner, eftersom sessioner som skapas via API:et aldrig öppnar en widget. |
first_message_at |
När det första meddelandet i samtalet sparades. |
first_response_time_ms |
Hur lång tid det första svaret tog, i millisekunder. Använd detta för första svarstid. |
first_human_response_at |
När någon av dina agenter skickade det första svaret. Värdet är null när chattboten skötte hela samtalet. |
taken_over_at |
När en agent tog över chatten från chattboten. |
last_message_at |
När det sista meddelandet i samtalet sparades. |
ended_at |
När besökaren lämnade chatten. En chatt har inget löst eller stängt tillstånd, eftersom en besökare alltid kan komma tillbaka och ställa en ny fråga. |
Alla tidsstämplar är i UTC och använder formatet ISO 8601. Du kan inte ändra tidszonen. Konvertera värdena i ditt eget rapporteringsverktyg.
Exempel (cURL)
curl "https://asyntai.com/api/v1/sessions/?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
GET /leads/
Hämta insamlade leads — e-postadresser och telefonnummer som skickats in av besökare under chattkonversationer.
Frågeparametrar
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
limit |
heltal | Nej | Antal leads att returnera (standard: 50, max: 100) |
website_id |
sträng | Nej | Filtrera leads efter ett specifikt webbplats-ID |
Svar
{
"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"
}
]
}
| Fält | Typ | Beskrivning |
|---|---|---|
session_id |
sträng | Chattsessions-ID. Skicka detta till /conversations/ för att se den fullständiga chatthistoriken. |
email |
sträng eller null | E-postadress angiven av besökaren, eller null om den inte samlades in |
phone |
sträng eller null | Telefonnummer angivet av besökaren, eller null om det inte samlades in |
page_url |
sträng eller null | Sidans URL där besökaren chattade |
started_at |
sträng | ISO 8601-tidssämpel för när chattsessionen startade |
Exempel (cURL)
curl "https://asyntai.com/api/v1/leads/?limit=20" \
-H "Authorization: Bearer YOUR_API_KEY"
Exempel (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/
Hämta din kontoinformation och användningsstatistik.
Svar
{
"success": true,
"account": {
"email": "[email protected]",
"plan": "starter",
"messages_used": 150,
"messages_limit": 2500
}
}
Exempel (cURL)
curl https://asyntai.com/api/v1/account/ \
-H "Authorization: Bearer YOUR_API_KEY"
Flera webbplatser? Kunskapsbasens slutpunkter är som standard din primära webbplats. Om du har flera webbplatser, skicka website_id för att rikta mot en specifik. Du hittar dina webbplats-ID:n med GET /websites/.
Dagliga uppladdningsgränser: Uppladdningar till kunskapsbasen (text, URL, kalkylblad) är föremål för en daglig teckengräns baserad på din plan. Detta gäller det totala innehållet som laddas upp över alla kunskapsbasslutpunkter per dag.
| Plan | Tecken/dag |
|---|---|
| Starter | 300 000 |
| Standard | 1 500 000 |
| Pro | 6 000 000 |
GET /knowledge/
Lista dina kunskapsbaserade poster. Det är de innehållskällor din AI-chattbot använder för att besvara frågor.
Frågeparametrar
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
limit |
heltal | Nej | Antal poster att returnera (standard: 50, max: 100) |
website_id |
sträng | Nej | Filtrera efter webbplats-ID (standardvärde är din primära webbplats) |
Svar
{
"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"
}
]
}
Exempel (cURL)
curl "https://asyntai.com/api/v1/knowledge/?limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"
POST /knowledge/text/
Lägg till anpassat textinnehåll i din kunskapsbas. AI:n använder detta för att svara på besökares frågor.
Begäranstext
{
"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"
}
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
title |
sträng | Ja | En titel för den här kunskapsposten |
content |
sträng | Ja | Textinnehållet (minst 10 tecken) |
website_id |
sträng | Nej | Målwebbplats (standard är din primära webbplats) |
Svar
{
"success": true,
"id": "abc-123-def",
"title": "Return Policy",
"chunks_created": 1
}
Exempel (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/
Lägg till en webbsida i din kunskapsbas. Innehållet hämtas och extraheras automatiskt.
Begäranstext
{
"url": "https://example.com/faq",
"website_id": "123"
}
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
url |
sträng | Ja | URL:en att hämta innehåll från |
website_id |
sträng | Nej | Målwebbplats (standard är din primära webbplats) |
Svar
{
"success": true,
"id": "abc-123-def",
"title": "FAQ - Example",
"url": "https://example.com/faq",
"chunks_created": 5
}
Exempel (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/
Ladda upp ett CSV- eller Excel-kalkylark (.xlsx) till din kunskapsbas. Varje rad blir en separat kunskapspost, idealiskt för produktkataloger, FAQ-listor, pristabeller och kataloger.
Begäran
Skicka som multipart/form-data (filuppladdning), inte JSON.
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
file |
fil | Ja | En .csv- eller .xlsx-fil. Första raden måste vara kolumnrubriker. Max rader per uppladdning: Starter 500, Standard 2 000, Pro 10 000. Överskjutande rader avkortas. |
website_id |
sträng | Nej | Målwebbplats (standard är din primära webbplats) |
Svar
{
"success": true,
"id": "abc-123-def",
"title": "products.csv",
"rows_processed": 15,
"chunks_created": 15
}
Exempel (cURL)
curl -X POST "https://asyntai.com/api/v1/knowledge/spreadsheet/" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "[email protected]"
GET /knowledge/{id}/
Läs en post i kunskapsbasen, inklusive texten som är sparad för den. Värdet id kommer från svaret på GET /knowledge/.
Innehåll returneras för de poster du själv har lagt till: text, filer, kalkylblad, enskilda URL:er och videor. En webbplatsgenomsökning visas i listan, men dess sidor returneras inte, eftersom källan är din egen offentliga webbplats. I så fall är content lika med null och fältet reason förklarar varför.
Svar
{
"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
}
Exempel (cURL)
curl "https://asyntai.com/api/v1/knowledge/abc-123-def/" \
-H "Authorization: Bearer YOUR_API_KEY"
DELETE /knowledge/{id}/
Radera en kunskapsbaspost. id hittas i svaret från GET /knowledge/.
Svar
{
"success": true,
"message": "Knowledge base entry deleted"
}
Exempel (cURL)
curl -X DELETE "https://asyntai.com/api/v1/knowledge/abc-123-def/" \
-H "Authorization: Bearer YOUR_API_KEY"
Tips: Du kan också hantera webhooks från API-inställningar sida utan att skriva någon kod.
GET /webhooks/
Lista dina registrerade webhooks.
Svar
{
"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"
}
]
}
Exempel (cURL)
curl "https://asyntai.com/api/v1/webhooks/" \
-H "Authorization: Bearer YOUR_API_KEY"
POST /webhooks/
Registrera en ny webhook för att ta emot realtidshändelsemeddelanden.
Tillgängliga händelser
| Händelse | Beskrivning |
|---|---|
message.received |
En besökare skickade ett meddelande och fick ett svar |
conversation.started |
En ny chattsession startades |
escalation.requested |
AI:n utlöste en eskalering till en mänsklig agent |
takeover.started |
En mänsklig agent tog över en chattsession |
Begäranstext
{
"url": "https://example.com/webhook",
"events": ["message.received", "escalation.requested"],
"website_id": "123"
}
| Parameter | Typ | Obligatoriskt | Beskrivning |
|---|---|---|---|
url |
sträng | Ja | HTTPS-URL:en för att ta emot webhook POST-förfrågningar |
events |
array | Ja | Lista över händelser att prenumerera på (se tabell ovan) |
website_id |
sträng | Nej | Målwebbplats (standard är din primära webbplats) |
Svar
{
"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"
}
}
Verifierar webhooks: Varje webhook inkluderar en secret (visas bara vid skapande). Varje POST till din URL inkluderar en X-Webhook-Signature header — en HMAC-SHA256 av förfrågningskroppen signerad med din hemlighet.
Exempel (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}/
Radera en webhook. id hittas i svaret från GET /webhooks/.
Svar
{
"success": true,
"message": "Webhook deleted"
}
Exempel (cURL)
curl -X DELETE "https://asyntai.com/api/v1/webhooks/abc-123-def/" \
-H "Authorization: Bearer YOUR_API_KEY"
Felsvar
Alla felsvar följer detta format:
{
"success": false,
"error": "Error message describing what went wrong"
}
| Statuskod | Beskrivning |
|---|---|
400 |
Felaktig begäran - Ogiltiga parametrar eller saknade obligatoriska fält |
401 |
Obehörig – Ogiltig eller saknad API-nyckel |
429 |
Too Many Requests - Meddelandegränsen nådd för din Pro |
503 |
Tjänst otillgänglig - AI-tjänst tillfälligt otillgänglig |
Hastighetsgränser
API-användning begränsas av din plan:
- Free: 100 meddelanden/månad
- Starter (39 $/mån): 2 500 meddelanden/månad
- Standard (139 $/mån): 15 000 meddelanden/månad
- Pro (449 $/mån): 50 000 meddelanden/månad
Behöver du hjälp?
Om du har några frågor eller stöter på problem, kontakta oss på [email protected].