Skip to main content
@zodedev/sdk wraps the Zode API for Node. Version 0.2.0 is on npm. It is ESM only, needs Node 22 or later, and has no runtime dependencies. Python SDK: coming soon.

Install

The package ships as ES modules only. Load it with import, not require.

Get an API key

Create a key in the console under API keys (console.zode.dev/tokens), or with POST /v1/tokens (see the API reference). A key starts with zode_tok_ and belongs to one workspace.
The SDK does not read the sign-in that zode login saves for the CLI. It does read ZODE_TOKEN, so a shell set up for the CLI with that variable works for the SDK too.

Configure the client

new Zode(options) makes a client. Every option is optional.
  • org is a workspace id, sent as the X-Zode-Org header. You do not need it with an API key.
  • timeoutMs applies to each HTTP call. It is long by default because a create waits for the VM to boot. It does not limit streamed commands; those take their own timeoutMs (see Run commands).
  • fetch lets you swap in another implementation, for a proxy or tests.
  • An environment variable set to an empty string counts as unset.

Static helpers or a client

There are two ways to reach sandboxes:
  • Static helpers on Sandbox: Sandbox.create(opts), Sandbox.get(id) and Sandbox.list(filters). Each call builds a client from the environment unless you pass client, which takes a Zode instance or ZodeOptions.
  • A client: zode.sandboxes.create / get / list do the same thing. Snapshots (zode.snapshots) and environments (zode.environments) are only on the client.
Every Sandbox keeps the client that loaded it as sbx.client. For routes the SDK does not wrap, zode.request(method, path, body?, query?) sends a JSON request to any /v1 path and throws ZodeError on a non-2xx answer.

Records use the API’s field names

sbx.id, sbx.name and sbx.status are shortcuts. sbx.record returns a copy of the full API record, in the API’s snake_case:
Right after a create or fork whose browser or desktop could not be switched on, the record also has feature_error. The record updates after every call that returns a sandbox: refresh, stop, start, restore, and switching the browser or desktop. Options you pass in are camelCase (gitRepo, maxCostMicros); results such as exec’s exit_code keep the API’s names.

End-to-end example

Sandbox.create resolves once the VM is running. The fork is a second running sandbox, so this example needs room for two; the Free plan runs at most 2 at once.

Reference