context.Context first. For workflows and examples, start with the Quickstart.
Client
agentbox.NewClient
Collections:
client.Agents, client.Sandboxes, client.Snapshots, client.Idcs, client.Products.
client.Eligibility
Eligible) and in which data centers (DataCenters).
Catalog
client.Idcs.List
"sandbox". Each Idc has IdcID() (use this as Idc / IdcName) and Name().
client.Products.List
Product has InstanceType() (the size ID) and Price().
Agents
client.Agents.Create
A sandbox Agent without
Idc or InstanceType returns HTTP 422.
client.Agents.Get / List / Update / Delete
Listpages start at 1. Default page size 20, maximum 100.Updatetakes amap[string]any. Locked fields return 422.Deletereturns 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
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,PauseandResumereturn*SandboxExpiry,*SandboxPauseand*SandboxResume, not the sandbox.client.Sandboxes.CreateSnapshotreturns a*Snapshotwith no Agent slug. ItsWaitUntilReadyandRefreshreturn an error. Usesandbox.CreateSnapshotwhen you need to wait for the snapshot.
client.Sandboxes.Launch
agent.Launch, by Agent slug. IdcName is required unless SnapshotID is set.
client.Sandboxes.List
client.Sandboxes.Get
sandbox.WaitUntilRunning
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
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
Status() is usually pausing. Poll with Refresh until paused. Returns 409 if the sandbox is not running.
sandbox.Resume
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
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
FileDownload with Content ([]byte), Filename and Header.
sandbox.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
stream.Next() (StreamEvent, bool), check stream.Err() when it returns false, and always call stream.Close(). StreamEvent has Event, Data and Raw.
sandbox.CreateSnapshot
sandbox.Metrics / MetricsTimeseries
Not supported on sandboxes. Return 501 (IsNotSupportedError).
sandbox.Delete
Sandbox
Execution
Snapshots
sandbox.CreateSnapshot
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
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
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
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.