Chatbots API
Chatbots are tenant-scoped AI assistants with a persona, allowed knowledge bases, and platform bindings.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | `/api/v1/chatbots` | List |
| POST | `/api/v1/chatbots` | Create |
| GET | `/api/v1/chatbots/:id` | Get |
| PATCH | `/api/v1/chatbots/:id` | Update |
| DELETE | `/api/v1/chatbots/:id` | Delete |
| GET | `/api/v1/chatbots/:id/sessions` | Recent chat sessions |
| GET | `/api/v1/chatbots/:id/stats` | Sessions / messages / takeover rate |
| POST | `/api/v1/chatbots/:id/test` | One-shot test message |
Schema
{
"id": "bot_01H...",
"tenantId": "tnt_01H...",
"name": "Pre-sales Bot",
"avatar": null,
"platforms": ["XIAOHONGSHU", "INSTAGRAM"],
"knowledgeBaseIds": ["kb_01H..."],
"persona": "friendly product expert",
"model": "deepseek-v4-flash",
"temperature": 0.4,
"enabled": true,
"createdAt": "2026-03-01T00:00:00Z",
"updatedAt": "2026-04-15T00:00:00Z"
}Testing
curl -X POST https://api.anvilhk.com/api/v1/chatbots/bot_01H.../test \
-H "Authorization: Bearer $ANVIL_KEY" \
-H "X-Tenant-ID: $TENANT" \
-H "Content-Type: application/json" \
-d '{ "message": "What is the MOQ for product X?" }'Returns { reply, tokens, latencyMs }.
Every response uses the standard envelope:
{
"success": true,
"data": { /* resource or array */ },
"meta": { "total": 100, "cursor": "...", "hasMore": true },
"error": { "code": "ERROR_CODE", "message": "Human readable" }
}error is omitted on success; meta is omitted when not paginating.
Rate Limits
Chatbot calls share the per-user AI cap of 60/min/user (in addition to the standard 200/min/tenant). See [Rate Limits](/docs/api-reference/rate-limits).