Skip to content
Sandbox Instances

Sandbox Instances

The Sandbox Instances API is used to create, query, and manage the sandbox lifecycle, and to query sandbox logs and resource metrics.

Create a Sandbox

Description

Creates a sandbox instance from the specified template.

Request Path

http
POST /sandboxes

Request Parameters

ParameterTypeRequiredDescription
templateIDstringYesTemplate ID or template name
timeoutintegerNoSandbox timeout in seconds. Defaults to 15
autoPausebooleanNoWhether to automatically pause the sandbox after timeout. Defaults to false
securebooleanNoWhether to enable secure mode for sandbox system communication
allow_internet_accessbooleanNoWhether the sandbox can access the public internet. When false, this is equivalent to denying 0.0.0.0/0 outbound traffic in the network configuration
network.allowPublicTrafficbooleanNoWhether the sandbox's public access address allows public traffic. Defaults to true
network.allowOutstring[]NoCIDR or IP list allowed for outbound access
network.denyOutstring[]NoCIDR or IP list denied for outbound access
network.maskRequestHoststringNoHost mask used by sandbox requests
metadataobjectNoCustom metadata. Keys and values are strings
envVarsobjectNoEnvironment variables injected when the sandbox starts
mcpobjectNoMCP configuration
injectionsarrayNoInline secret injection rules. Up to 20 items
resourcesarrayNoExternal resources prepared and mounted before the sandbox starts. Up to 20 items

resources currently supports github_repository:

ParameterTypeRequiredDescription
resources[].typestringYesResource type. Use github_repository for GitHub repository resources
resources[].urlstringYesGitHub repository URL. HTTPS URLs and GitHub SSH-style URLs such as git@github.com:owner/repo.git are supported. The platform normalizes them to HTTPS
resources[].mount_pathstringYesAbsolute mount path for the repository contents inside the sandbox
resources[].authorization_tokenstringYesGitHub token used to access the repository. Multiple GitHub repository resources in the same sandbox currently must use the same token

Response Fields

FieldTypeDescription
templateIDstringTemplate ID used to create the sandbox
sandboxIDstringSandbox instance ID
aliasstringTemplate alias
envdVersionstringenvd version inside the sandbox
envdAccessTokenstringToken used to access envd inside the sandbox
trafficAccessTokenstringToken required to access sandbox proxy traffic
domainstringSandbox traffic access domain

Request Example

bash
curl -X POST "$SUFY_SANDBOX_API_URL/sandboxes" \
  -H "X-API-Key: $SUFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "templateID": "base",
    "timeout": 300,
    "metadata": {
      "project": "demo"
    },
    "envVars": {
      "APP_ENV": "dev"
    }
  }'

Response Example

json
{
  "templateID": "base",
  "sandboxID": "sbx_123456",
  "envdVersion": "0.1.0",
  "envdAccessToken": "envd-token",
  "trafficAccessToken": "traffic-token",
  "domain": "sbx_123456.example.sufyapi.com"
}

List Sandboxes

Description

Lists sandboxes under the current account. GET /v2/sandboxes is recommended because it supports state filtering and pagination.

Request Path

http
GET /v2/sandboxes

Compatible path:

http
GET /sandboxes

Request Parameters

ParameterTypeRequiredDescription
metadatastringNoMetadata filter, for example user=abc&app=prod. Keys and values must be URL-encoded
statestring[]NoSandbox state filter. Available values: running, paused
nextTokenstringNoPagination cursor
limitintegerNoNumber of items per page. Range: 1 to 100. Defaults to 100

Response Fields

Returns an array of sandbox objects:

FieldTypeDescription
templateIDstringTemplate ID used to create the sandbox
sandboxIDstringSandbox instance ID
aliasstringTemplate alias
startedAtstringSandbox start time
endAtstringSandbox expiration time
cpuCountintegerCPU core count
memoryMBintegerMemory size in MiB
diskSizeMBintegerDisk size in MiB
metadataobjectCustom metadata
statestringSandbox state. Available values: running, paused
envdVersionstringenvd version inside the sandbox
executionIdstringSandbox execution ID
uidstringSufy user UID

Request Example

bash
curl -G "$SUFY_SANDBOX_API_URL/v2/sandboxes" \
  -H "X-API-Key: $SUFY_API_KEY" \
  --data-urlencode "state=running" \
  --data-urlencode "limit=20"

Get Sandbox Details

Request Path

http
GET /sandboxes/{sandboxID}

Path Parameters

ParameterTypeRequiredDescription
sandboxIDstringYesSandbox instance ID

Response Fields

