Skip to content

API: Agents

GET /api/agents
{
"agents": [
{
"id": "bookstore_bot",
"name": "Bookstore Assistant",
"description": "Book recommendation assistant",
"system_prompt": "...",
"model": null,
"created_at": "2026-04-07 10:00:00"
}
]
}
GET /api/agents/<agent_id>

Returns the agent with its assigned tools (array of tool IDs) and channels.

POST /api/agents
Content-Type: application/json
{
"id": "bookstore_bot",
"name": "Bookstore Assistant",
"description": "Book recommendation assistant"
}

The id must match ^[a-zA-Z0-9_]+$.

PUT /api/agents/<agent_id>
Content-Type: application/json
{
"name": "Updated Name",
"system_prompt": "New system prompt...",
"model": "gpt-4"
}

Updatable fields: name, description, system_prompt, model.

DELETE /api/agents/<agent_id>

Removes the agent, its channels, sessions, messages, and KB directory.


GET /api/agents/<agent_id>/tools
{"tools": ["get_weather", "calculator"]}
PUT /api/agents/<agent_id>/tools
Content-Type: application/json
{"tools": ["get_weather", "calculator", "search_restaurants"]}

Replaces the entire tool assignment list.


GET /api/agents/<agent_id>/kb
{
"files": [
{"filename": "facilities.md", "size": 2345, "modified": 1712500000.0}
]
}
GET /api/agents/<agent_id>/kb/<filename>
{"filename": "facilities.md", "content": "# Facilities\n\n..."}
POST /api/agents/<agent_id>/kb
Content-Type: multipart/form-data
file=@facilities.md
POST /api/agents/<agent_id>/kb
Content-Type: application/json
{"filename": "faq.md", "content": "# FAQ\n\n..."}
PUT /api/agents/<agent_id>/kb/<filename>
Content-Type: application/json
{"content": "Updated content..."}
DELETE /api/agents/<agent_id>/kb/<filename>

GET /api/agents/<agent_id>/channels
POST /api/agents/<agent_id>/channels
Content-Type: application/json
{
"type": "telegram",
"name": "Main Bot",
"config": {"bot_token": "123456:ABC..."}
}
PUT /api/agents/<agent_id>/channels/<channel_id>
DELETE /api/agents/<agent_id>/channels/<channel_id>
POST /api/agents/<agent_id>/channels/<channel_id>/start
POST /api/agents/<agent_id>/channels/<channel_id>/stop

POST /api/agents/<agent_id>/chat
Content-Type: application/json
{
"message": "Apakah kamar Bismo tersedia?",
"user_id": "web_test"
}

Response:

{
"success": true,
"response": "Selamat datang! Kamar Bismo tersedia untuk tanggal tersebut..."
}

The user_id is used as the external user identifier for session management. Each unique user_id gets a separate conversation history.

POST /api/agents/<agent_id>/chat/clear
Content-Type: application/json
{"user_id": "web_test"}