Skip to content

Create a Sandbox

This guide shows you how to create an Agent Sandbox using the REST API.

Send a POST request to /v1/sandboxes with your container image, entrypoint, resource limits and the sandbox cluster ID in extensions. The sandbox is ready within seconds.

Terminal window
curl -X POST https://api.nirvanalabs.io/v1/sandboxes \
-H "Content-Type: application/json" \
-H "OPEN-SANDBOX-API-KEY: $NIRVANA_API_KEY" \
-d '{
"image": {"uri": "python:3.12-slim"},
"entrypoint": ["python3", "-m", "http.server", "8000"],
"resourceLimits": {"cpu": "1", "memory": "1Gi"},
"extensions": {
"nirvana.sandbox_cluster_id": "123e4567-e89b-12d3-a456-426614174000"
}
}'

The response includes the sandbox id. Its extensions also carry nirvana.sandbox_cluster_id and nirvana.region.

Add a pvc volume to keep data on block storage. See Persistence & Storage for the options.

Terminal window
curl -X POST https://api.nirvanalabs.io/v1/sandboxes \
-H "Content-Type: application/json" \
-H "OPEN-SANDBOX-API-KEY: $NIRVANA_API_KEY" \
-d '{
"image": {"uri": "python:3.12-slim"},
"entrypoint": ["python3", "-m", "http.server", "8000"],
"resourceLimits": {"cpu": "2", "memory": "2Gi"},
"volumes": [
{
"name": "workspace",
"pvc": {
"claimName": "agent-workspace",
"createIfNotExists": true,
"storage": "50Gi"
},
"mountPath": "/workspace"
}
],
"extensions": {
"nirvana.sandbox_cluster_id": "123e4567-e89b-12d3-a456-426614174000"
}
}'

Container image to run, as a URI such as python:3.12-slim or node:18-alpine.

Command to run when the sandbox starts.

CPU and memory for the sandbox:

  • CPU: cores as a string, such as "1", "2" or "2000m".
  • Memory: a size such as "512Mi", "1Gi" or "2Gi".

Optional timeout in seconds, after which the sandbox expires. Without it, the sandbox doesn’t expire. Extend it later with renew-expiration.

  • nirvana.sandbox_cluster_id (required): ID of the sandbox cluster to run the sandbox on.
  • snapshotId: creating sandboxes from snapshots.
  • host and ossfs volumes. Only pvc volumes are accepted.