Both SDKs expose the same public /api/v2 capabilities through resource
groups. Python offers synchronous BoxCompute and asynchronous
AsyncBoxCompute clients.
| Resource | TypeScript | Python | Purpose |
|---|---|---|---|
| Authentication | auth.revoke() |
auth.revoke() |
Revoke the current API key |
| Identity | me.get() |
me.get() |
Show the account and API key a credential authenticates |
| Workspaces | workspaces.list() |
workspaces.list() |
List persistent workspaces |
| Workspaces | workspaces.create() |
workspaces.create() |
Create a workspace idempotently |
| Sandboxes | sandboxes.list() |
sandboxes.list() |
List Sandbox instances |
| Sandboxes | sandboxes.create() |
sandboxes.create() |
Create and start a Sandbox |
| Sandboxes | sandboxes.inspect() |
sandboxes.inspect() |
Read current Sandbox state |
| Sandboxes | sandboxes.start() |
sandboxes.start() |
Start a stopped Sandbox, keeping its workspace |
| Sandboxes | sandboxes.stop() |
sandboxes.stop() |
Stop a running VM now, keeping its workspace |
| Sandboxes | sandboxes.execute() |
sandboxes.execute() |
Execute and wait for a command |
| Sandboxes | sandboxes.logs() |
sandboxes.logs() |
Read retained Sandbox logs |
| Sandboxes | sandboxes.delete() |
sandboxes.delete() |
Delete a Sandbox |
| Sandboxes | sandboxes.analytics() |
sandboxes.analytics() |
Read lifecycle, operation, and resource analytics |
| Sandboxes | sandboxes.costs() |
sandboxes.costs() |
List every charged run with a running estimate |
| Previews | previews.create() |
previews.create() |
Open a one-hour HTTP/WebSocket preview of a VM port |
| Previews | previews.close() |
previews.close() |
Close a preview before it expires |
| Deleted Sandboxes | deletedSandboxes.list() |
deleted_sandboxes.list() |
List deleted Sandboxes, newest first |
| Deleted Sandboxes | deletedSandboxes.logs() |
deleted_sandboxes.logs() |
Read a deleted Sandbox's retained logs |
| Deleted Sandboxes | deletedSandboxes.costs() |
deleted_sandboxes.costs() |
List a deleted Sandbox's charged runs |
| Operations | operations.start() |
operations.start() |
Start an observable command |
| Operations | operations.inspect() |
operations.inspect() |
Read operation state |
| Operations | operations.output() |
operations.output() |
Page stdout or stderr |
| Operations | operations.wait() |
operations.wait() |
Long-poll operation state |
| Operations | operations.cancel() |
operations.cancel() |
Request cancellation |
| Files | files.stat() |
files.stat() |
Inspect a workspace path |
| Files | files.read() |
files.read() |
Read binary bytes with paging metadata |
| Files | files.write() |
files.write() |
Write binary bytes |
| Files | files.edit() |
files.edit() |
Conditionally edit UTF-8 text |
| Files | files.list() |
files.list() |
Page a directory listing |
| Files | files.mkdir() |
files.mkdir() |
Create a directory |
| Files | files.rename() |
files.rename() |
Atomically rename a path |
| Files | files.remove() |
files.remove() |
Remove a path |
| Usage | usage.get() |
usage.get() |
Read account usage |
| Billing | billing.get() |
billing.get() |
Remaining credits, settled spending and pending reservations |
| Billing | billing.transactions() |
billing.transactions() |
Page verified wallet transactions |
| Costs | costs.sandboxes() |
costs.sandboxes() |
Compute cost per API key and per Sandbox |
| Audit log | auditEvents.list() |
audit_events.list() |
Page the account's API audit log, newest first |
Python spells the from query parameter as from_. Audit pages return
nextCursor; pass it as before to read the next page.
Billing amounts are integer micro-USD: 1_000_000 is $1.
balance.availableMicros subtracts reservations and running compute from the
settled balance, and is null when live compute estimates are unavailable.
settledUsage is all-time wallet deductions, excluding pending work and
observation-mode AI. billing.transactions() returns bucket-level entries
(one charge may spend several buckets), with signed amounts, inclusive from,
exclusive to, and cursor pagination. Both reads require usage:read and never
start or resume compute.
Python response fields use snake_case: balance.available_micros,
settled_usage.total_micros, and next_cursor.
All file paths must be /workspace or a descendant. Identifiers are URL
encoded by the SDKs. Mutation retries must follow the rules in
idempotency.md.
sandboxes.create() accepts VM-only runtime options. vmSandbox defaults to
true (VM runtime); new gVisor container sandboxes are no longer created, so
false is rejected with INVALID_REQUEST. blockNetwork defaults to false
(Internet) and true selects a sandbox without a NIC.
size selects the VM compute tier and defaults to "small":
size |
vCPU | Memory | Workspace |
|---|---|---|---|
"small" |
0.5 | 1024 MiB | 30 GiB |
"large" |
1.5 | 3072 MiB | 30 GiB |
Both profiles use a 30 GiB thin-provisioned workspace. Omit size (or pass
"small") to use the default. Sandbox.size reports the immutable
profile; it is absent for historical replays, which are small.
await boxcompute.sandboxes.create({ workspaceId, size: "large", idempotencyKey });boxcompute.sandboxes.create(workspace_id=workspace_id, size="large", idempotency_key=key)A running VM bills compute until it stops. It stops on its own 30 minutes after
the last API call that used it, or at once with sandboxes.stop(). Its
/workspace files survive a stop; memory and running processes do not.
- Counts as use:
sandboxes.start(),sandboxes.execute(), everyfiles.*call,operations.start(),previews.create()and requests to a preview URL. - Does not count:
sandboxes.inspect(),logs(),analytics(),costs(), polling or waiting on an operation, and CPU or network activity inside the VM. A background process alone does not keep a VM running.
Sandbox.lastUsedAt is the last counted call while the VM runs, so the idle
stop happens about 30 minutes after it; after a stop it is when the VM stopped.
state is running or cold (stopped, disk kept).
sandboxes.stop() never wakes a stopped VM and needs no credit, so it works at
zero balance. It returns { sandbox, stopped }, with stopped false when the VM
was not running; a 409 means the VM is still starting, stopping or in use, so
try again shortly. It requires the sandbox:create scope, like start().
execute(), files.* and start() wake a stopped VM again, which takes about
30 seconds; inspect() never does.
const result = await boxcompute.sandboxes.execute(sandbox.id, { argv: ["make", "test"] });
await boxcompute.sandboxes.stop(sandbox.id); // done for now; files stayresult = boxcompute.sandboxes.execute(sandbox.id, argv=["make", "test"])
boxcompute.sandboxes.stop(sandbox.id) # done for now; files stay