Skip to main content
Sandbox API

API Overview and Authentication

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.

Prerequisites

  1. Activate Bailian and create an API Key: obtain one from the console.
  2. Complete service authorization: first-time use of Sandbox requires SLR authorization. See Quick Start.
  3. 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:
https://{workspace_id}.{region}.maas.aliyuncs.com/api/v1/agentstudio/sandbox
  • workspace_id: workspace ID
  • region: region ID, currently only cn-beijing

Authentication

All requests carry the Bailian API Key via an HTTP header:
Authorization: Bearer <your-api-key>
When using the E2B SDK, the SDK-required 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

CapabilityMethodPath
Create instancePOST/sandboxes
List instancesGET/v2/sandboxes
Get instanceGET/sandboxes/{sandboxID}
Connect to instancePOST/sandboxes/{sandboxID}/connect
Pause instancePOST/sandboxes/{sandboxID}/pause
Resume instancePOST/sandboxes/{sandboxID}/resume
Release instanceDELETE/sandboxes/{sandboxID}

Template Management

CapabilityMethodPath
Create templatePOST/v3/templates
List templatesGET/v2/templates
Get templateGET/templates/{templateCode}
Update templatePUT/templates/{templateCode}
Get build statusGET/templates/{templateCode}/builds/{buildID}/status
Delete templateDELETE/templates/{templateCode}

Error Responses

When a call fails, the error response looks like this:
{
  "code": 100004,
  "message": "Missing parameter",
  "requestID": "request-id"
}
Common HTTP status codes:
HTTP statusDescription
400Missing parameter, malformed format, or value out of range
401Invalid API Key
404Template or instance not found
409The current resource state does not allow this operation
500Internal service error
501Not 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.

SDK

In addition to calling the REST API directly, you can integrate via the official E2B SDK. See Manage and Use Instances.
Overview
Managed Agent API
Sandbox API
Memory API
Flow Agent API
RAG API
Connector API
Framework Integration
Assistant API (Deprecating)
  • Overview