# Sandbox Clusters

## Create Sandbox Cluster

`client.sandboxClusters.create(SandboxClusterCreateParamsbody, RequestOptionsoptions?): Operation`

**post** `/v1/sandbox_clusters`

Create a Sandbox Cluster to run sandboxes on. The infrastructure it runs on is provisioned in a project the platform manages.

### Parameters

- `body: SandboxClusterCreateParams`

  - `instance_type: string`

    Instance type of the nodes the sandboxes run on.

  - `name: string`

    Name of the Sandbox Cluster. Unique within its project.

  - `node_count: number`

    Number of nodes the sandboxes run on.

  - `project_id: string`

    ID of the project to create the Sandbox Cluster in.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `tags?: Array<string>`

    Tags to attach to the Sandbox Cluster.

### Returns

- `Operation`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: OperationDetails | null`

    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: string | number | boolean | Array<string>`

        Previous value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

      - `to: string | number | boolean | Array<string>`

        New value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

  - `kind: OperationKind`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

    - `"sandbox_cluster"`

    - `"bucket"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: OperationStatus`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: OperationType`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const operation = await client.sandboxClusters.create({
  instance_type: 'n1-standard-8',
  name: 'my-sandboxes',
  node_count: 3,
  project_id: '123e4567-e89b-12d3-a456-426614174000',
  region: 'us-sva-2',
});

console.log(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 Sandbox Cluster

`client.sandboxClusters.get(stringsandboxClusterID, RequestOptionsoptions?): SandboxCluster`

**get** `/v1/sandbox_clusters/{sandbox_cluster_id}`

Get a Sandbox Cluster

### Parameters

- `sandboxClusterID: string`

### Returns

- `SandboxCluster`

  A cluster sandboxes run on, in one region.

  - `id: string`

    Unique identifier for the Sandbox Cluster.

  - `created_at: string`

    When the Sandbox Cluster was created.

  - `gateway_hostname: string | null`

    Hostname sandboxes' endpoints are served on over HTTPS, to allow in outbound firewalls. Null until assigned; a recreated Sandbox Cluster gets a new one.

  - `instance_type: string`

    Instance type of the nodes the sandboxes run on.

  - `name: string`

    Name of the Sandbox Cluster.

  - `node_count: number`

    Number of nodes the sandboxes run on.

  - `project_id: string`

    ID of the project the Sandbox Cluster is in.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `status: ResourceStatus`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

    - `"suspended"`

  - `tags: Array<string>`

    Tags attached to the Sandbox Cluster.

  - `updated_at: string`

    When the Sandbox Cluster was last updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const sandboxCluster = await client.sandboxClusters.get('sandbox_cluster_id');

console.log(sandboxCluster.id);
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "gateway_hostname": "gw.0123456789ab.example.com",
  "instance_type": "n1-standard-8",
  "name": "my-sandboxes",
  "node_count": 3,
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "region": "us-sva-2",
  "status": "ready",
  "tags": [
    "production",
    "agents"
  ],
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Update Sandbox Cluster

`client.sandboxClusters.update(stringsandboxClusterID, SandboxClusterUpdateParamsbody, RequestOptionsoptions?): SandboxCluster`

**patch** `/v1/sandbox_clusters/{sandbox_cluster_id}`

Update a Sandbox Cluster's name and tags

### Parameters

- `sandboxClusterID: string`

- `body: SandboxClusterUpdateParams`

  - `name?: string`

    Name of the Sandbox Cluster. Unique within its project.

  - `tags?: Array<string>`

    Tags to attach to the Sandbox Cluster.

### Returns

- `SandboxCluster`

  A cluster sandboxes run on, in one region.

  - `id: string`

    Unique identifier for the Sandbox Cluster.

  - `created_at: string`

    When the Sandbox Cluster was created.

  - `gateway_hostname: string | null`

    Hostname sandboxes' endpoints are served on over HTTPS, to allow in outbound firewalls. Null until assigned; a recreated Sandbox Cluster gets a new one.

  - `instance_type: string`

    Instance type of the nodes the sandboxes run on.

  - `name: string`

    Name of the Sandbox Cluster.

  - `node_count: number`

    Number of nodes the sandboxes run on.

  - `project_id: string`

    ID of the project the Sandbox Cluster is in.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `status: ResourceStatus`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

    - `"suspended"`

  - `tags: Array<string>`

    Tags attached to the Sandbox Cluster.

  - `updated_at: string`

    When the Sandbox Cluster was last updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const sandboxCluster = await client.sandboxClusters.update('sandbox_cluster_id');

console.log(sandboxCluster.id);
```

