Skip to main content
A sandbox is an isolated execution environment you allocate on demand to run code, shell commands, and file operations. Sandboxes are drawn from a warm pool, so allocation is fast, and each one is single-use — released sandboxes are not recycled.

Lifecycle

Use sandboxes when your agent needs to execute user-provided code, run a data transformation step, call a shell tool, or do any work that should be isolated and disposable. Common examples: an LLM agent that writes and runs Python to answer a data question, a CI tool that tests generated code, or a pipeline step that processes a file and discards the environment afterward. A sandbox moves through three states: Allocated sandboxes have a default TTL of 3600 seconds (1 hour). Extend it with renew, or release the sandbox when done.

SDK methods

Allocate a sandbox

Request parameters

string
required
Compute tier: micro, standard, large, or gpu.
integer
Time-to-live in seconds. Defaults to 3600.

Response

string
Unique identifier for the allocated sandbox.
string
Always allocated on success.
string
URL: https://sandbox-<id>.compute.hexelstudio.com
string
The tier allocated.
string
ISO 8601 timestamp when the sandbox will be terminated if not renewed.

Execute code

Execute parameters

string
Source code to execute. Provide either code or command, not both.
string
Language for the code (e.g., python). Required when code is provided.
string
Shell command to execute. Provide either command or code, not both.

Renew and release

List and get

Reach a running sandbox

An allocated sandbox is reachable at:
The sandbox transitions to terminated. Any running process is killed and local storage is destroyed. Extend the TTL with renew before expiry if you need more time.
No. Sandboxes are single-use. After release or termination, allocate a new one.
The allocation returns HTTP 503. There is no automatic fallback to another tier. Retry after a short delay or request a different tier.
Use a filesystem attached to a session. Sandbox-local storage is destroyed on termination.

Limits & quotas

Numeric limits depend on your plan — see the Console.

Errors

On 503, back off and retry. The SDKs retry 503 automatically with exponential backoff.

Security

Common mistakes

  • Reusing a released sandbox. Released sandboxes are terminated; allocate a new one.
  • Letting work outlive the TTL. Renew before the 1-hour default expires, or the sandbox terminates mid-execution.
  • Storing data you need to keep in a sandbox. Local storage is lost on termination — use a filesystem for persistence.

Best practices

  • Release sandboxes as soon as you’re done to free capacity.
  • Pick the smallest tier that fits the workload.
  • Use a persistent session with a filesystem when you need state across sandboxes.

Sessions & Filesystems

Persist data across sandboxes.

Compute Overview

Tiers and the compute model.

Agents

Long-running deployments instead of on-demand sandboxes.

Quickstart

Run your first sandbox.

Next steps

Continue to Agents to deploy long-running workloads.