# Sandbox VMs

## Create Agent Sandbox

`client.SandboxVMs.New(ctx, body) (*Operation, error)`

**post** `/v1/sandbox_vms`

Create an Agent Sandbox to run sandboxes on. An Agent Sandbox can be paused and resumed, and is billed for compute only while it is running.

### Parameters

- `body SandboxVMNewParams`

  - `Name param.Field[string]`

    Name of the Agent Sandbox. Unique within its project.

  - `ProjectID param.Field[string]`

    ID of the project to create the Agent Sandbox in.

  - `Region param.Field[RegionName]`

    Region the resource is in.

  - `InstanceType param.Field[string]`

    Instance type of the Agent Sandbox. Defaults to n1-highcpu-2 (2 vCPU, 4 GiB), the only size available.

  - `Tags param.Field[[]string]`

    Tags to attach to the Agent Sandbox.

  - `VPCID param.Field[string]`

    ID of the VPC to place the Agent Sandbox in. It must be a ready VPC in the Agent Sandbox's project and region.
    Omit it to use the project's oldest ready VPC in the region, or a new VPC when there is none.

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    Structured details about what an operation is changing.

    - `Changes OperationChanges`

      Map of changed field names to their from/to diffs. Keys depend on the parent operation's kind+type.

      - `From OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

    - `const OperationKindSandboxCluster OperationKind = "sandbox_cluster"`

    - `const OperationKindSandboxVM OperationKind = "sandbox_vm"`

    - `const OperationKindBucket OperationKind = "bucket"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

    - `const OperationTypePause OperationType = "pause"`

    - `const OperationTypeResume OperationType = "resume"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/sandbox_vms"
  "github.com/nirvana-labs/nirvana-go/shared"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.SandboxVMs.New(context.TODO(), sandbox_vms.SandboxVMNewParams{
    Name: "my-sandboxes",
    ProjectID: "123e4567-e89b-12d3-a456-426614174000",
    Region: shared.RegionNameUsSva2,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", operation.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "details": {
    "changes": {
      "foo": {
        "from": "string",
        "to": "string"
      }
    }
  },
  "kind": "vm",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "resource_id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "pending",
  "type": "create",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Get Agent Sandbox

`client.SandboxVMs.Get(ctx, sandboxVMID) (*SandboxVM, error)`

**get** `/v1/sandbox_vms/{sandbox_vm_id}`

Get an Agent Sandbox

### Parameters

- `sandboxVMID string`

### Returns

- `type SandboxVM struct{…}`

  An Agent Sandbox: a VM sandboxes run on, in one region. It can be paused and resumed.

  - `ID string`

    Unique identifier for the Agent Sandbox.

  - `CreatedAt Time`

    When the Agent Sandbox was created.

  - `EndpointHostname string`

    Hostname the Agent Sandbox's sandbox API is served on over HTTPS. It stays the same for the life of the Agent Sandbox. Null until assigned.

  - `ImageVersion string`

    Version of the image the Agent Sandbox runs. Null until it is running.

  - `InstanceType string`

    Instance type of the Agent Sandbox.

  - `Name string`

    Name of the Agent Sandbox.

  - `OpensandboxVersion string`

    Version of OpenSandbox the Agent Sandbox runs. Null until it is running.

  - `PausedAt Time`

    When the Agent Sandbox was paused. Null while it is running.

  - `PowerState SandboxVMPowerState`

    Whether the Agent Sandbox's sandboxes can run.

    - `const SandboxVMPowerStateRunning SandboxVMPowerState = "running"`

    - `const SandboxVMPowerStatePaused SandboxVMPowerState = "paused"`

    - `const SandboxVMPowerStatePoweredOff SandboxVMPowerState = "powered_off"`

  - `PowersOffAt Time`

    When the paused Agent Sandbox is, or was, powered off. Null while it is running.

  - `ProjectID string`

    ID of the project the Agent Sandbox is in.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

    - `const RegionNameUsWdc1 RegionName = "us-wdc-1"`

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

    - `const ResourceStatusSuspended ResourceStatus = "suspended"`

  - `Tags []string`

    Tags attached to the Agent Sandbox.

  - `UpdatedAt Time`

    When the Agent Sandbox was last updated.

  - `VPCID string`

    ID of the VPC the Agent Sandbox is in. Null until it is placed in one.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  sandboxVM, err := client.SandboxVMs.Get(context.TODO(), "sandbox_vm_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sandboxVM.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "endpoint_hostname": "0123456789ab.sandboxes.example.com",
  "image_version": "2026.11.1",
  "instance_type": "n1-highcpu-2",
  "name": "my-sandboxes",
  "opensandbox_version": "1.2.0",
  "paused_at": "2025-01-01T00:00:00Z",
  "power_state": "running",
  "powers_off_at": "2025-01-01T01:00:00Z",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "region": "us-sva-2",
  "status": "ready",
  "tags": [
    "production",
    "agents"
  ],
  "updated_at": "2025-01-01T00:00:00Z",
  "vpc_id": "123e4567-e89b-12d3-a456-426614174000"
}
```

