API Documentation

Complete guide to integrate with the AI Agent API

POST/v1/chat

Send a message to the AI agent. Requires API Key authentication. Optionally include a callback_url for async response delivery.

Headers

X-API-KeystringrequiredYour API key from the API Keys page
Content-Typestringrequiredapplication/json

Request Body

messagestringrequiredThe user message to send
session_idstring?Session ID for conversation continuity
user_idstring?Unique user identifier
channelstringChannel identifier (default: "api")
brandstring?Brand to use for the response
personastring?Persona mode (default: "customer")
callback_urlstring?URL to receive async callback with the response
callback_secretstring?Secret for HMAC-SHA256 signing of callback payload

Example Request

curl -X POST https://your-domain.com/api/v1/chat \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "message": "สวัสดีครับ ขอเช็คยอด",
    "user_id": "user-123",
    "callback_url": "https://your-server.com/webhook/callback"
  }'

Example Response

{
  "message": "ยอดเครดิตปัจจุบัน 5,000 บาทครับ",
  "session_id": "api_user-123",
  "trace_id": "abc-123-def-456",
  "model_used": "claude-sonnet-4-20250514",
  "tools_called": [
    {
      "tool": "web_r.get_balance",
      "success": true,
      "latency_ms": 340
    }
  ],
  "confidence": 0.95,
  "latency_ms": 1234.5,
  "handoff": null
}
Try It