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

https://supportgenie.online/api

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

BASH
Authorization: Bearer YOUR_API_KEY

How to get your API key:

  1. Log in to your ChatSupport AI dashboard
  2. Navigate to Settings > API Keys
  3. Click "Generate New API Key"
  4. 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

POST/api/widget/chat

Request Body

JSON
{
  "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."
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

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

JSON
{
  "id": "resp_1680123456789",
  "message": "Our business hours are 9am-5pm EST, Monday through Friday.",
  "timestamp": "2023-03-29T14:30:00.000Z"
}

Example Request

BASH
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"
  }'
1
2
3
4
5
6
7
8

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:

Plan
Requests per minute
Daily limit
Free
10
100
Basic
30
1,000
Premium
100
10,000
Enterprise
500
Unlimited

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:

JAVASCRIPT
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();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

Check out the SDK documentation for more details.