## Update Agent Sandbox

`client.SandboxVMs.Update(ctx, sandboxVMID, body) (*SandboxVM, error)`

**patch** `/v1/sandbox_vms/{sandbox_vm_id}`

Update an Agent Sandbox's name and tags

### Parameters

- `sandboxVMID string`

- `body SandboxVMUpdateParams`

  - `Name param.Field[string]`

    Name of the Agent Sandbox. Unique within its project.

  - `Tags param.Field[[]string]`

    Tags to attach to the Agent Sandbox.

### Returns

- `type SandboxVM struct{…}`

  An Agent Sandbox: a VM sandboxes run on, in one region. It can be paused and resumed.

  - `ID string`

    Unique identifier for the Agent Sandbox.

  - `CreatedAt Time`

    When the Agent Sandbox was created.

  - `EndpointHostname string`

    Hostname the Agent Sandbox's sandbox API is served on over HTTPS. It stays the same for the life of the Agent Sandbox. Null until assigned.

  - `ImageVersion string`

    Version of the image the Agent Sandbox runs. Null until it is running.

  - `InstanceType string`

    Instance type of the Agent Sandbox.

  - `Name string`

    Name of the Agent Sandbox.

  - `OpensandboxVersion string`

    Version of OpenSandbox the Agent Sandbox runs. Null until it is running.

  - `PausedAt Time`

    When the Agent Sandbox was paused. Null while it is running.

  - `PowerState SandboxVMPowerState`

    Whether the Agent Sandbox's sandboxes can run.

    - `const SandboxVMPowerStateRunning SandboxVMPowerState = "running"`

    - `const SandboxVMPowerStatePaused SandboxVMPowerState = "paused"`

    - `const SandboxVMPowerStatePoweredOff SandboxVMPowerState = "powered_off"`

  - `PowersOffAt Time`

    When the paused Agent Sandbox is, or was, powered off. Null while it is running.

  - `ProjectID string`

    ID of the project the Agent Sandbox is in.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

    - `const RegionNameUsWdc1 RegionName = "us-wdc-1"`

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

    - `const ResourceStatusSuspended ResourceStatus = "suspended"`

  - `Tags []string`

    Tags attached to the Agent Sandbox.

  - `UpdatedAt Time`

    When the Agent Sandbox was last updated.

  - `VPCID string`

    ID of the VPC the Agent Sandbox is in. Null until it is placed in one.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/sandbox_vms"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  sandboxVM, err := client.SandboxVMs.Update(
    context.TODO(),
    "sandbox_vm_id",
    sandbox_vms.SandboxVMUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sandboxVM.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "endpoint_hostname": "0123456789ab.sandboxes.example.com",
  "image_version": "2026.11.1",
  "instance_type": "n1-highcpu-2",
  "name": "my-sandboxes",
  "opensandbox_version": "1.2.0",
  "paused_at": "2025-01-01T00:00:00Z",
  "power_state": "running",
  "powers_off_at": "2025-01-01T01:00:00Z",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "region": "us-sva-2",
  "status": "ready",
  "tags": [
    "production",
    "agents"
  ],
  "updated_at": "2025-01-01T00:00:00Z",
  "vpc_id": "123e4567-e89b-12d3-a456-426614174000"
}
```

## Delete Agent Sandbox

`client.SandboxVMs.Delete(ctx, sandboxVMID) (*Operation, error)`

**delete** `/v1/sandbox_vms/{sandbox_vm_id}`

Delete an Agent Sandbox, with its sandboxes and its disk. An Agent Sandbox can be deleted when it is ready or failed, whether it is running, paused or powered off.

### Parameters

- `sandboxVMID string`

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    Structured details about what an operation is changing.

    - `Changes OperationChanges`

      Map of changed field names to their from/to diffs. Keys depend on the parent operation's kind+type.

      - `From OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

    - `const OperationKindSandboxCluster OperationKind = "sandbox_cluster"`

    - `const OperationKindSandboxVM OperationKind = "sandbox_vm"`

    - `const OperationKindBucket OperationKind = "bucket"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

    - `const OperationTypePause OperationType = "pause"`

    - `const OperationTypeResume OperationType = "resume"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.SandboxVMs.Delete(context.TODO(), "sandbox_vm_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", operation.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "details": {
    "changes": {
      "foo": {
        "from": "string",
        "to": "string"
      }
    }
  },
  "kind": "vm",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "resource_id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "pending",
  "type": "create",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## List Agent Sandboxes

`client.SandboxVMs.List(ctx, query) (*Cursor[SandboxVM], error)`

**get** `/v1/sandbox_vms`

List the Agent Sandboxes in a project

### Parameters

- `query SandboxVMListParams`

  - `ProjectID param.Field[string]`

    Project ID of resources to request

  - `Cursor param.Field[string]`

    Pagination cursor returned by a previous request. Only valid for the same sort order.

  - `Limit param.Field[int64]`

    Maximum number of items to return

  - `Name param.Field[string]`

    Filter by a case-insensitive substring of the Agent Sandbox name

  - `Region param.Field[string]`

    Filter by region

  - `Sort param.Field[string]`

    Comma-separated sort terms in precedence order, each field:asc or field:desc. Fields: created_at, updated_at

  - `Tags param.Field[[]string]`

    Filter by tags. Repeat the parameter to require several tags; an Agent Sandbox must carry all of them.

### Returns

- `type SandboxVM struct{…}`

  An Agent Sandbox: a VM sandboxes run on, in one region. It can be paused and resumed.

  - `ID string`

    Unique identifier for the Agent Sandbox.

  - `CreatedAt Time`

    When the Agent Sandbox was created.

  - `EndpointHostname string`

    Hostname the Agent Sandbox's sandbox API is served on over HTTPS. It stays the same for the life of the Agent Sandbox. Null until assigned.

  - `ImageVersion string`

    Version of the image the Agent Sandbox runs. Null until it is running.

  - `InstanceType string`

    Instance type of the Agent Sandbox.

  - `Name string`

    Name of the Agent Sandbox.

  - `OpensandboxVersion string`

    Version of OpenSandbox the Agent Sandbox runs. Null until it is running.

  - `PausedAt Time`

    When the Agent Sandbox was paused. Null while it is running.

  - `PowerState SandboxVMPowerState`

    Whether the Agent Sandbox's sandboxes can run.

    - `const SandboxVMPowerStateRunning SandboxVMPowerState = "running"`

    - `const SandboxVMPowerStatePaused SandboxVMPowerState = "paused"`

    - `const SandboxVMPowerStatePoweredOff SandboxVMPowerState = "powered_off"`

  - `PowersOffAt Time`

    When the paused Agent Sandbox is, or was, powered off. Null while it is running.

  - `ProjectID string`

    ID of the project the Agent Sandbox is in.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

    - `const RegionNameUsWdc1 RegionName = "us-wdc-1"`

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

    - `const ResourceStatusSuspended ResourceStatus = "suspended"`

  - `Tags []string`

    Tags attached to the Agent Sandbox.

  - `UpdatedAt Time`

    When the Agent Sandbox was last updated.

  - `VPCID string`

    ID of the VPC the Agent Sandbox is in. Null until it is placed in one.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/sandbox_vms"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  page, err := client.SandboxVMs.List(context.TODO(), sandbox_vms.SandboxVMListParams{
    ProjectID: "project_id",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
```

#### Response

```json
{
  "items": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "created_at": "2025-01-01T00:00:00Z",
      "endpoint_hostname": "0123456789ab.sandboxes.example.com",
      "image_version": "2026.11.1",
      "instance_type": "n1-highcpu-2",
      "name": "my-sandboxes",
      "opensandbox_version": "1.2.0",
      "paused_at": "2025-01-01T00:00:00Z",
      "power_state": "running",
      "powers_off_at": "2025-01-01T01:00:00Z",
      "project_id": "123e4567-e89b-12d3-a456-426614174000",
      "region": "us-sva-2",
      "status": "ready",
      "tags": [
        "production",
        "agents"
      ],
      "updated_at": "2025-01-01T00:00:00Z",
      "vpc_id": "123e4567-e89b-12d3-a456-426614174000"
    }
  ],
  "pagination": {
    "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
    "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
    "total_count": 125
  }
}
```

## Pause Agent Sandbox

`client.SandboxVMs.Pause(ctx, sandboxVMID) (*Operation, error)`

**post** `/v1/sandbox_vms/{sandbox_vm_id}/pause`

Pause an Agent Sandbox. Its sandboxes stop, keeping their files and installed packages but not their
running processes or memory, and compute billing stops. After an hour paused the Agent Sandbox is
powered off. A pause sent while another change runs waits for it, and pausing a paused Agent Sandbox
changes nothing.

### Parameters

- `sandboxVMID string`

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    Structured details about what an operation is changing.

    - `Changes OperationChanges`

      Map of changed field names to their from/to diffs. Keys depend on the parent operation's kind+type.

      - `From OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

    - `const OperationKindSandboxCluster OperationKind = "sandbox_cluster"`

    - `const OperationKindSandboxVM OperationKind = "sandbox_vm"`

    - `const OperationKindBucket OperationKind = "bucket"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

    - `const OperationTypePause OperationType = "pause"`

    - `const OperationTypeResume OperationType = "resume"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.SandboxVMs.Pause(context.TODO(), "sandbox_vm_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", operation.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "details": {
    "changes": {
      "foo": {
        "from": "string",
        "to": "string"
      }
    }
  },
  "kind": "vm",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "resource_id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "pending",
  "type": "create",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Resume Agent Sandbox

`client.SandboxVMs.Resume(ctx, sandboxVMID) (*Operation, error)`

**post** `/v1/sandbox_vms/{sandbox_vm_id}/resume`

Resume a paused or powered-off Agent Sandbox, restarting its sandboxes. A resume sent while another
change runs waits for it, and resuming a running Agent Sandbox changes nothing. Pausing doesn't free
quota and resuming doesn't use any: a paused Agent Sandbox still counts toward the sandbox quota's vms,
and Agent Sandboxes don't count toward its vcpu or memory_gb. A billing block returns 402.

### Parameters

- `sandboxVMID string`

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    Structured details about what an operation is changing.

    - `Changes OperationChanges`

      Map of changed field names to their from/to diffs. Keys depend on the parent operation's kind+type.

      - `From OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

    - `const OperationKindSandboxCluster OperationKind = "sandbox_cluster"`

    - `const OperationKindSandboxVM OperationKind = "sandbox_vm"`

    - `const OperationKindBucket OperationKind = "bucket"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

    - `const OperationTypePause OperationType = "pause"`

    - `const OperationTypeResume OperationType = "resume"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.SandboxVMs.Resume(context.TODO(), "sandbox_vm_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", operation.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "details": {
    "changes": {
      "foo": {
        "from": "string",
        "to": "string"
      }
    }
  },
  "kind": "vm",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "resource_id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "pending",
  "type": "create",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Restart Agent Sandbox

`client.SandboxVMs.Restart(ctx, sandboxVMID) (*Operation, error)`

**post** `/v1/sandbox_vms/{sandbox_vm_id}/restart`

Restart an Agent Sandbox's VM. Its sandboxes keep their files and installed packages but not their running
processes or memory. A restart sent while another change runs waits for it.
A billing block returns 402.

### Parameters

- `sandboxVMID string`

### Returns

- `type Operation struct{…}`

  Operation details.

  - `ID string`

    Unique identifier for the Operation.

  - `CreatedAt Time`

    When the Operation was created.

  - `Details OperationDetails`

    Structured details about what an operation is changing.

    - `Changes OperationChanges`

      Map of changed field names to their from/to diffs. Keys depend on the parent operation's kind+type.

      - `From OperationFieldDiffFromUnion`

        Previous value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffFromArray []string`

      - `To OperationFieldDiffToUnion`

        New value.

        - `string`

        - `float64`

        - `bool`

        - `type OperationFieldDiffToArray []string`

  - `Kind OperationKind`

    Kind of Operation.

    - `const OperationKindVM OperationKind = "vm"`

    - `const OperationKindVolume OperationKind = "volume"`

    - `const OperationKindVPC OperationKind = "vpc"`

    - `const OperationKindFirewallRule OperationKind = "firewall_rule"`

    - `const OperationKindNKSCluster OperationKind = "nks_cluster"`

    - `const OperationKindNKSNodePool OperationKind = "nks_node_pool"`

    - `const OperationKindSandboxCluster OperationKind = "sandbox_cluster"`

    - `const OperationKindSandboxVM OperationKind = "sandbox_vm"`

    - `const OperationKindBucket OperationKind = "bucket"`

  - `ProjectID string`

    Project ID the Operation belongs to.

  - `ResourceID string`

    ID of the resource that the Operation is acting on.

  - `Status OperationStatus`

    Status of the Operation.

    - `const OperationStatusPending OperationStatus = "pending"`

    - `const OperationStatusRunning OperationStatus = "running"`

    - `const OperationStatusDone OperationStatus = "done"`

    - `const OperationStatusFailed OperationStatus = "failed"`

    - `const OperationStatusUnknown OperationStatus = "unknown"`

  - `Type OperationType`

    Type of Operation.

    - `const OperationTypeCreate OperationType = "create"`

    - `const OperationTypeUpdate OperationType = "update"`

    - `const OperationTypeDelete OperationType = "delete"`

    - `const OperationTypeRestart OperationType = "restart"`

    - `const OperationTypePause OperationType = "pause"`

    - `const OperationTypeResume OperationType = "resume"`

  - `UpdatedAt Time`

    When the Operation was updated.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  operation, err := client.SandboxVMs.Restart(context.TODO(), "sandbox_vm_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", operation.ID)
}
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "details": {
    "changes": {
      "foo": {
        "from": "string",
        "to": "string"
      }
    }
  },
  "kind": "vm",
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "resource_id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "pending",
  "type": "create",
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Domain Types

