The Sandbox API is E2B-compatible and provides sandbox instance lifecycle management and template management, forwarded through the Bailian AI gateway.
The Sandbox API is compatible with the E2B protocol and provides sandbox instance lifecycle management and template management. Control-plane requests are forwarded through the Bailian AI gateway.
The API base URL is assembled from the workspace and region:
All requests carry the Bailian API Key via an HTTP header:
When using the E2B SDK, the SDK-required
When a call fails, the error response looks like this:
Common HTTP status codes:
Sandbox currently exposes an E2B-compatible HTTP API. Each endpoint's method, path, and response structure stay close to the official E2B definitions. Except for the Update Template endpoint, which is a Bailian-specific protocol, the common fields and semantics of the other endpoints can be found in the official E2B API documentation:
In addition to calling the REST API directly, you can integrate via the official E2B SDK. See Manage and Use Instances.
Prerequisites
- Activate Bailian and create an API Key: obtain one from the console.
- Complete service authorization: first-time use of Sandbox requires SLR authorization. See Quick Start.
- Get your workspace ID: view it in the dropdown at the top-right of the Bailian console, in the form
{workspace_id}.
Endpoint
The API base URL is assembled from the workspace and region:
workspace_id: workspace IDregion: region ID, currently onlycn-beijing
Authentication
All requests carry the Bailian API Key via an HTTP header:
X-API-Key / api_key only satisfies the E2B protocol format; Bailian does not use it for business authentication. We recommend e2b_${ALIYUN_UID}.
E2B-compatible endpoints return response bodies close to the native E2B structure and are not wrapped in Bailian's unified
Result<T> structure.Available APIs
Instance Management
| Capability | Method | Path |
|---|---|---|
| Create instance | POST | /sandboxes |
| List instances | GET | /v2/sandboxes |
| Get instance | GET | /sandboxes/{sandboxID} |
| Connect to instance | POST | /sandboxes/{sandboxID}/connect |
| Pause instance | POST | /sandboxes/{sandboxID}/pause |
| Resume instance | POST | /sandboxes/{sandboxID}/resume |
| Release instance | DELETE | /sandboxes/{sandboxID} |
Template Management
| Capability | Method | Path |
|---|---|---|
| Create template | POST | /v3/templates |
| List templates | GET | /v2/templates |
| Get template | GET | /templates/{templateCode} |
| Update template | PUT | /templates/{templateCode} |
| Get build status | GET | /templates/{templateCode}/builds/{buildID}/status |
| Delete template | DELETE | /templates/{templateCode} |
Error Responses
When a call fails, the error response looks like this:
| HTTP status | Description |
|---|---|
| 400 | Missing parameter, malformed format, or value out of range |
| 401 | Invalid API Key |
| 404 | Template or instance not found |
| 409 | The current resource state does not allow this operation |
| 500 | Internal service error |
| 501 | Not supported in the current version |
E2B Official Reference
Sandbox currently exposes an E2B-compatible HTTP API. Each endpoint's method, path, and response structure stay close to the official E2B definitions. Except for the Update Template endpoint, which is a Bailian-specific protocol, the common fields and semantics of the other endpoints can be found in the official E2B API documentation:
This documentation lists only the endpoints and Bailian extension fields that Bailian supports. Bailian's authentication, endpoint, and extension configurations follow this documentation; common protocol fields can be cross-referenced with the official E2B docs.