> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sleak.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# API Overzicht

> De Sleak.chat API biedt directe toegang tot onze infrastructuur voor het bouwen van betrouwbare AI agents

<Info>
  **n8n community node beschikbaar**

  Voor low-code integraties kun je gebruik maken van onze [n8n community node](https://docs.sleak.chat/integraties/n8n-integratie). Dit maakt het eenvoudig om Sleak te integreren in je automatiseringsworkflows.
</Info>

## Authenticatie

De Sleak API gebruikt Bearer token authenticatie. Voeg je API key toe aan de Authorization header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

Je kunt je API key vinden in het dashboard onder **Instellingen > API**.

## Base URL

```
https://api.v1.sleak.chat
```

## Endpoints

De API biedt de volgende endpoints:

<Card title="POST /api/conversation" icon="comments" href="/api/create-conversation">
  Start een nieuwe conversatie met een chatbot
</Card>

<Card title="POST /api/message" icon="message" href="/api/send-message">
  Verstuur een bericht binnen een bestaande conversatie
</Card>

## Rate Limiting

De API hanteert rate limiting om overbelasting te voorkomen. Rate limit informatie wordt teruggegeven in de response headers:

* `X-RateLimit-Limit`: Maximaal aantal requests per minuut
* `X-RateLimit-Remaining`: Aantal resterende requests
* `X-RateLimit-Reset`: Unix timestamp wanneer de rate limit reset

Bij het overschrijden van de rate limit ontvang je een `429 Too Many Requests` response.

## Error Handling

Alle errors worden geretourneerd in het volgende format:

```json theme={null}
{
  "error": {
    "code": "error_code",
    "message": "Foutbeschrijving",
    "details": {}
  }
}
```

**HTTP Status Codes:**

* `200`: Succesvol verwerkt
* `400`: Ongeldige aanvraag
* `401`: Niet geautoriseerd
* `403`: Geen toegang tot deze resource
* `404`: Resource niet gevonden
* `429`: Rate limit overschreden
* `500`: Interne server fout

## Code Voorbeelden

### cURL

```bash theme={null}
# Start een conversatie
curl -X POST https://api.v1.sleak.chat/api/conversation \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"chatbot_id": "chatbot_123", "visitor_id": "visitor_456"}'

# Verstuur een bericht
curl -X POST https://api.v1.sleak.chat/api/message \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"conversation_id": "conv_789", "message": "Hallo!"}'
```

### Python

```python theme={null}
import requests

API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.v1.sleak.chat"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# Start conversatie
response = requests.post(
    f"{BASE_URL}/api/conversation",
    headers=headers,
    json={"chatbot_id": "chatbot_123", "visitor_id": "visitor_456"}
)
conversation_id = response.json()["conversation_id"]

# Verstuur bericht
response = requests.post(
    f"{BASE_URL}/api/message",
    headers=headers,
    json={"conversation_id": conversation_id, "message": "Hallo!"}
)
messages = response.json()
```

### JavaScript (Node.js)

```javascript theme={null}
const axios = require('axios');

const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://api.v1.sleak.chat';

const headers = {
  'Authorization': `Bearer ${API_KEY}`,
  'Content-Type': 'application/json'
};

// Start conversatie
const conversation = await axios.post(
  `${BASE_URL}/api/conversation`,
  { chatbot_id: 'chatbot_123', visitor_id: 'visitor_456' },
  { headers }
);

const conversationId = conversation.data.conversation_id;

// Verstuur bericht
const response = await axios.post(
  `${BASE_URL}/api/message`,
  { conversation_id: conversationId, message: 'Hallo!' },
  { headers }
);
```

***

<CardGroup cols={2}>
  <Card title="Email Support" icon="envelope" href="mailto:support@sleak.chat">
    [support@sleak.chat](mailto:support@sleak.chat)
  </Card>

  <Card title="Bel ons" icon="phone" href="tel:+31850608199">
    +31 85 060 8199
  </Card>
</CardGroup>
