-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
en dev openapi
Starting from v4.18.0, AstrBot provides API Key based HTTP APIs for programmatic access.
- Create an API key in WebUI - Settings.
- Include the API key in request headers:
Authorization: Bearer abk_xxxAlso supported:
X-API-Key: abk_xxx- For chat endpoints,
usernameis required:
-
POST /api/v1/chat: request body must includeusername -
GET /api/v1/chat/sessions: query params must includeusername
The local OpenAPI schema is available at http://localhost:6185/api/v1/openapi.json, and the interactive docs are available at http://localhost:6185/api/v1/docs.
When creating an API Key, you can configure scopes. Each scope controls the range of accessible endpoints:
| Scope | Purpose | Accessible Endpoints |
|---|---|---|
bot |
Manage bot/platform configurations |
GET /api/v1/bot-types, GET/POST /api/v1/bots, PATCH /api/v1/bots/enabled
|
provider |
Manage model providers and provider sources |
GET/POST /api/v1/providers, GET/PUT/DELETE /api/v1/provider-sources/by-id
|
persona |
Manage personas and persona folders |
GET/POST /api/v1/personas, GET/POST /api/v1/persona-folders
|
im |
Send proactive IM messages and query bot/platform list |
POST /api/v1/im/message, GET /api/v1/im/bots
|
config |
Manage config profiles, system config, and shared configuration. This scope also includes bot and provider access. |
GET /api/v1/configs, GET/PUT /api/v1/system-config, GET/POST /api/v1/config-profiles
|
chat |
Access chat capabilities and query sessions |
POST /api/v1/chat, GET /api/v1/chat/sessions
|
file |
Upload and download chat attachments |
POST /api/v1/file, GET /api/v1/file, POST /api/v1/files
|
plugin |
Manage plugins, plugin config, plugin sources, and marketplace entries |
GET /api/v1/plugins, GET/PUT /api/v1/plugins/config, POST /api/v1/plugins/install/url
|
mcp |
Manage MCP server configurations and provider sync |
GET/POST /api/v1/mcp/servers, PATCH /api/v1/mcp/servers/{server_name}/enabled, POST /api/v1/mcp/providers/modelscope/sync
|
skill |
Manage skills, skill archives, skill files, and Shipyard Neo skill workflows |
GET/POST /api/v1/skills, PUT /api/v1/skills/{skill_name}/files/{file_path}, POST /api/v1/skills/neo/sync
|
If the API Key does not include the required scope for the target endpoint, the request will return 403 Insufficient API key scope.
config is a broad management scope. When an API key is created with config, AstrBot grants the key config, bot, and provider access together. The WebUI mirrors this dependency: selecting config selects bot and provider; deselecting bot or provider removes config.
Developer API keys currently support only the 10 scopes listed above. tool, skills, kb, data, and system are not valid developer API key scopes. Use the singular skill scope for /api/v1/skills/* endpoints. The public OpenAPI reference only includes endpoints covered by supported developer API key scopes.
Chat
Interact with AstrBot's built-in Agent. Supports plugin calls, tool calls, and other capabilities — consistent with IM-side chat.
-
POST /api/v1/chat: send chat message (SSE stream, server generates UUID whensession_idis omitted) -
GET /api/v1/chat/sessions: list sessions for a specificusernamewith pagination -
GET /api/v1/configs: list available config files -
POST /api/v1/file: upload an attachment for later use in message segments
Bots and Providers
-
GET /api/v1/bots: list bot/platform configurations -
POST /api/v1/bots: create a bot/platform configuration -
GET /api/v1/providers: list model provider configurations -
GET /api/v1/provider-sources: list provider source configurations
Personas, Plugins, MCP, and Skills
-
GET /api/v1/personas: list personas -
GET /api/v1/plugins: list plugins -
GET /api/v1/mcp/servers: list MCP servers -
GET /api/v1/skills: list skills
Proactive IM Messages
-
POST /api/v1/im/message: send a proactive message via UMO -
GET /api/v1/im/bots: list bot/platform IDs
The message field in POST /api/v1/chat and POST /api/v1/im/message supports two formats:
- String: plain text message
- Array: message segments (message chain)
{
"message": "Hello"
}{
"message": [
{ "type": "plain", "text": "Please see this file" },
{ "type": "file", "attachment_id": "9a2f8c72-e7af-4c0e-b352-111111111111" }
]
}Supported type values:
| type | Required Fields | Optional Fields | Description |
|---|---|---|---|
plain |
text |
- | Text segment |
reply |
message_id |
selected_text |
Quote-reply a message |
image |
attachment_id |
- | Image attachment segment |
record |
attachment_id |
- | Audio attachment segment |
file |
attachment_id |
- | Generic file segment |
video |
attachment_id |
- | Video attachment segment |
- The
replysegment is currently only supported for/api/v1/chat, not forPOST /api/v1/im/message.
Notes:
-
attachment_idcomes from an existing attachment record, or fromPOST /api/v1/fileafter uploading an attachment with thefilescope. -
replycannot be the only segment; at least one content segment (e.g.plain/image/file/...) is required. - A request with only
replyor empty content will return an error.
POST /api/v1/chat additionally requires username, with optional session_id (a UUID is auto-generated if omitted).
username is a caller-declared WebChat identity. It is used as the message sender and session owner in the message pipeline, including sender-ID-based command permission checks. Treat API keys with the chat scope as trusted backend credentials. If you expose chat access to end users, proxy requests through your own service and map each external user to an allowed username; do not let clients submit administrator IDs or other reserved sender IDs directly.
{
"username": "alice",
"session_id": "my_session_001",
"message": [
{ "type": "plain", "text": "Please summarize this PDF" },
{ "type": "file", "attachment_id": "9a2f8c72-e7af-4c0e-b352-111111111111" }
],
"enable_streaming": true
}POST /api/v1/im/message requires umo + message.
{
"umo": "webchat:FriendMessage:openapi_probe",
"message": [
{ "type": "plain", "text": "This is a proactive message" },
{ "type": "image", "attachment_id": "9a2f8c72-e7af-4c0e-b352-222222222222" }
]
}curl -N 'http://localhost:6185/api/v1/chat' \
-H 'Authorization: Bearer abk_xxx' \
-H 'Content-Type: application/json' \
-d '{"message":"Hello","username":"alice"}'Use the interactive docs:
- 首页
- 文档入口
- Top Level
- community events
- deploy
- dev
- others
- platform
- 接入 OneBot v11 协议实现
- 接入钉钉 DingTalk
- 接入 Discord
- 接入 Kook
- 接入飞书
- 接入 LINE
- 接入 Matrix
- 接入 Mattermost
- 接入 Misskey 平台
- 接入 QQ 官方机器人平台
- 通过 QQ官方机器人 接入 QQ (Webhook)
- 通过 QQ官方机器人 接入 QQ (Websockets)
- 接入 Satori 协议
- 接入 server-satori (基于 Koishi)
- 接入 Slack
- 接入消息平台
- 接入 Telegram
- 接入 VoceChat
- AstrBot 接入企业微信
- 接入企业微信智能机器人平台
- AstrBot 接入微信公众平台
- 接入个人微信
- providers
- use
- Home
- Docs Entry
- Top Level
- config
- deploy
- Deploy AstrBot on 1Panel
- Deploy AstrBot on BT Panel
- Deploy AstrBot on CasaOS
- Deploy AstrBot from Source Code
- Community-Provided Deployment Methods
- Deploy via Compshare
- Deploy with AstrBot Desktop Client
- Deploy AstrBot with Docker
- Deploy AstrBot with Kubernetes
- Deploy AstrBot with AstrBot Launcher
- Other Deployments
- Package Manager Deployment (uv)
- Installation via System Package Manager
- Preface
- dev
- AstrBot Configuration File
- AstrBot HTTP API
- Developing a Platform Adapter
- plugin
- AI
- Text to Image
- Handling Message Events
- Plugin Configuration
- Plugin Internationalization
- Plugin Pages
- Sending Messages
- Session Control
- Minimal Example
- Plugin Storage
- AstrBot Plugin Development Guide 🌠
- Publishing Plugins to the Plugin Marketplace
- ospp
- others
- platform
- Connect OneBot v11 Protocol Implementations
- Connect to DingTalk
- Connecting to Discord
- Connect to KOOK
- Connecting to Lark
- Connecting to LINE
- Connecting to Matrix
- Connecting to Mattermost
- Connecting to Misskey Platform
- Connect QQ Official Bot
- Connect QQ via QQ Official Bot (Webhook)
- Connect QQ via QQ Official Bot (Websockets)
- Connect to Satori Protocol
- Connect server-satori (Koishi)
- Connecting to Slack
- Messaging Platforms
- Connecting to Telegram
- Connect to VoceChat
- Connect AstrBot to WeCom
- Connect to WeCom AI Bot Platform
- Connect AstrBot to WeChat Official Account Platform
- Connect Personal WeChat
- providers
- Connect 302.AI
- Agent Runners
- Built-in Agent Runner
- Connect to Coze
- Connect to Alibaba Cloud Bailian Application
- Connect to DeerFlow
- Connect to Dify
- Connect AIHubMix
- coze
- dashscope
- dify
- 大语言模型提供商
- NewAPI
- Connect PPIO Cloud
- Connect LM Studio to Use DeepSeek-R1 and Other Models
- Integrating Ollama
- Connecting to SiliconFlow
- Connecting Model Services
- Connecting to TokenPony
- use
- Agent Runner
- Agent Sandbox Environment ⛵️
- astrbot sandbox
- CLI Commands
- Docker-based Code Interpreter
- Built-in Commands
- Computer Use
- Context Compression
- Custom Rules
- Function Calling
- AstrBot Knowledge Base
- MCP
- AstrBot Star
- Proactive Capabilities
- Anthropic Skills
- Agent Handoff and SubAgent
- Unified Webhook Mode
- Web Search
- WebUI