Skip to main content

Connect to sandbox

Connect to an existing instance and return the tokens and domain information required for data-plane access. Compatible with the E2B connect protocol and corresponds to connect() in the SDK.

Prerequisites

Configure the endpoint and authentication first. See API overview and authentication.

Endpoint

POST /sandboxes/{sandboxID}/connect Connect to an existing instance and return the tokens and domain information required for data-plane access. Compatible with the E2B connect protocol and corresponds to connect() in the SDK.

Path parameters

ParameterRequiredTypeDescription
sandboxIDYesstringUnique instance ID.

Request body

The request body is optional.
FieldRequiredTypeDescription
timeoutNointegerInstance timeout after connecting, in seconds. Valid range: [300,604800].

Request example

curl -X POST "$BASE_URL/sandboxes/sbx-xxx/connect" \
  -H "Authorization: Bearer $BAILIAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"timeout": 3600}'
BASE_URL is https://{workspace_id}.cn-beijing.maas.aliyuncs.com/api/v1/agentstudio/sandbox, and BAILIAN_API_KEY is your Alibaba Cloud Model Studio API key.

Response example

{
  "sandboxID": "sbx-xxx",
  "templateID": "your-template-id",
  "envdVersion": "your-envd-version",
  "domain": "your-sandbox-domain",
  "envdAccessToken": "your-envd-access-token",
  "trafficAccessToken": "your-traffic-access-token",
  "envdUrl": "your-envd-url",
  "state": "running"
}

Response fields

FieldTypeDescription
sandboxIDstringUnique instance ID.
templateIDstringTemplate ID.
envdVersionstringenvd version.
domainstringData-plane access domain.
envdAccessTokenstringenvd access token.
trafficAccessTokenstringTraffic access token.
envdUrlstringenvd access URL.
statestringInstance state, for example running.
Managed Agent API
Flow Agent API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration