OpenapiSandbox
Lease a sandbox — a real computer — or resume one you hold
Leases the caller's sandbox, or returns the one it named if that lease is still running.
POST /v1/sandbox/lease
| Address | https://api.hanzo.ai/v1/sandbox/lease |
| Method | POST |
| Operation | lease_sandbox |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Leases the caller's sandbox, or returns the one it named if that lease is still running.
What comes back is a real computer: a pod under a runtime boundary with a toolchain already in it, its own filesystem, and a lease that ends it. Every other op here acts on the one this returns.
Request
5 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
class | body | string | — | Class is what KIND of computer to lease, and the set is closed: exec a throwaway one that keeps nothing. Seconds to minutes. |
id | body | string | — | ID names a sandbox to RESUME, and is the id an earlier lease answered with. Empty asks for a new one. |
project | body | string | — | Project names the disk to attach, and is REQUIRED for every class but exec. |
runtime | body | string | — | Runtime is the isolation boundary asked for: gvisor shares a filesystem and holds a project volume, kata-fc is a microVM that boots slower and reads files… |
ttlSec | body | integer | — | TTLSec bounds the lease in seconds. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | Leased | ok |
200 body — 5 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
class | body | string | — | Class is what was actually leased, from the closed set LeaseIn.Class names: exec | dev | desktop | android. |
id | body | string | — | ID names this computer for every later call — run, read, write, stop and end all take it, and a LeaseIn carrying it resumes THIS sandbox instead of leasing a… |
runtime | body | string | — | Runtime is the boundary this sandbox GOT, which need not be the one asked for — carried for the same reason Workdir is, that it is a fact only the owner knows… |
status | body | string | — | Status is where the pod stands, from the store's three: pending | running | error. |
workdir | body | string | — | Workdir is the absolute directory this sandbox keeps files in, and what a relative path in a later read, write or run resolves against — /work for dev, desktop… |
Failure carries the platform error shape — see Errors.
Examples
hanzo sandboxes leaseimport { Configuration, SandboxApi } from 'hanzoai';
const api = new SandboxApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.leaseSandbox({ class: "<class>", id: "<id>" });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import SandboxApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = SandboxApi(client).lease_sandbox(class="<class>", id="<id>")cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.SandboxAPI.LeaseSandbox(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, sandbox_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = sandbox_api::lease_sandbox(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.SandboxApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new SandboxApi(client).leaseSandbox();curl -X POST https://api.hanzo.ai/v1/sandbox/lease \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"class": "<class>",
"id": "<id>"
}'Tool sandboxes, op lease_sandbox — POST the JSON-RPC envelope to https://api.hanzo.ai/v1/mcp.
curl -X POST https://api.hanzo.ai/v1/mcp \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "sandboxes",
"arguments": {
"op": "lease_sandbox",
"input": {
"class": "<class>",
"id": "<id>"
}
}
}
}'How is this guide?