### Sandbox VM

- `type SandboxVM struct{…}`

  An Agent Sandbox: a VM sandboxes run on, in one region. It can be paused and resumed.

  - `ID string`

    Unique identifier for the Agent Sandbox.

  - `CreatedAt Time`

    When the Agent Sandbox was created.

  - `EndpointHostname string`

    Hostname the Agent Sandbox's sandbox API is served on over HTTPS. It stays the same for the life of the Agent Sandbox. Null until assigned.

  - `ImageVersion string`

    Version of the image the Agent Sandbox runs. Null until it is running.

  - `InstanceType string`

    Instance type of the Agent Sandbox.

  - `Name string`

    Name of the Agent Sandbox.

  - `OpensandboxVersion string`

    Version of OpenSandbox the Agent Sandbox runs. Null until it is running.

  - `PausedAt Time`

    When the Agent Sandbox was paused. Null while it is running.

  - `PowerState SandboxVMPowerState`

    Whether the Agent Sandbox's sandboxes can run.

    - `const SandboxVMPowerStateRunning SandboxVMPowerState = "running"`

    - `const SandboxVMPowerStatePaused SandboxVMPowerState = "paused"`

    - `const SandboxVMPowerStatePoweredOff SandboxVMPowerState = "powered_off"`

  - `PowersOffAt Time`

    When the paused Agent Sandbox is, or was, powered off. Null while it is running.

  - `ProjectID string`

    ID of the project the Agent Sandbox is in.

  - `Region RegionName`

    Region the resource is in.

    - `const RegionNameUsSva2 RegionName = "us-sva-2"`

    - `const RegionNameUsWdc1 RegionName = "us-wdc-1"`

  - `Status ResourceStatus`

    Status of the resource.

    - `const ResourceStatusPending ResourceStatus = "pending"`

    - `const ResourceStatusCreating ResourceStatus = "creating"`

    - `const ResourceStatusUpdating ResourceStatus = "updating"`

    - `const ResourceStatusReady ResourceStatus = "ready"`

    - `const ResourceStatusDeleting ResourceStatus = "deleting"`

    - `const ResourceStatusDeleted ResourceStatus = "deleted"`

    - `const ResourceStatusError ResourceStatus = "error"`

    - `const ResourceStatusSuspended ResourceStatus = "suspended"`

  - `Tags []string`

    Tags attached to the Agent Sandbox.

  - `UpdatedAt Time`

    When the Agent Sandbox was last updated.

  - `VPCID string`

    ID of the VPC the Agent Sandbox is in. Null until it is placed in one.

