We zijn nog dingen aan het bouwen hier! Help ons verbeteren door bugs te rapporteren hier.

API Referentie

Complete API referentie voor integratie met het Customer Support AI Assistant platform. Bevat authenticatie, endpoints, request/response schema's, en praktische codevoorbeelden.

Authenticatie

De API ondersteunt twee authenticatiemethoden:

  • API Key Authenticatie: Gebruik X-API-Key en X-API-Secret headers voor directe API toegang
  • JWT Token Authenticatie: Gebruik Bearer tokens verkregen van het widget token endpoint voor browser-gebaseerde verzoeken

Widgettoken-eindpunt

Genereer kortlevende JWT tokens voor widget authenticatie. Dit endpoint stelt widgets in staat om veilige tokens te verkrijgen door alleen de client_id te gebruiken, waardoor de noodzaak om de client_secret bloot te stellen in browsermilieu's wordt vermeden.

<script src="https://widget.companin.tech/widget.js" data-client-id="YOUR_CLIENT_ID" data-assistant-id="YOUR_ASSISTANT_ID" data-config-id="YOUR_CONFIG_ID" data-instance-id="primary-widget"></script>

Antwoord:

{  "token": "eyJ...",  "expires_in": 3600,  "token_type": "Bearer"}

Tariefbeperking

API verzoeken zijn beperkt tot 1000 per uur per organisatie. Rate limit informatie is opgenomen in response headers.

Foutafhandeling

Alle API fouten retourneren gestructureerde JSON responses met status codes, fout details, en optionele data velden.

{  "status": "error",  "status_code": 401,  "detail": "Authentication required - ...",  "data": null}

API-eindpunten

Assistenten

Beheer AI assistent personas met aangepaste configuraties.

Assistenten weergeven

curl -X GET https://app.companin.tech/api/v1/assistants/ \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET"

Assistent maken

curl -X POST https://app.companin.tech/api/v1/assistants/ \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET" \  -H "Content-Type: application/json" \  -d '{    "name": "Customer Support Bot",    "description": "Helpful assistant for customer inquiries",    "tone": "professional",    "language": "en",    "default_tasks": ["answer_questions", "provide_support"],    "is_active": true  }'

Sessies

Maak anonieme bezoekerssessies voor tijdelijke interacties.

Sessie maken

curl -X POST https://app.companin.tech/api/v1/sessions/ \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET" \  -H "Content-Type: application/json" \  -d '{    "assistant_id": "550e8400-e29b-41d4-a716-446655440000",    "visitor_id": "visitor-123",    "locale": "en",    "metadata": {      "source": "website",      "page": "/contact"    }  }'

Bericht verzenden in sessie

curl -X POST https://app.companin.tech/api/v1/sessions/${SESSION_ID}/messages \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET" \  -H "Content-Type: application/json" \  -d '{    "content": "Hello, I need help with my order",    "metadata": {      "user_type": "customer"    }  }'

Conversaties

Maak persistente gesprekken voor geauthenticeerde gebruikers.

Conversatie maken

curl -X POST https://app.companin.tech/api/v1/conversations/ \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET" \  -H "Content-Type: application/json" \  -d '{    "assistant_id": "550e8400-e29b-41d4-a716-446655440000",    "customer_id": "user-456",    "title": "Order Support",    "locale": "en"  }'

Bericht verzenden in conversatie

curl -X POST https://app.companin.tech/api/v1/conversations/${CONVERSATION_ID}/messages \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET" \  -H "Content-Type: application/json" \  -d '{    "content": "Can you help me track my order?",    "metadata": {      "order_id": "12345"    }  }'

Gebruikerscontexten

Bewaar en beheer gebruikerscontext voor gepersonaliseerde interacties.

Gebruikerscontext maken

curl -X POST https://app.companin.tech/api/v1/contexts/ \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET" \  -H "Content-Type: application/json" \  -d '{    "user_reference": "user-456",    "traits": {      "name": "John Doe",      "email": "john@example.com",      "subscription_tier": "premium",      "preferences": {        "language": "en",        "notifications": true      }    }  }'

Kennisbank

Upload en beheer kennisbronnen voor uw assistenten.

Kennisbestand uploaden

curl -X POST https://app.companin.tech/api/v1/knowledge/files/ \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET" \  -F "title=Product Manual" \  -F "file_type=pdf" \  -F "file=@product_manual.pdf"

Vraag-antwoord paar toevoegen

curl -X POST https://app.companin.tech/api/v1/knowledge/qa/ \  -H "X-API-Key: YOUR_CLIENT_ID" \  -H "X-API-Secret: YOUR_CLIENT_SECRET" \  -H "Content-Type: application/json" \  -d '{    "question": "What are your business hours?",    "answer": "We are open Monday to Friday, 9 AM to 6 PM EST.",    "tags": ["hours", "support"]  }'

Gebruiksgevallen

Klantenservice Chatbot

