The Managed Agents API is a smart agent hosting runtime provided by Bailian, which manages sessions, sandboxes, tool execution, and event streams on the platform.
Prerequisites
- Enable Bailian and create an API Key: Obtain it via the console.
- Obtain your Workspace ID: Find it in the dropdown menu at the top-right corner of the Bailian console — it looks like
{workspace_id}.
Endpoint
The base API URL is constructed from your workspace ID and region:
workspace_id: Your workspace IDregion: Region ID — currently onlycn-beijingis supported.
Authentication
All requests must include your API Key in the HTTP Authorization header. A single API Key grants access to all resources within its associated workspace.
SDKs
In addition to direct REST API calls, you can integrate using Python or Java SDKs. The Managed Agents module requires:
- Python SDK v1.26.2 or later
- Java SDK v2.22.24 or later
Requests and Responses
- Request bodies are JSON-formatted with
Content-Type: application/json. - Every response includes an
x-request-idheader. Include this ID when submitting support tickets to help accelerate issue resolution. - List endpoints support pagination:
limit: Number of items per page (default: 20; maximum: 100)page: Page number (omit for first page; usenext_pagefrom previous response for subsequent pages).
If the response does not containnext_page, you’ve reached the last page.
Available APIs
| Resource | Endpoint | Purpose |
|---|---|---|
| Agent | POST /agents | Create an Agent |
GET /agents/{agent_id} | Retrieve an Agent | |
GET /agents | List Agents | |
POST /agents/{agent_id} | Update an Agent (auto-generates a new version number) | |
POST /agents/{agent_id}/archive | Archive an Agent | |
| Environment | POST /environments | Create an Environment |
GET /environments/{environment_id} | Retrieve an Environment | |
GET /environments | List Environments | |
POST /environments/{environment_id} | Update an Environment | |
DELETE /environments/{environment_id} | Delete an Environment | |
POST /environments/{environment_id}/archive | Archive an Environment | |
| Session & Event | POST /sessions | Create a Session |
GET /sessions/{session_id} | Retrieve a Session | |
GET /sessions | List Sessions | |
POST /sessions/{session_id} | Update a Session (e.g., rename) | |
DELETE /sessions/{session_id} | Delete a Session | |
POST /sessions/{session_id}/archive | Archive a Session | |
POST /sessions/{session_id}/events | Send an Event (e.g., user message or tool response to the Agent) | |
GET /sessions/{session_id}/events | List event history; subscribe to SSE event stream (for streaming output) | |
| File | POST /files | Upload a File (multipart/form-data) |
GET /files/{file_id} | Retrieve File metadata | |
GET /files | List Files | |
DELETE /files/{file_id} | Delete a File | |
| Skill | POST /skills | Create a Skill |
GET /skills/{skill_id} | Retrieve a Skill | |
GET /skills | List Skills | |
DELETE /skills/{skill_id} | Delete a Skill | |
POST /skills/{skill_id}/versions | Upload a new version of a Skill | |
GET /skills/{skill_id}/versions/{version} | Retrieve a specific Skill version | |
GET /skills/{skill_id}/versions | List all versions of a Skill | |
GET /skills/{skill_id}/versions/{version}/content | Download a Skill package | |
| Vault | POST /vaults | Create a Vault |
GET /vaults/{vault_id} | Retrieve a Vault | |
GET /vaults | List Vaults | |
POST /vaults/{vault_id} | Update a Vault | |
DELETE /vaults/{vault_id} | Delete a Vault | |
POST /vaults/{vault_id}/archive | Archive a Vault | |
| Credential | POST /credentials | Create a Credential |
GET /credentials/{credential_id} | Retrieve a Credential | |
GET /credentials | List Credentials | |
POST /credentials/{credential_id} | Update a Credential | |
DELETE /credentials/{credential_id} | Delete a Credential | |
POST /credentials/{credential_id}/archive | Archive a Credential | |
| Webhook | POST /webhook_endpoints | Create a Webhook |
GET /webhook_endpoints/{id} | Retrieve a Webhook | |
GET /webhook_endpoints | List Webhooks | |
PUT /webhook_endpoints/{id} | Update a Webhook | |
DELETE /webhook_endpoints/{id} | Delete a Webhook | |
POST /webhook_endpoints/{id}/enable | Enable a Webhook | |
POST /webhook_endpoints/{id}/disable | Disable a Webhook | |
POST /webhook_endpoints/{id}/test | Test a Webhook | |
POST /webhook_endpoints/{id}/reset_secret | Reset the signing secret | |
GET /webhook_endpoints/{id}/events | List Webhook events |