Accueil / Reference API
Enterprise et Unlimited v1
API ENTERPRISE

Reference API

L'API AISupportBot vous permet d'envoyer des questions a votre assistant configure et de recevoir des reponses IA basees sur votre base de connaissances. Ideal pour integration dans votre bot Discord, application web ou backend.

⚑
RAG-Powered
Answers grounded in your uploaded documents. No hallucinations.
πŸ‘€
User Context
Pass custom JSON data to personalize responses per-user.
πŸ“Š
Usage Tracked
Each call counts against your plan's monthly response quota.
Base URL
https://aisupportbot.io/api/chat

Authentication

All Enterprise API requests must include your API key in the request header.

Header
X-API-Key:ask_your_api_key_here
πŸ”‘
Where to find your key
Go to your Dashboard β†’ Server β†’ Settings. The "API Key" section is visible on Enterprise and Unlimited plans. Click Generate key to create one.
⚠️
Keep it secret
Your API key grants full access to your assistant. Never expose it in client-side code or public repositories.

Chat Endpoint

Send a message to your assistant and receive an AI-generated response.

POST /api/chat

Request Body (JSON)

FieldTypeRequiredDescription
assistantIdstringrequiredYour assistant's ID (found in the dashboard URL).
messagestringrequiredThe user's message / question.
historyarrayoptionalPrevious messages for context. Array of {role, content}. Max 15 messages kept.
userIdstringoptionalYour user's identifier (for logging).
channelIdstringoptionalDiscord channel ID if the question came from a specific channel.
userContextobjectoptionalJSON object with user-specific data injected into the AI prompt. Max 4KB. More details β†’

Minimal Request

curl
curl -X POST https://aisupportbot.io/api/chat \
  -H "X-API-Key: ask_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "assistantId": "clz1abc...",
    "message": "How do I reset my password?"
  }'

User Context

The userContext field lets you pass any JSON object about the asking user. The AI will use this data to personalize its response β€” addressing the user by name, referencing their account state, plan, stats, etc.

πŸ’‘ Perfect for platforms with user data

If you're integrating into a game, SaaS, or community platform, pass relevant data like balance, tier, or recent activity. The AI will reference it naturally when it's relevant to the question.

Example β€” Bot Hosting Platform

JSON
{
  "assistantId": "clz1abc...",
  "message": "Why is my bot offline?",
  "userId": "discord_123456",
  "userContext": {
    "username": "NikolaB",
    "plan": "pro",
    "servers": [
      { "name": "MyBot", "status": "offline", "uptime": "98.2%" }
    ],
    "coins": 450,
    "memberSince": "2024-03-15"
  }
}

The AI will respond to "Why is my bot offline?" with something like:

"Hi NikolaB! I can see that MyBot (Pro plan) is currently offline. Common causes include…"

Constraints

  • βœ“ Any valid JSON object is accepted
  • βœ“ Nested objects and arrays are supported
  • βœ— Max size: 4 KB β€” requests with larger payloads will be rejected
  • ⚠ The data is read-only context β€” the AI cannot modify it

Response Schema

All successful responses return 200 OK with a JSON body.

Response β€” 200 OK
{
  "response": "The reset link is sent to your registered email…",
  "requiresEscalation": false,
  "usage": {
    "prompt_tokens": 312,
    "completion_tokens": 48,
    "total_tokens": 360
  }
}
FieldTypeDescription
responsestringThe AI-generated answer. May be an empty string if escalation was triggered.
requiresEscalationbooleantrue when the AI isn't confident enough to answer. You should route the user to a human agent.
usageobjectToken counts for the request (prompt + completion). Useful for cost monitoring.

Error Codes

All errors return a JSON body with an error field and optional details.

400
Bad Request
Missing required fields (assistantId, message) or userContext exceeds 4KB.
401
Unauthorized
API key is missing, malformed (must start with ask_), or has been deleted.
403
Forbidden
The API key does not belong to the requested assistantId.
404
Not Found
The given assistantId doesn't exist or the assistant is not active.
429
Plan Limit Reached
Your assistant has exhausted its monthly response quota. Upgrade or wait for reset.
500
Internal Server Error
Unexpected server error. Retry after a few seconds.
Error response example
{
  "error": "Plan limit reached",
  "details": "Upgrade to get more responses. (1000/1000)"
}

Examples

Full working examples for common use cases.

JS JavaScript / TypeScript

With conversation history + userContext
const askBot = async (message, user, history = []) => {
  const res = await fetch('https://aisupportbot.io/api/chat', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': 'ask_your_key_here',
    },
    body: JSON.stringify({
      assistantId: 'clz1abc...',
      message,
      history,
      userId: user.id,
      userContext: {
        username: user.name,
        plan: user.plan,
        coins: user.coins,
        servers: user.servers,
      },
    }),
  });

  const data = await res.json();

  if (data.requiresEscalation) {
    return { reply: "I'll connect you with a human agent.", escalate: true };
  }

  return { reply: data.response, escalate: false };
};

Py Python

Simple integration
import requests

API_KEY = "ask_your_key_here"
ASSISTANT_ID = "clz1abc..."

def ask_bot(message, user_context=None):
    response = requests.post(
        "https://aisupportbot.io/api/chat",
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        },
        json={
            "assistantId": ASSISTANT_ID,
            "message": message,
            "userContext": user_context,
        }
    )
    data = response.json()

    if data.get("requiresEscalation"):
        return "Escalating to a human agent."

    return data["response"]

Handling Escalation

When requiresEscalation is true, the AI couldn't find a confident answer. You should redirect the user to a human support channel rather than showing an empty or incorrect response.

βœ“ Open a ticket in your Discord server

βœ“ Redirect to a #support channel

βœ“ Send a DM to on-call staff

βœ— Don't show the empty response string to users

Questions about the API? Join our Discord support server.