Alibaba Cloud SDK and API guide

Updated at:

Agent Sandbox Flash Edition provides entry points through native OpenAPI, Alibaba Cloud SDK, and Alibaba Cloud CLI. Install the SDK and configure access credentials and service endpoints to manage Agent Sandbox resources.

Features

The Agent Sandbox Flash Edition native OpenAPI provides management operations on resources such as Team, API Key, Template, Volume, and Quota. For the parameters of each operation, see the corresponding API and operation documentation.

The Agent Sandbox Flash Edition native OpenAPI uses Alibaba Cloud access credentials for signature authentication. When you use Agent Sandbox through the E2B SDK or E2B CLI, use an Agent Sandbox API Key. For the connection methods, see E2B SDK-compatible API List and E2B SDK connection parameters.

Prerequisites

Before you call the native OpenAPI, Alibaba Cloud SDK, and Alibaba Cloud CLI, make sure that the following conditions are met:

  • The Agent Sandbox service and the required features are activated in the target region.

  • The calling identity has the RAM (Resource Access Management) permissions on the target API operations and resources. For the authorization procedure, see Configure RAM User Permissions. The authorization requirements of each API operation are defined in the corresponding API documentation.

  • The region specified in the call matches the region where the target resource resides.

  • Alibaba Cloud access credentials are prepared. In production environments, STS (Security Token Service) temporary credentials of a RAM role are recommended to avoid storing an AccessKey pair in your code.

The calling identity of Alibaba Cloud SDK, Alibaba Cloud CLI, and online debugging must have the RAM permissions required for the operations to be performed. An Agent Sandbox API Key cannot replace the Alibaba Cloud access credentials required for signature authentication of the native OpenAPI.

OpenAPI entry points

Item

Value

Product identifier

Sandbox

API version

2026-08-20

Credentials

An Alibaba Cloud AccessKey pair, or an STS temporary credential that contains SecurityToken.

On the Sandbox product page or in the OpenAPI documentation, view the API list, request parameters, response structures, authorization requirements, and error messages. These pages also support online API debugging.

Service endpoints

The format of a public endpoint is sandbox.<region>.aliyuncs.com. For example, the endpoint of the China (Hangzhou) region is sandbox.cn-hangzhou.aliyuncs.com. Specify the domain name in the endpoint parameter of the SDK. Do not include https:// or the request path.

The examples in this topic explicitly configure a public endpoint. The region and network type of the endpoint must match your calling environment. Do not rely only on the automatic endpoint selection of the SDK. For the available endpoints, see Sandbox service endpoints.

Public endpoints are used for calls through Alibaba Cloud OpenAPI and SDK. For the API URL and domain that the E2B SDK uses, see E2B SDK connection parameters.

Call Agent Sandbox Flash Edition by using Alibaba Cloud SDK

The following SDKs are for Sandbox / 2026-08-20. The table lists the versions verified in this topic. For other languages, installation methods, and later versions, see Sandbox SDK center.

Language

SDK package or module

Version

Python

alibabacloud-sandbox20260820

1.2.0

Java

com.aliyun:sandbox20260820

1.2.0

Go

github.com/alibabacloud-go/sandbox-20260820

v1.2.0

TypeScript and Node.js

@alicloud/sandbox20260820

1.2.0

Install the Python SDK

Create a Python virtual environment and install the SDK:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --index-url https://pypi.org/simple "alibabacloud-sandbox20260820==1.2.0"

The installation command uses the official PyPI (Python Package Index) source to obtain the published version. If you use another package mirror, make sure that the required version has been synchronized to that mirror. The Python module name for import is alibabacloud_sandbox20260820.

Configure credentials and the region

Set the credentials, region, and endpoint in the runtime environment. The following example uses the China (Hangzhou) region. If you use another region, change the region and the endpoint at the same time:

export ALIBABA_CLOUD_ACCESS_KEY_ID="<YOUR-ACCESSKEY-ID>"
export ALIBABA_CLOUD_ACCESS_KEY_SECRET="<YOUR-ACCESSKEY-SECRET>"
# To use an STS temporary credential, also set the corresponding SecurityToken:
# export ALIBABA_CLOUD_SECURITY_TOKEN="<YOUR-SECURITY-TOKEN>"

export SANDBOX_REGION_ID="cn-hangzhou"
export SANDBOX_ENDPOINT="sandbox.cn-hangzhou.aliyuncs.com"

The AccessKey ID, AccessKey secret, and SecurityToken of an STS temporary credential must be used together, and the call must be made while the credential is valid.

Initialize the client and call an API operation

The following example uses ListTeams to query the first page of Teams. The calling identity must have the permission to call this operation. Save the code as list_teams.py:

import json
import os

from alibabacloud_sandbox20260820 import models
from alibabacloud_sandbox20260820.client import Client as SandboxClient
from alibabacloud_tea_openapi import utils_models as open_api_models


def require_env(name: str) -> str:
    value = os.environ.get(name, "").strip()
    if not value:
        raise RuntimeError(f"Missing environment variable: {name}")
    return value


config = open_api_models.Config(
    access_key_id=require_env("ALIBABA_CLOUD_ACCESS_KEY_ID"),
    access_key_secret=require_env("ALIBABA_CLOUD_ACCESS_KEY_SECRET"),
    security_token=os.environ.get("ALIBABA_CLOUD_SECURITY_TOKEN"),
    region_id=require_env("SANDBOX_REGION_ID"),
    endpoint=require_env("SANDBOX_ENDPOINT"),
)
client = SandboxClient(config)

response = client.list_teams(
    models.ListTeamsRequest(page_number=1, page_size=10)
)
if response.body is None:
    raise RuntimeError("ListTeams does not return a response body")

print(json.dumps(response.body.to_map(), ensure_ascii=False, indent=2))

Run the example:

python list_teams.py

The response contains the Team list of the current page, the total number of Teams, and the request ID. This example queries only the first page. To obtain more pages, adjust page_number based on the pagination information in the response.

To call other API operations, reuse the client initialization described above, and then configure the request model and parameters based on the corresponding operation documentation. The fields that each operation uses are defined by the documentation and SDK models of the current API version.

Call Agent Sandbox Flash Edition by using Alibaba Cloud CLI

Alibaba Cloud CLI is suitable for local verification and scripted calls. For information about how to install the CLI and configure credentials, see Alibaba Cloud CLI.

Select a target API operation on the Sandbox CLI call examples page to generate the corresponding command. When you make the call, use the product identifier Sandbox and the API version 2026-08-20. Configure an endpoint that matches the region and network type of the resource.

Calls through Alibaba Cloud SDK, Alibaba Cloud CLI, and online debugging are all subject to the RAM permissions of the calling identity. If a call fails, retain the returned request ID, error code, and error message, and troubleshoot the issue using the corresponding API documentation.