#### Response

```json
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "created_at": "2025-01-01T00:00:00Z",
  "gateway_hostname": "gw.0123456789ab.example.com",
  "instance_type": "n1-standard-8",
  "name": "my-sandboxes",
  "node_count": 3,
  "project_id": "123e4567-e89b-12d3-a456-426614174000",
  "region": "us-sva-2",
  "status": "ready",
  "tags": [
    "production",
    "agents"
  ],
  "updated_at": "2025-01-01T00:00:00Z"
}
```

## Delete Sandbox Cluster

`client.sandboxClusters.delete(stringsandboxClusterID, RequestOptionsoptions?): Operation`

**delete** `/v1/sandbox_clusters/{sandbox_cluster_id}`

Delete a Sandbox Cluster, with its sandboxes and the infrastructure they run on.

### Parameters

- `sandboxClusterID: string`

### Returns

- `Operation`

  Operation details.

  - `id: string`

    Unique identifier for the Operation.

  - `created_at: string`

    When the Operation was created.

  - `details: OperationDetails | null`

    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: string | number | boolean | Array<string>`

        Previous value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

      - `to: string | number | boolean | Array<string>`

        New value.

        - `string`

        - `number`

        - `boolean`

        - `Array<string>`

  - `kind: OperationKind`

    Kind of Operation.

    - `"vm"`

    - `"volume"`

    - `"vpc"`

    - `"firewall_rule"`

    - `"nks_cluster"`

    - `"nks_node_pool"`

    - `"sandbox_cluster"`

    - `"bucket"`

  - `project_id: string`

    Project ID the Operation belongs to.

  - `resource_id: string`

    ID of the resource that the Operation is acting on.

  - `status: OperationStatus`

    Status of the Operation.

    - `"pending"`

    - `"running"`

    - `"done"`

    - `"failed"`

    - `"unknown"`

  - `type: OperationType`

    Type of Operation.

    - `"create"`

    - `"update"`

    - `"delete"`

    - `"restart"`

  - `updated_at: string`

    When the Operation was updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const operation = await client.sandboxClusters.delete('sandbox_cluster_id');

console.log(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 Sandbox Clusters

`client.sandboxClusters.list(SandboxClusterListParamsquery, RequestOptionsoptions?): Cursor<SandboxCluster>`

**get** `/v1/sandbox_clusters`

List the Sandbox Clusters in a project

### Parameters

- `query: SandboxClusterListParams`

  - `project_id: string`

    Project ID of resources to request

  - `cursor?: string`

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

  - `limit?: number`

    Maximum number of items to return

  - `name?: string`

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

  - `region?: string`

    Filter by region

  - `sort?: string`

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

  - `tags?: Array<string>`

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

### Returns

- `SandboxCluster`

  A cluster sandboxes run on, in one region.

  - `id: string`

    Unique identifier for the Sandbox Cluster.

  - `created_at: string`

    When the Sandbox Cluster was created.

  - `gateway_hostname: string | null`

    Hostname sandboxes' endpoints are served on over HTTPS, to allow in outbound firewalls. Null until assigned; a recreated Sandbox Cluster gets a new one.

  - `instance_type: string`

    Instance type of the nodes the sandboxes run on.

  - `name: string`

    Name of the Sandbox Cluster.

  - `node_count: number`

    Number of nodes the sandboxes run on.

  - `project_id: string`

    ID of the project the Sandbox Cluster is in.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `status: ResourceStatus`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

    - `"suspended"`

  - `tags: Array<string>`

    Tags attached to the Sandbox Cluster.

  - `updated_at: string`

    When the Sandbox Cluster was last updated.

### Example

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const sandboxCluster of client.sandboxClusters.list({ project_id: 'project_id' })) {
  console.log(sandboxCluster.id);
}
```

#### Response

```json
{
  "items": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "created_at": "2025-01-01T00:00:00Z",
      "gateway_hostname": "gw.0123456789ab.example.com",
      "instance_type": "n1-standard-8",
      "name": "my-sandboxes",
      "node_count": 3,
      "project_id": "123e4567-e89b-12d3-a456-426614174000",
      "region": "us-sva-2",
      "status": "ready",
      "tags": [
        "production",
        "agents"
      ],
      "updated_at": "2025-01-01T00:00:00Z"
    }
  ],
  "pagination": {
    "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
    "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
    "total_count": 125
  }
}
```

## Domain Types

### Sandbox Cluster