FieldTypeDescription
templateIDstringTemplate ID used to create the sandbox
sandboxIDstringSandbox instance ID
startedAtstringSandbox start time
endAtstringSandbox expiration time
cpuCountintegerCPU core count
memoryMBintegerMemory size in MiB
diskSizeMBintegerDisk size in MiB
metadataobjectCustom metadata
statestringSandbox state
envdVersionstringenvd version inside the sandbox
envdAccessTokenstringToken used to access envd inside the sandbox
domainstringSandbox traffic access domain

Delete a Sandbox

Description

Terminates and deletes the specified sandbox.

Request Path

http
DELETE /sandboxes/{sandboxID}

Path Parameters

ParameterTypeRequiredDescription
sandboxIDstringYesSandbox instance ID

Response Fields

Returns 204 No Content on success, with no response body.

Pause a Sandbox

Request Path

http
POST /sandboxes/{sandboxID}/pause

Returns 204 No Content on success.

Resume a Sandbox

Request Path

http
POST /sandboxes/{sandboxID}/resume

Request Parameters

ParameterTypeRequiredDescription
timeoutintegerNoTimeout after resume, in seconds. Defaults to 15
autoPausebooleanNoDeprecated. Whether to automatically pause after timeout

Returns sandbox connection information on success. The fields are the same as the create sandbox response.

Connect to a Sandbox

Description

Gets sandbox connection information. If the sandbox is paused, it is resumed first. If the sandbox is already running, only its TTL is extended.

Request Path

http
POST /sandboxes/{sandboxID}/connect

Request Parameters

ParameterTypeRequiredDescription
timeoutintegerYesTimeout from the current time, in seconds

Returns sandbox connection information on success. The fields are the same as the create sandbox response.

Set Sandbox Timeout

Request Path

http
POST /sandboxes/{sandboxID}/timeout

Request Parameters

ParameterTypeRequiredDescription
timeoutintegerYesTimeout from the current time, in seconds

Returns 204 No Content on success.

Extend Sandbox Lifetime

Request Path

http
POST /sandboxes/{sandboxID}/refreshes

Request Parameters

ParameterTypeRequiredDescription
durationintegerNoExtension duration in seconds. Maximum: 3600

Returns 204 No Content on success.

Query Sandbox Logs

Request Path

http
GET /sandboxes/{sandboxID}/logs

Request Parameters

ParameterTypeRequiredDescription
startintegerNoLog start timestamp in milliseconds
limitintegerNoNumber of log entries to return

Response Fields

FieldTypeDescription
logs[].timestampstringLog timestamp
logs[].linestringLog content
logEntries[].timestampstringStructured log timestamp
logEntries[].levelstringLog level
logEntries[].messagestringLog message
logEntries[].fieldsobjectStructured fields

Query Sandbox Metrics

Request Path

http
GET /sandboxes/{sandboxID}/metrics

Request Parameters

ParameterTypeRequiredDescription
startintegerNoStart Unix timestamp in seconds
endintegerNoEnd Unix timestamp in seconds

Response Fields

Returns an array of metric objects:

FieldTypeDescription
timestampUnixintegerMetric timestamp, as a Unix timestamp in seconds
cpuCountintegerCPU core count
cpuUsedPctnumberCPU usage percentage
memUsedintegerUsed memory in bytes
memTotalintegerTotal memory in bytes
diskUsedintegerUsed disk space in bytes
diskTotalintegerTotal disk space in bytes

Batch Query Sandbox Metrics

Request Path

http
GET /sandboxes/metrics

Request Parameters

ParameterTypeRequiredDescription
sandbox_idsstring[]YesSandbox ID list, passed as a single comma-separated query parameter. Up to 100 IDs

Request Example

bash
curl -G "$SUFY_SANDBOX_API_URL/sandboxes/metrics" \
  -H "X-API-Key: $SUFY_API_KEY" \
  --data-urlencode "sandbox_ids=sbx_123456,sbx_789012"

Response Fields

Returns a metrics object keyed by sandbox ID:

FieldTypeDescription
sandboxesobjectSandbox metrics map, keyed by sandbox ID
sandboxes.<sandboxID>.timestampUnixintegerMetric timestamp, as a Unix timestamp in seconds
sandboxes.<sandboxID>.cpuCountintegerCPU core count
sandboxes.<sandboxID>.cpuUsedPctnumberCPU usage percentage
sandboxes.<sandboxID>.memUsedintegerUsed memory in bytes
sandboxes.<sandboxID>.memTotalintegerTotal memory in bytes
sandboxes.<sandboxID>.diskUsedintegerUsed disk space in bytes
sandboxes.<sandboxID>.diskTotalintegerTotal disk space in bytes