Skip to content
Sandbox Runtime

Sandbox Runtime

The Sandbox Runtime API is provided by envd inside the sandbox. It is used to get runtime status, environment variables, and resource metrics, and it also serves as the access point for the Processes API and File System API.

Unlike region-level Open APIs, envd APIs require you to first get sandbox connection information through the Sandbox Instances API, then access the sandbox runtime proxy address.

Access Method

Get Connection Information

Call POST /sandboxes/{sandboxID}/connect, make sure the sandbox is running, and get domain and envdAccessToken.

bash
curl -X POST "$SUFY_SANDBOX_API_URL/sandboxes/$SANDBOX_ID/connect" \
  -H "X-API-Key: $SUFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"timeout": 300}'

Key response fields:

FieldTypeDescription
domainstringSandbox traffic access domain
envdAccessTokenstringRuntime token used to access envd

Build the envd Endpoint

envd is exposed through port 49983 by default. When accessed through the sandbox proxy, the endpoint format is:

text
https://49983-{sandboxID}.{domain}

Example:

bash
export ENVD_API_BASE="https://49983-$SANDBOX_ID.$SANDBOX_DOMAIN"

If domain is empty, the current sandbox connection information is not sufficient for direct access to envd from a browser or external HTTP client. Reconnect the sandbox before accessing envd.

Authentication

envd authenticates requests with the X-Access-Token header:

http
X-Access-Token: <envdAccessToken>

Some file download and upload APIs also support signature parameters, but for regular calls, X-Access-Token is recommended.

File download and upload APIs may use signed /files URLs. Process, PTY, and File System Connect RPC APIs use X-Access-Token.

Connect RPC APIs can also use Basic Auth to specify the execution user:

http
Authorization: Basic <base64("user:")>

If no user is specified, envd uses the sandbox default user.

Common Headers

HeaderRequiredDescription
X-Access-TokenYesenvd runtime access token
AuthorizationNoBasic Auth username used to specify the execution user
Content-TypeYesUse application/json for REST JSON APIs and Connect RPC JSON requests
Connect-Protocol-VersionRequired for Connect RPC requestsAlways 1

Health Check

Request Path

http
GET /health

Returns 204 No Content when healthy.

Request Example

bash
curl -I "$ENVD_API_BASE/health"

Query Runtime Metrics

Request Path

http
GET /metrics

Response Fields

FieldTypeDescription
tsintegerCurrent sandbox time, as a Unix timestamp in seconds
cpu_countintegerCPU core count
cpu_used_pctnumberCPU usage percentage
mem_totalintegerTotal memory in bytes
mem_usedintegerUsed memory in bytes
disk_totalintegerTotal disk space in bytes
disk_usedintegerUsed disk space in bytes

Request Example

bash
curl -X GET "$ENVD_API_BASE/metrics" \
  -H "X-Access-Token: $ENVD_ACCESS_TOKEN"

Query Environment Variables

Request Path

http
GET /envs

Returns an environment variable object. Both keys and values are strings.

Request Example

bash
curl -X GET "$ENVD_API_BASE/envs" \
  -H "X-Access-Token: $ENVD_ACCESS_TOKEN"

Initialize Runtime

Description

POST /init is used by the system side to initialize or update envd runtime state, such as synchronizing time and metadata, setting the access token, default user, default working directory, environment variables, mounts, and post-init actions.

This is a privileged API. Regular business scenarios usually do not need to call it directly. When creating or restoring a sandbox, the platform performs the required initialization.

Request Path

http
POST /init

Request Parameters

ParameterTypeRequiredDescription
hyperloopIPstringNohyperloop service IP
envVarsobjectNoEnvironment variables to merge into the runtime
accessTokenstringNoenvd access token. After it is set, it cannot be changed to a different value
timestampstringNoRFC3339 timestamp. Requests older than the most recent initialization are skipped
defaultUserstringNoDefault execution user
defaultWorkdirstringNoDefault working directory
mountsarrayNoFile system mounts to configure
postInitActionsarrayNoCommands to run after initialization
caCertPEMstringNoCA certificate to inject into the system trust store

Returns 204 No Content on success.