Skip to content
AstrBot
Main Navigation HomeBlogRoadmapHTTP API

English

简体中文

English

简体中文

Toggle dark mode

Intro & DeployMessaging PlatformsAI IntegrationUsageDevelopment
Sidebar Navigation

Introduction

What is AstrBot

Community

FAQ

Deployment

Package Manager

Desktop Client

One-click Launcher

Docker

Kubernetes

BT Panel

1Panel

Manual

Other Deployments

CasaOS

Compshare GPU

Community-provided Deployment

Support Us

Messaging Platforms

Quick Start

QQ Official Bot

Websockets

Webhook

OneBot v11

WeCom Application

WeCom AI Bot

WeChat Official Account

Personal WeChat

Lark

DingTalk

Telegram

LINE

Slack

Mattermost

Misskey

Discord

KOOK

Satori

Connect Satori

Using server-satori

Community-provided

Matrix

VoceChat

AI Integration

✨ Model Providers

NewAPI

AIHubMix

PPIO Cloud

SiliconFlow

TokenPony

302.AI

Ollama

LMStudio

⚙️ Agent Runners

Built-in Agent Runner

Dify

Coze

Alibaba Bailian

DeerFlow

Usage

WebUI

CLI Commands

Plugins

Built-in Commands

Tool Use

Anthropic Skills

Computer Use

SubAgent Orchestration

Proactive Tasks

MCP

Web Search

Knowledge Base

Custom Rules

Agent Runner

Unified Webhook Mode

Auto Context Compression

Agent Sandbox

Development

Plugin Development

🌠 Getting Started

Minimal Example

Listen to Message Events

Send Messages

Plugin Configuration

Plugin Pages

Plugin Internationalization

AI

Storage

HTML to Image

Session Control

Publish Plugin

Platform Adapter Integration

AstrBot HTTP API

AstrBot Configuration File

Others

Self-hosted HTML to Image

Open Source Summer

OSPP 2025

On this page

AstrBot HTTP API ​

Starting from v4.18.0, AstrBot provides API Key based HTTP APIs for programmatic access.

Quick Start ​

  1. Create an API key in WebUI - Settings.
  2. Include the API key in request headers:
http
Authorization: Bearer abk_xxx

Also supported:

http
X-API-Key: abk_xxx
  1. For chat endpoints, username is required:
  • POST /api/v1/chat: request body must include username
  • GET /api/v1/chat/sessions: query params must include username

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.

Scope Permissions ​

When creating an API Key, you can configure scopes. Each scope controls the range of accessible endpoints:

ScopePurposeAccessible Endpoints
botManage bot/platform configurationsGET /api/v1/bot-types, GET/POST /api/v1/bots, PATCH /api/v1/bots/enabled
providerManage model providers and provider sourcesGET/POST /api/v1/providers, GET/PUT/DELETE /api/v1/provider-sources/by-id
personaManage personas and persona foldersGET/POST /api/v1/personas, GET/POST /api/v1/persona-folders
imSend proactive IM messages and query bot/platform listPOST /api/v1/im/message, GET /api/v1/im/bots
configManage 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
chatAccess chat capabilities and query sessionsPOST /api/v1/chat, GET /api/v1/chat/sessions
fileUpload and download chat attachmentsPOST /api/v1/file, GET /api/v1/file, POST /api/v1/files
pluginManage plugins, plugin config, plugin sources, and marketplace entriesGET /api/v1/plugins, GET/PUT /api/v1/plugins/config, POST /api/v1/plugins/install/url
mcpManage MCP server configurations and provider syncGET/POST /api/v1/mcp/servers, PATCH /api/v1/mcp/servers/{server_name}/enabled, POST /api/v1/mcp/providers/modelscope/sync
skillManage skills, skill archives, skill files, and Shipyard Neo skill workflowsGET/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.

Common Endpoints ​

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 when session_id is omitted)
  • GET /api/v1/chat/sessions: list sessions for a specific username with 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

message Field Format (Important) ​

The message field in POST /api/v1/chat and POST /api/v1/im/message supports two formats:

  1. String: plain text message
  2. Array: message segments (message chain)

1. Plain Text Format ​

json
{
  "message": "Hello"
}

2. Message Segment Array Format ​

json
{
  "message": [
    { "type": "plain", "text": "Please see this file" },
    { "type": "file", "attachment_id": "9a2f8c72-e7af-4c0e-b352-111111111111" }
  ]
}

Supported type values:

typeRequired FieldsOptional FieldsDescription
plaintext-Text segment
replymessage_idselected_textQuote-reply a message
imageattachment_id-Image attachment segment
recordattachment_id-Audio attachment segment
fileattachment_id-Generic file segment
videoattachment_id-Video attachment segment
  • The reply segment is currently only supported for /api/v1/chat, not for POST /api/v1/im/message.

Notes:

  • attachment_id comes from an existing attachment record, or from POST /api/v1/file after uploading an attachment with the file scope.
  • reply cannot be the only segment; at least one content segment (e.g. plain/image/file/...) is required.
  • A request with only reply or empty content will return an error.

message Usage in Chat API ​

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.

json
{
  "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
}

message Usage in IM Message API ​

POST /api/v1/im/message requires umo + message.

json
{
  "umo": "webchat:FriendMessage:openapi_probe",
  "message": [
    { "type": "plain", "text": "This is a proactive message" },
    { "type": "image", "attachment_id": "9a2f8c72-e7af-4c0e-b352-222222222222" }
  ]
}

Example ​

bash
curl -N 'http://localhost:6185/api/v1/chat' \
  -H 'Authorization: Bearer abk_xxx' \
  -H 'Content-Type: application/json' \
  -d '{"message":"Hello","username":"alice"}'

Full API Reference ​

Use the interactive docs:

  • https://docs.astrbot.app/scalar.html
Edit this page on GitHub

Last updated:

Pager
PreviousPlatform Adapter Integration
NextAstrBot Configuration File

Deployed on Rainyun Logo