Skip to main content
Requires Go 1.25.5+. Every method that calls the service takes a context.Context first. For workflows and examples, start with the Quickstart.

Client

agentbox.NewClient

Options Collections: client.Agents, client.Sandboxes, client.Snapshots, client.Idcs, client.Products.

client.Eligibility

Returns whether your organization can launch (Eligible) and in which data centers (DataCenters).

Catalog

client.Idcs.List

Lists data centers. Pass "sandbox". Each Idc has IdcID() (use this as Idc / IdcName) and Name().

client.Products.List

Lists sizes in a data center. Each Product has InstanceType() (the size ID) and Price().

Agents

client.Agents.Create

Creates an Agent and starts its image build. Does not start a sandbox. A sandbox Agent without Idc or InstanceType returns HTTP 422.

client.Agents.Get / List / Update / Delete

  • List pages start at 1. Default page size 20, maximum 100.
  • Update takes a map[string]any. Locked fields return 422.
  • Delete returns 409 (IsConflictError) while the Agent still has sandboxes, and can keep returning it for a few seconds after the last one is deleted. Retry on 409.

Agent

agent.Launch

Launches a sandbox and returns immediately. The sandbox starts as pending. Errors: 400 for invalid metadata or a timeout under 60; 404 for an unknown snapshot; 409 when the snapshot is not ready.

agent.BuildLogs

Returns BuildLogPage with Entries (each Offset, Level, Message, Timestamp), NextOffset and HasMore. Returns 410 (IsGoneError) when the logs have expired.

Sandboxes

Every method below exists on a *Sandbox, and on client.Sandboxes with the sandbox ID after the context. For example, sandbox.Pause(ctx) is the same as client.Sandboxes.Pause(ctx, sandboxID). The exceptions are WaitUntilRunning and Refresh, which exist only on a *Sandbox. Some collection methods return a different type:
  • client.Sandboxes.SetTimeout, Pause and Resume return *SandboxExpiry, *SandboxPause and *SandboxResume, not the sandbox.
  • client.Sandboxes.CreateSnapshot returns a *Snapshot with no Agent slug. Its WaitUntilReady and Refresh return an error. Use sandbox.CreateSnapshot when you need to wait for the snapshot.

client.Sandboxes.Launch

Same as agent.Launch, by Agent slug. IdcName is required unless SnapshotID is set.

client.Sandboxes.List

client.Sandboxes.Get

sandbox.WaitUntilRunning

Polls until the status is running. Defaults: Timeout 300 seconds, PollInterval 2 seconds. Returns *SandboxFailed if the status becomes error, deleted, stopped or stopping, and *SandboxWaitTimeout if the timeout passes first.

sandbox.Refresh

sandbox.SetTimeout

Sets the lifetime to now plus timeoutSeconds (minimum 60) and pins it. Works while the sandbox is running or paused. Errors: 400 if under 60 or above your account maximum; 409 if the sandbox is not running or paused.

sandbox.Pause

Pauses a running sandbox. Returns when accepted; Status() is usually pausing. Poll with Refresh until paused. Returns 409 if the sandbox is not running.

sandbox.Resume

Resumes a paused sandbox. Returns when accepted; Status() is usually resuming. Poll with WaitUntilRunning. Leave TimeoutSeconds nil to keep the run time left at pause; a value (60 or more) restarts the lifetime and pins it. Errors: 400 if under 60; 409 if the sandbox is not paused.

sandbox.Execute

Runs a command. Wait is a *bool and defaults to true. WaitTimeoutSeconds is a *int, 1 to 25, and is ignored when Wait is false. Accepted is true when the command is still running.

sandbox.GetExecution / CancelExecution

sandbox.UploadFile

sandboxPath must be absolute with no . or .. segments. filename defaults to the last element of sandboxPath when empty.

sandbox.DownloadFile

Returns FileDownload with Content ([]byte), Filename and Header.

sandbox.Shell

Opens an interactive shell. ShellMessage has Type (status, stdout or error), Data and Message. A connection allows one reader and one writer at a time. See Interactive shell.

sandbox.Stream

Read with stream.Next() (StreamEvent, bool), check stream.Err() when it returns false, and always call stream.Close(). StreamEvent has Event, Data and Raw.

sandbox.CreateSnapshot

Saves a running sandbox. See Snapshots.

sandbox.Metrics / MetricsTimeseries

Not supported on sandboxes. Return 501 (IsNotSupportedError).

sandbox.Delete

Deletes the sandbox. This cannot be undone.

Sandbox

Execution

Snapshots

sandbox.CreateSnapshot

Saves a running sandbox; the snapshot starts as creating. Name is up to 255 characters; if empty, one is generated. Errors: 403 if you are not the sandbox’s creator or an organization owner; 409 if the sandbox is not running.

snapshot.WaitUntilReady

Defaults: Timeout 300 seconds, PollInterval 2 seconds. Returns *SnapshotFailed if the status becomes error, deleting or delete_failed, and *SnapshotWaitTimeout if the timeout passes first.

snapshot.Rename

Only a ready or error snapshot can be renamed. name is 1 to 255 characters. Errors: 400 for an invalid name; 409 while still creating or being deleted.

snapshot.Delete

Deletes asynchronously; status becomes deleting.

Snapshot

Errors

Service errors are *agentbox.APIError with StatusCode, Message, Code and Details. Use errors.As, or the Is*Error helpers. See Errors and limits for the full table.