// 1. Widget-token ophalen voor browsergebaseerde chatasync function getWidgetToken() {  const response = await fetch('https://app.companin.tech/api/v1/auth/widget-token', {    method: 'POST',    headers: { 'Content-Type': 'application/json' },    body: JSON.stringify({ client_id: 'YOUR_CLIENT_ID' })  });  return (await response.json()).token;}// 2. Een sessie maken voor anonieme bezoekerasync function startSupportSession(token, assistantId) {  const response = await fetch('https://app.companin.tech/api/v1/sessions/', {    method: 'POST',    headers: {      'Authorization': `Bearer ${token}`,      'Content-Type': 'application/json'    },    body: JSON.stringify({      assistant_id: assistantId,      visitor_id: 'visitor-' + Date.now(),      metadata: { source: 'support_widget' }    })  });  return await response.json();}// 3. Klantbericht verzenden en AI-antwoord krijgenasync function sendMessage(token, sessionId, message) {  const response = await fetch(`https://app.companin.tech/api/v1/sessions/${sessionId}/messages`, {    method: 'POST',    headers: {      'Authorization': `Bearer ${token}`,      'Content-Type': 'application/json'    },    body: JSON.stringify({      content: message,      metadata: { user_type: 'customer' }    })  });  return await response.json();}// Gebruiksvoorbeeldconst token = await getWidgetToken();const session = await startSupportSession(token, 'assistant-uuid');const result = await sendMessage(token, session.data.id, 'Ik heb hulp nodig met mijn bestelling');

E-commerce Productassistent

// 1. Gebruikerscontext maken voor personalisatieasync function createUserContext(userId, userData) {  const response = await fetch('https://app.companin.tech/api/v1/contexts/', {    method: 'POST',    headers: {      'X-API-Key': 'YOUR_CLIENT_ID',      'X-API-Secret': 'YOUR_CLIENT_SECRET',      'Content-Type': 'application/json'    },    body: JSON.stringify({      user_reference: userId,      traits: {        name: userData.name,        purchase_history: userData.purchases,        preferences: userData.preferences      }    })  });  return await response.json();}// 2. Persistente conversatie maken met contextasync function startPersonalizedChat(assistantId, userId) {  const response = await fetch('https://app.companin.tech/api/v1/conversations/', {    method: 'POST',    headers: {      'X-API-Key': 'YOUR_CLIENT_ID',      'X-API-Secret': 'YOUR_CLIENT_SECRET',      'Content-Type': 'application/json'    },    body: JSON.stringify({      assistant_id: assistantId,      customer_id: userId,      user_context_id: userId,      title: 'Product Recommendations',      metadata: { source: 'product_page' }    })  });  return await response.json();}// 3. Chatten met productkennisasync function askAboutProduct(conversationId, question) {  const response = await fetch(`https://app.companin.tech/api/v1/conversations/${conversationId}/messages`, {    method: 'POST',    headers: {      'X-API-Key': 'YOUR_CLIENT_ID',      'X-API-Secret': 'YOUR_CLIENT_SECRET',      'Content-Type': 'application/json'    },    body: JSON.stringify({      content: question,      metadata: { context: 'product_inquiry' }    })  });  return await response.json();}// Gebruiksvoorbeeldawait createUserContext('user-123', {  name: 'Alice',  purchases: ['laptop-1', 'mouse-2'],  preferences: { category: 'electronics' }});const conversation = await startPersonalizedChat('assistant-uuid', 'user-123');const result = await askAboutProduct(conversation.data.id, 'Welke laptop raad je aan?');

Kennisbeheersysteem

// 1. Productdocumentatie uploadenasync function uploadDocumentation(file, title) {  const formData = new FormData();  formData.append('title', title);  formData.append('file_type', 'pdf');  formData.append('file', file);  const response = await fetch('https://app.companin.tech/api/v1/knowledge/files/', {    method: 'POST',    headers: {      'X-API-Key': 'YOUR_CLIENT_ID',      'X-API-Secret': 'YOUR_CLIENT_SECRET'    },    body: formData  });  return await response.json();}// 2. FAQ-items toevoegenasync function addFAQ(question, answer, tags) {  const response = await fetch('https://app.companin.tech/api/v1/knowledge/qa/', {    method: 'POST',    headers: {      'X-API-Key': 'YOUR_CLIENT_ID',      'X-API-Secret': 'YOUR_CLIENT_SECRET',      'Content-Type': 'application/json'    },    body: JSON.stringify({      question,      answer,      tags,      source: 'manual'    })  });  return await response.json();}// 3. Webinhoud toevoegenasync function addWebContent(url, title) {  const response = await fetch('https://app.companin.tech/api/v1/knowledge/urls/', {    method: 'POST',    headers: {      'X-API-Key': 'YOUR_CLIENT_ID',      'X-API-Secret': 'YOUR_CLIENT_SECRET',      'Content-Type': 'application/json'    },    body: JSON.stringify({      url,      title    })  });  return await response.json();}// Gebruiksvoorbeeldconst fileUpload = await uploadDocumentation(pdfFile, 'User Manual v2.0');const faq = await addFAQ(  'Hoe reset ik mijn wachtwoord?',  'Ga naar instellingen en klik op "Wachtwoord resetten"...',  ['password', 'security']);const webContent = await addWebContent(  'https://example.tech/blog/new-features',  'Aankondiging van nieuwe functies');

Voorbeelden

Widget Token Verkrijgen

curl -X POST https://app.companin.tech/api/v1/auth/widget-token \  -H "Content-Type: application/json" \  -d '{"client_id":"YOUR_CLIENT_ID"}'

Sessie Aanmaken

fetch('https://app.companin.tech/api/v1/sessions', {  method: 'POST',  headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },  body: JSON.stringify({ assistant_id: 'ASSISTANT_UUID' })})

CORS Ondersteuning

  • Alle endpoints ondersteunen CORS voor web integraties
  • Preflight verzoeken worden automatisch afgehandeld
  • Credentials worden ondersteund voor geauthenticeerde verzoeken