### Sandbox VM List

- `type SandboxVMList struct{…}`

  - `Items []SandboxVM`

    - `ID string`

      Unique identifier for the Agent Sandbox.

    - `CreatedAt Time`

      When the Agent Sandbox was created.

    - `EndpointHostname string`

      Hostname the Agent Sandbox's sandbox API is served on over HTTPS. It stays the same for the life of the Agent Sandbox. Null until assigned.

    - `ImageVersion string`

      Version of the image the Agent Sandbox runs. Null until it is running.

    - `InstanceType string`

      Instance type of the Agent Sandbox.

    - `Name string`

      Name of the Agent Sandbox.

    - `OpensandboxVersion string`

      Version of OpenSandbox the Agent Sandbox runs. Null until it is running.

    - `PausedAt Time`

      When the Agent Sandbox was paused. Null while it is running.

    - `PowerState SandboxVMPowerState`

      Whether the Agent Sandbox's sandboxes can run.

      - `const SandboxVMPowerStateRunning SandboxVMPowerState = "running"`

      - `const SandboxVMPowerStatePaused SandboxVMPowerState = "paused"`

      - `const SandboxVMPowerStatePoweredOff SandboxVMPowerState = "powered_off"`

    - `PowersOffAt Time`

      When the paused Agent Sandbox is, or was, powered off. Null while it is running.

    - `ProjectID string`

      ID of the project the Agent Sandbox is in.

    - `Region RegionName`

      Region the resource is in.

      - `const RegionNameUsSva2 RegionName = "us-sva-2"`

      - `const RegionNameUsWdc1 RegionName = "us-wdc-1"`

    - `Status ResourceStatus`

      Status of the resource.

      - `const ResourceStatusPending ResourceStatus = "pending"`

      - `const ResourceStatusCreating ResourceStatus = "creating"`

      - `const ResourceStatusUpdating ResourceStatus = "updating"`

      - `const ResourceStatusReady ResourceStatus = "ready"`

      - `const ResourceStatusDeleting ResourceStatus = "deleting"`

      - `const ResourceStatusDeleted ResourceStatus = "deleted"`

      - `const ResourceStatusError ResourceStatus = "error"`

      - `const ResourceStatusSuspended ResourceStatus = "suspended"`

    - `Tags []string`

      Tags attached to the Agent Sandbox.

    - `UpdatedAt Time`

      When the Agent Sandbox was last updated.

    - `VPCID string`

      ID of the VPC the Agent Sandbox is in. Null until it is placed in one.

  - `Pagination Pagination`

    Pagination response details.

    - `NextCursor string`

    - `PreviousCursor string`

    - `TotalCount int64`

