External API
Integrate WizChat chatbots into your applications using our REST API.
Overview
The External API allows you to:
- Send messages to your chatbot
- Retrieve responses programmatically
- Integrate chatbot functionality into your apps
- Build custom interfaces
Getting API Keys
- Go to "Settings" > "API"
- Click "Generate API Key"
- Copy and securely store the key
- Note: Keys are shown only once
Authentication
All API requests require authentication:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.wizchat.com/v1/chatbots/YOUR_CHATBOT_ID/query
Base URL
https://api.wizchat.com/v1
Sending a Message
Request
POST /chatbots/{chatbotId}/query
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"message": "What is your return policy?",
"conversationId": "optional-conversation-id"
}
Response
{
"response": "Our return policy allows returns within 30 days of purchase...",
"conversationId": "conv_abc123",
"sources": [
{
"documentId": "doc_xyz",
"title": "Return Policy",
"relevance": 0.95
}
]
}
Conversation Management
Continue a Conversation
Include the conversationId from previous response:
{
"message": "What if the item is damaged?",
"conversationId": "conv_abc123"
}
Start New Conversation
Omit conversationId or pass null:
{
"message": "Hello!",
"conversationId": null
}
Code Examples
JavaScript/Node.js
const response = await fetch(
'https://api.wizchat.com/v1/chatbots/YOUR_CHATBOT_ID/query',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
message: 'What are your business hours?',
}),
}
);
const data = await response.json();
console.log(data.response);
Python
import requests
response = requests.post(
'https://api.wizchat.com/v1/chatbots/YOUR_CHATBOT_ID/query',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
json={
'message': 'What are your business hours?',
},
)
data = response.json()
print(data['response'])
cURL
curl -X POST https://api.wizchat.com/v1/chatbots/YOUR_CHATBOT_ID/query \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "What are your business hours?"}'
Rate Limits
| Plan | Requests/Minute | Requests/Day |
|---|---|---|
| Starter | 30 | 1,000 |
| Pro | 60 | 10,000 |
| Business | 120 | Unlimited |
Rate Limit Headers
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1640000000
Error Handling
Error Response Format
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests. Please try again later.",
"retryAfter": 60
}
}
Common Error Codes
| Code | HTTP Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Invalid or missing API key |
FORBIDDEN | 403 | API key doesn't have access |
NOT_FOUND | 404 | Chatbot not found |
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
INTERNAL_ERROR | 500 | Server error |
API Key Management
Viewing Keys
- Go to "Settings" > "API"
- See all active keys
- View usage statistics
Revoking Keys
- Go to "Settings" > "API"
- Find the key
- Click "Revoke"
- Confirm revocation
warning
Revoked keys stop working immediately.
Best Practices
- Store API keys securely (environment variables)
- Rotate keys periodically
- Use separate keys for different environments
- Implement proper error handling
- Respect rate limits