- `SandboxCluster`

  A cluster sandboxes run on, in one region.

  - `id: string`

    Unique identifier for the Sandbox Cluster.

  - `created_at: string`

    When the Sandbox Cluster was created.

  - `gateway_hostname: string | null`

    Hostname sandboxes' endpoints are served on over HTTPS, to allow in outbound firewalls. Null until assigned; a recreated Sandbox Cluster gets a new one.

  - `instance_type: string`

    Instance type of the nodes the sandboxes run on.

  - `name: string`

    Name of the Sandbox Cluster.

  - `node_count: number`

    Number of nodes the sandboxes run on.

  - `project_id: string`

    ID of the project the Sandbox Cluster is in.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `status: ResourceStatus`

    Status of the resource.

    - `"pending"`

    - `"creating"`

    - `"updating"`

    - `"ready"`

    - `"deleting"`

    - `"deleted"`

    - `"error"`

    - `"suspended"`

  - `tags: Array<string>`

    Tags attached to the Sandbox Cluster.

  - `updated_at: string`

    When the Sandbox Cluster was last updated.

### Sandbox Cluster List

- `SandboxClusterList`

  - `items: Array<SandboxCluster>`

    - `id: string`

      Unique identifier for the Sandbox Cluster.

    - `created_at: string`

      When the Sandbox Cluster was created.

    - `gateway_hostname: string | null`

      Hostname sandboxes' endpoints are served on over HTTPS, to allow in outbound firewalls. Null until assigned; a recreated Sandbox Cluster gets a new one.

    - `instance_type: string`

      Instance type of the nodes the sandboxes run on.

    - `name: string`

      Name of the Sandbox Cluster.

    - `node_count: number`

      Number of nodes the sandboxes run on.

    - `project_id: string`

      ID of the project the Sandbox Cluster is in.

    - `region: RegionName`

      Region the resource is in.

      - `"us-sva-2"`

      - `"us-wdc-1"`

    - `status: ResourceStatus`

      Status of the resource.

      - `"pending"`

      - `"creating"`

      - `"updating"`

      - `"ready"`

      - `"deleting"`

      - `"deleted"`

      - `"error"`

      - `"suspended"`

    - `tags: Array<string>`

      Tags attached to the Sandbox Cluster.

    - `updated_at: string`

      When the Sandbox Cluster was last updated.

  - `pagination: Pagination`

    Pagination response details.

    - `next_cursor: string | null`

    - `previous_cursor: string | null`

    - `total_count: number`

# Cost

## Estimate Sandbox Cluster Create Cost

`client.sandboxClusters.cost.create(CostCreateParamsbody, RequestOptionsoptions?): CostQuote`

**post** `/v1/sandbox_clusters/cost`

Return a priced cost quote for the proposed Sandbox Cluster.

### Parameters

- `body: CostCreateParams`

  - `instance_type: string`

    Instance type of the nodes the sandboxes run on.

  - `name: string`

    Name of the Sandbox Cluster. Unique within its project.

  - `node_count: number`

    Number of nodes the sandboxes run on.

  - `project_id: string`

    ID of the project to create the Sandbox Cluster in.

  - `region: RegionName`

    Region the resource is in.

    - `"us-sva-2"`

    - `"us-wdc-1"`

  - `tags?: Array<string>`

    Tags to attach to the Sandbox Cluster.

### Returns

- `CostQuote`

  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.

  - `monthly_total: string`

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

  - `priced_at: string`

    Timestamp the quote was priced at.

  - `usage_dimensions: Array<UsageDimension>`

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

    - `dimension: string`

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

    - `dimension_display_name: string`

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

    - `monthly_amount: string`

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

    - `quantity: number`

      Quantity of the dimension being priced.

    - `unit_price: string`

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

  - `current_summary?: 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").

    - `daily_cost: string`

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

    - `effective_balance: string`

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

    - `monthly_cost: string`

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

    - `recharge_threshold_days: string`

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

    - `estimated_next_charge_at?: string | null`

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

    - `runway_months?: string | null`

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

  - `updated_summary?: 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

```typescript
import NirvanaLabs from '@nirvana-labs/nirvana';

const client = new NirvanaLabs({
  apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});

const costQuote = await client.sandboxClusters.cost.create({
  instance_type: 'n1-standard-8',
  name: 'my-sandboxes',
  node_count: 3,
  project_id: '123e4567-e89b-12d3-a456-426614174000',
  region: 'us-sva-2',
});

console.log(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",
    "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",
    "recharge_threshold_days": "-69125",
    "estimated_next_charge_at": "2025-01-01T00:00:00Z",
    "runway_months": "-69125"
  }
}
```