# Cost

## Estimate Agent Sandbox Create Cost

`client.SandboxVMs.Cost.New(ctx, body) (*CostQuote, error)`

**post** `/v1/sandbox_vms/cost`

Return a priced cost quote for the proposed Agent Sandbox while it runs. A paused or powered-off Agent Sandbox is billed for its disk only.

### Parameters

- `body CostNewParams`

  - `Name param.Field[string]`

    Name of the Agent Sandbox. Unique within its project.

  - `ProjectID param.Field[string]`

    ID of the project to create the Agent Sandbox in.

  - `Region param.Field[RegionName]`

    Region the resource is in.

  - `InstanceType param.Field[string]`

    Instance type of the Agent Sandbox. Defaults to n1-highcpu-2 (2 vCPU, 4 GiB), the only size available.

  - `Tags param.Field[[]string]`

    Tags to attach to the Agent Sandbox.

  - `VPCID param.Field[string]`

    ID of the VPC to place the Agent Sandbox in. It must be a ready VPC in the Agent Sandbox's project and region.
    Omit it to use the project's oldest ready VPC in the region, or a new VPC when there is none.

### Returns

- `type CostQuote struct{…}`

  Cost quote returned by POST /cost. current_summary and updated_summary hold the org billing summary now and with this resource; omitted when the caller cannot view billing.

  - `Currency string`

    Currency the quote is denominated in. Always "USD" in v1.

  - `MonthlyTotal string`

    Arbitrary-precision decimal serialized as a string (e.g. "58.40").

  - `PricedAt Time`

    Timestamp the quote was priced at.

  - `UsageDimensions []CostQuoteUsageDimension`

    Priced rows, one per usage dimension emitted by the resource.

    - `Dimension string`

      Usage dimension being priced (e.g. compute_vcpu, storage_abs_gb).

    - `DimensionDisplayName string`

      User-facing label for the dimension (e.g. "vCPU (hours)").

    - `MonthlyAmount string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `Quantity int64`

      Quantity of the dimension being priced.

    - `UnitPrice string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

  - `CurrentSummary OrganizationBillingSummary`

    Forward-looking billing summary for an organization. All costs are run-rate projections from the organization's current active usage ("≈ $X/mo at current usage").

    - `DailyCost string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `EffectiveBalance string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `MonthlyCost string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `PromotionalCredits []OrganizationBillingSummaryPromotionalCredit`

      Credits the organization earns automatically through the startup credits program, one per step. Empty when the organization is not part of the program.

      - `Amount string`

        Arbitrary-precision decimal serialized as a string (e.g. "58.40").

      - `Kind string`

        Step that earns the credit: creating the organization, or saving a payment method on it.

        - `const OrganizationBillingSummaryPromotionalCreditKindOrganizationCreated OrganizationBillingSummaryPromotionalCreditKind = "organization_created"`

        - `const OrganizationBillingSummaryPromotionalCreditKindPaymentMethodAdded OrganizationBillingSummaryPromotionalCreditKind = "payment_method_added"`

      - `Status string`

        Whether the credit can still be earned ("available"), was earned and is being issued ("pending"), or was issued ("granted"). A granted credit reaches the balance shortly after it is issued.

        - `const OrganizationBillingSummaryPromotionalCreditStatusAvailable OrganizationBillingSummaryPromotionalCreditStatus = "available"`

        - `const OrganizationBillingSummaryPromotionalCreditStatusPending OrganizationBillingSummaryPromotionalCreditStatus = "pending"`

        - `const OrganizationBillingSummaryPromotionalCreditStatusGranted OrganizationBillingSummaryPromotionalCreditStatus = "granted"`

    - `RechargeThresholdDays string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

    - `EstimatedNextChargeAt Time`

      Projected date the balance reaches the recharge threshold at the current run-rate. Null when there is no active usage (never charges).

    - `RunwayMonths string`

      Arbitrary-precision decimal serialized as a string (e.g. "58.40").

  - `UpdatedSummary OrganizationBillingSummary`

    Forward-looking billing summary for an organization. All costs are run-rate projections from the organization's current active usage ("≈ $X/mo at current usage").

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/sandbox_vms"
  "github.com/nirvana-labs/nirvana-go/shared"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  costQuote, err := client.SandboxVMs.Cost.New(context.TODO(), sandbox_vms.CostNewParams{
    Name: "my-sandboxes",
    ProjectID: "123e4567-e89b-12d3-a456-426614174000",
    Region: shared.RegionNameUsSva2,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", costQuote.Currency)
}
```

#### Response

```json
{
  "currency": "USD",
  "monthly_total": "-69125",
  "priced_at": "2025-01-01T00:00:00Z",
  "usage_dimensions": [
    {
      "dimension": "compute_vcpu",
      "dimension_display_name": "vCPU (hours)",
      "monthly_amount": "-69125",
      "quantity": 4,
      "unit_price": "-69125"
    }
  ],
  "current_summary": {
    "daily_cost": "-69125",
    "effective_balance": "-69125",
    "monthly_cost": "-69125",
    "promotional_credits": [
      {
        "amount": "-69125",
        "kind": "payment_method_added",
        "status": "available"
      }
    ],
    "recharge_threshold_days": "-69125",
    "estimated_next_charge_at": "2025-01-01T00:00:00Z",
    "runway_months": "-69125"
  },
  "updated_summary": {
    "daily_cost": "-69125",
    "effective_balance": "-69125",
    "monthly_cost": "-69125",
    "promotional_credits": [
      {
        "amount": "-69125",
        "kind": "payment_method_added",
        "status": "available"
      }
    ],
    "recharge_threshold_days": "-69125",
    "estimated_next_charge_at": "2025-01-01T00:00:00Z",
    "runway_months": "-69125"
  }
}
```
