API Reference
The ChatSupport AI API provides endpoints for chat functionality, web scraping, and widget configuration. Use these endpoints to integrate ChatSupport AI with your applications.
Base URL
All API endpoints are relative to the base URL
For self-hosted instances, use your custom domain.
Authentication
How to authenticate with the API
All API requests require an API key to be included in the header:
Authentication Header
Authorization: Bearer YOUR_API_KEY
How to get your API key:
- Log in to your ChatSupport AI dashboard
- Navigate to Settings > API Keys
- Click "Generate New API Key"
- Copy your API key and store it securely
Security Warning
Keep your API key secure and never expose it in client-side code. Always make API requests from your server.
Chat API
Send messages to the AI assistant
Endpoint
Request Body
{
"message": "What are your business hours?",
"widgetId": "YOUR_WIDGET_ID",
"sessionId": "user_session_123",
"context": {
"rules": {
"companyName": "Acme Inc.",
"companyDescription": "A software company specializing in AI tools.",
"policies": [
{
"title": "Business Hours",
"content": "Our business hours are 9am-5pm EST, Monday through Friday."
}
],
"tone": "friendly"
},
"scrapedData": "Acme Inc. provides cutting-edge AI solutions for businesses."
}
}
Required Parameters
- messageThe user's message text
- widgetIdYour widget identifier
Optional Parameters
- sessionIdA unique identifier for the chat session
- contextAdditional context for the AI, including company rules and scraped website data
Success Response
{
"id": "resp_1680123456789",
"message": "Our business hours are 9am-5pm EST, Monday through Friday.",
"timestamp": "2023-03-29T14:30:00.000Z"
}
Example Request
curl -X POST https://supportgenie.online/api/widget/chat \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"message": "What are your business hours?",
"widgetId": "YOUR_WIDGET_ID",
"sessionId": "user_session_123"
}'
Error Codes
- 400Missing required parameters
- 401Unauthorized - Invalid or missing API key
- 404Widget not found
- 500Server error
Rate Limits
API request limits and quotas
Rate limits vary by plan:
If you exceed your rate limit, requests will return a 429 Too Many Requests status code.
JavaScript SDK
Use our JavaScript SDK for easier API integration
We provide a JavaScript SDK for easier integration with our API:
import { ChatSupportAI } from 'supportgenie-sdk';
// Initialize the SDK with your API key
const client = new ChatSupportAI({
apiKey: 'YOUR_API_KEY',
widgetId: 'YOUR_WIDGET_ID'
});
// Send a message
const response = await client.sendMessage({
message: 'Hello, I have a question about your service',
sessionId: 'unique_session_id'
});
// Scrape a URL
const scrapedData = await client.scrapeUrl({
url: 'https://example.com/about-us'
});
// Get widget configuration
const config = await client.getWidgetConfig();
Check out the SDK documentation for more details.