API Reference
Go SDK
Client
| Method | Signature | Description |
|---|---|---|
| NewClient | NewClient(baseURL, apiKey string) *Client | Create a new client with base URL and optional API key |
| GetSystemStats | GetSystemStats(ctx) (*SystemStats, error) | Get server-level CPU/memory stats |
Workspace Lifecycle
| Method | Signature | Description |
|---|---|---|
| CreateWorkspace | CreateWorkspace(ctx, WorkspaceRequest) (*WorkspaceResponse, error) | Create a new sandbox |
| DeleteWorkspace | DeleteWorkspace(ctx, id string) error | Destroy a sandbox |
| GetWorkspace | GetWorkspace(ctx, id string) (*Workspace, error) | Get sandbox metadata |
| ListWorkspaces | ListWorkspaces(ctx) ([]*Workspace, error) | List all sandboxes |
| PauseWorkspace | PauseWorkspace(ctx, id string) error | Pause the VM |
| ResumeWorkspace | ResumeWorkspace(ctx, id string) error | Resume the VM |
| ForkWorkspace | ForkWorkspace(ctx, id string) (*WorkspaceResponse, error) | Fork a sandbox |
| CommitWorkspace | CommitWorkspace(ctx, id, ref string) (*Image, error) | Commit filesystem as image |
| CreateSnapshot | CreateSnapshot(ctx, id string) (*SnapshotResponse, error) | Create a VM snapshot |
| Health | Health(ctx, id string) (*HealthResponse, error) | Check workspace health |
| SetInternet | SetInternet(ctx, id string, enabled bool) error | Toggle internet access |
Execution
| Method | Signature | Description |
|---|---|---|
| Exec | Exec(ctx, id string, ExecRequest) (*ExecResponse, error) | Execute a command in a sandbox |
File Operations
| Method | Signature | Description |
|---|---|---|
| ListFiles | ListFiles(ctx, id, path string) ([]FileInfo, error) | List directory contents |
| ReadFile | ReadFile(ctx, id, path string) (*FileResponse, error) | Read a file |
| WriteFile | WriteFile(ctx, id string, WriteFileRequest) error | Write a file |
| DeleteFile | DeleteFile(ctx, id, path string) error | Delete a file |
| GetArchive | GetArchive(ctx, id string) ([]byte, error) | Download workspace as tar archive |
Terminal
| Method | Signature | Description |
|---|---|---|
| ConnectTerminal | ConnectTerminal(ctx, id string) (*Terminal, error) | Open a WebSocket PTY session |
| ConnectLogs | ConnectLogs(ctx, id string) (*LogStream, error) | Stream serial console logs |
Process Management
| Method | Signature | Description |
|---|---|---|
| ListProcesses | ListProcesses(ctx, id string) ([]ProcessInfo, error) | List running processes |
| KillProcesses | KillProcesses(ctx, id string) error | Kill all processes |
Port & Preview
| Method | Signature | Description |
|---|---|---|
| GetPorts | GetPorts(ctx, id string) ([]PortInfo, error) | List open ports |
| GetPreviewURL | GetPreviewURL(ctx, id string, port int) (*PreviewURL, error) | Get a preview URL |
Image & Snapshot
| Method | Signature | Description |
|---|---|---|
| WarmImage | WarmImage(ctx, id string) error | Pre-warm an image for faster boot |
Key Types
types.go
type WorkspaceRequest struct {
Image string `json:"image"`
Cpus int64 `json:"cpus,omitempty"`
MemoryMB int64 `json:"memory_mb,omitempty"`
DiskSizeGB int `json:"disk_size_gb,omitempty"`
TimeoutMs int64 `json:"timeout_ms,omitempty"`
KeepAlive bool `json:"keep_alive,omitempty"`
Env map[string]string `json:"env,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
OnStart []string `json:"on_start,omitempty"`
OnReady []string `json:"on_ready,omitempty"`
}
type ExecRequest struct {
Cmd string `json:"cmd"`
Args []string `json:"args,omitempty"`
Envs map[string]string `json:"env,omitempty"`
Background bool `json:"background,omitempty"`
Language string `json:"language,omitempty"`
}
type ExecResponse struct {
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
Pid int `json:"pid,omitempty"`
}