> ## Documentation Index
> Fetch the complete documentation index at: https://namespace.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Inspect and release volumes

> List, describe, and destroy cache volumes, persistent volumes, and snapshots with the TypeScript SDK.

`client.storage` covers the two volume types Namespace attaches to instances. [Cache volumes](/docs/architecture/storage/cache-volumes) are identified by a tag and reused across runs, with one generation per use. Persistent volumes are block volumes with their own identity and snapshots.

The examples on this page use a Compute client:

```typescript theme={null}
import { createComputeClient } from "@namespacelabs/sdk/api/compute";

const client = createComputeClient();
```

## `storage.listCacheVolumes()`

Return every cache volume in the workspace.

<h3 id="storage-listcachevolumes-example">
  Example
</h3>

```typescript {1} theme={null}
const { cacheVolume } = await client.storage.listCacheVolumes({});

for (const volume of cacheVolume) {
  console.log(volume.id, volume.tag, volume.metadata?.sizeMb);
}
```

<h3 id="storage-listcachevolumes-api-reference">
  API reference
</h3>

```typescript theme={null}
listCacheVolumes(
  request: MessageInitShape<typeof ListCacheVolumesRequestSchema>,
  options?: CallOptions,
): Promise<ListCacheVolumesResponse>
```

<h4 id="storage-listcachevolumes-arguments-and-options">
  Arguments and options
</h4>

The request has no fields. Pass an empty object.

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-listcachevolumes-return-value">
  Return value
</h4>

Returns a `ListCacheVolumesResponse` with `cacheVolume`, a list of `CacheVolume`. Each entry carries `id`, `tag`, `metadata` with the lifecycle timestamps, size, and state, and `attachment` with the instance the volume was attached to and its utilization.

***

## `storage.getCacheVolume()`

Return a single cache volume generation by ID.

<h3 id="storage-getcachevolume-example">
  Example
</h3>

```typescript {1} theme={null}
const { cacheVolume } = await client.storage.getCacheVolume({ id: volumeId });

console.log(cacheVolume?.metadata?.state);
```

<h3 id="storage-getcachevolume-api-reference">
  API reference
</h3>

```typescript theme={null}
getCacheVolume(
  request: MessageInitShape<typeof GetCacheVolumeRequestSchema>,
  options?: CallOptions,
): Promise<GetCacheVolumeResponse>
```

<h4 id="storage-getcachevolume-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="id" type="string" required>
  The unique identifier of the cache volume generation. A single tag can have multiple generations over time.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-getcachevolume-return-value">
  Return value
</h4>

Returns a `GetCacheVolumeResponse` with the matching `cacheVolume`.

***

## `storage.listVolumeTagSummaries()`

Summarize every cache volume tag in the workspace. Use this to see cache usage per tag rather than per generation.

<h3 id="storage-listvolumetagsummaries-example">
  Example
</h3>

```typescript {1} theme={null}
const { summaries } = await client.storage.listVolumeTagSummaries({});

for (const summary of summaries) {
  console.log(summary.tag, summary.sizeMb, summary.generations.length);
}
```

<h3 id="storage-listvolumetagsummaries-api-reference">
  API reference
</h3>

```typescript theme={null}
listVolumeTagSummaries(
  request: MessageInitShape<typeof ListVolumeTagSummariesRequestSchema>,
  options?: CallOptions,
): Promise<ListVolumeTagSummariesResponse>
```

<h4 id="storage-listvolumetagsummaries-arguments-and-options">
  Arguments and options
</h4>

The request has no fields. Pass an empty object.

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-listvolumetagsummaries-return-value">
  Return value
</h4>

Returns a `ListVolumeTagSummariesResponse` with `summaries`, a list of `TagSummary`. Each summary carries the `tag`, its requested `sizeMb`, and the `generations` that belong to it.

***

## `storage.getVolumeTagSummary()`

Summarize a single cache volume tag.

<h3 id="storage-getvolumetagsummary-example">
  Example
</h3>

```typescript {1} theme={null}
const { summary } = await client.storage.getVolumeTagSummary({ tag: "node-modules" });

console.log(summary?.sizeMb);
```

<h3 id="storage-getvolumetagsummary-api-reference">
  API reference
</h3>

```typescript theme={null}
getVolumeTagSummary(
  request: MessageInitShape<typeof GetVolumeTagSummaryRequestSchema>,
  options?: CallOptions,
): Promise<GetVolumeTagSummaryResponse>
```

<h4 id="storage-getvolumetagsummary-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="tag" type="string" required>
  The name of the cache volume tag.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-getvolumetagsummary-return-value">
  Return value
</h4>

Returns a `GetVolumeTagSummaryResponse` with the matching `TagSummary`.

***

## `storage.destroyCacheVolume()`

Release all cache volumes that belong to a tag.

<h3 id="storage-destroycachevolume-example">
  Example
</h3>

```typescript {1} theme={null}
await client.storage.destroyCacheVolume({ tag: "node-modules" });
```

<h3 id="storage-destroycachevolume-api-reference">
  API reference
</h3>

```typescript theme={null}
destroyCacheVolume(
  request: MessageInitShape<typeof DestroyCacheVolumeRequestSchema>,
  options?: CallOptions,
): Promise<Empty>
```

<h4 id="storage-destroycachevolume-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="tag" type="string" required>
  The cache volume tag to release.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-destroycachevolume-return-value">
  Return value
</h4>

Returns an empty response. Omitting the tag fails with `InvalidArgument`, and an unknown tag fails with `NotFound`.

<Warning>
  Releasing a cache volume cannot be undone. The next run that uses the tag starts from an empty cache.
</Warning>

***

## `storage.listPersistentVolumes()`

Return one page of persistent volumes, optionally filtered by tag and site.

<h3 id="storage-listpersistentvolumes-example">
  Example
</h3>

```typescript {1-4} theme={null}
const page = await client.storage.listPersistentVolumes({
  tag: "workspace-data",
  maxEntries: 50n,
});

for (const volume of page.volumes) {
  console.log(volume.id, volume.site, volume.attachedTo);
}
```

<h3 id="storage-listpersistentvolumes-api-reference">
  API reference
</h3>

```typescript theme={null}
listPersistentVolumes(
  request: MessageInitShape<typeof ListPersistentVolumesRequestSchema>,
  options?: CallOptions,
): Promise<ListPersistentVolumesResponse>
```

<h4 id="storage-listpersistentvolumes-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="tag" type="string">
  Only return volumes with this tag. When omitted, all persistent volumes are returned.
</ResponseField>

<ResponseField name="site" type="StringMatcher">
  Only query the matching sites. When omitted, all sites are queried.
</ResponseField>

<ResponseField name="maxEntries" type="bigint">
  The maximum number of entries to return. The service may return fewer.
</ResponseField>

<ResponseField name="paginationCursor" type="Uint8Array">
  The `paginationCursor` from a previous response, to continue reading results.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-listpersistentvolumes-return-value">
  Return value
</h4>

Returns a `ListPersistentVolumesResponse` with `volumes` and a `paginationCursor`. A set cursor means more results are available. Each `PersistentVolume` carries `id`, `tag`, `sizeMb`, `site`, `createdAt`, `attachedTo`, and the release and destruction timestamps.

***

## `storage.describePersistentVolume()`

Return details of a single persistent volume.

<h3 id="storage-describepersistentvolume-example">
  Example
</h3>

```typescript {1-4} theme={null}
const { volume } = await client.storage.describePersistentVolume({
  id: volumeId,
  tag: "workspace-data",
});

console.log(volume?.sizeMb, volume?.attachedTo);
```

<h3 id="storage-describepersistentvolume-api-reference">
  API reference
</h3>

```typescript theme={null}
describePersistentVolume(
  request: MessageInitShape<typeof DescribePersistentVolumeRequestSchema>,
  options?: CallOptions,
): Promise<DescribePersistentVolumeResponse>
```

<h4 id="storage-describepersistentvolume-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="id" type="string" required>
  The unique identifier of the persistent volume.
</ResponseField>

<ResponseField name="tag" type="string" required>
  The tag of the persistent volume.
</ResponseField>

<ResponseField name="site" type="string">
  The site the volume is located in. When provided, only that site is queried.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-describepersistentvolume-return-value">
  Return value
</h4>

Returns a `DescribePersistentVolumeResponse` with the matching `volume`. If the volume does not exist, the call fails with `NotFound`.

***

## `storage.destroyPersistentVolumes()`

Destroy every persistent volume that matches the given criteria.

<h3 id="storage-destroypersistentvolumes-example">
  Example
</h3>

```typescript {1,4-6} theme={null}
import { StringMatcher_Operator } from "@namespacelabs/sdk/proto/namespace/stdlib/matchers_pb";

const { destroyedVolumes } = await client.storage.destroyPersistentVolumes({
  tag: {
    values: ["workspace-data"],
    op: StringMatcher_Operator.IS_ANY_OF,
  },
});

console.log(`destroyed ${destroyedVolumes.length} volumes`);
```

<h3 id="storage-destroypersistentvolumes-api-reference">
  API reference
</h3>

```typescript theme={null}
destroyPersistentVolumes(
  request: MessageInitShape<typeof DestroyPersistentVolumesRequestSchema>,
  options?: CallOptions,
): Promise<DestroyPersistentVolumesResponse>
```

<h4 id="storage-destroypersistentvolumes-arguments-and-options">
  Arguments and options
</h4>

At least one of `id` or `tag` must be set. For safety the service rejects the `IS_NOT` operator.

<ResponseField name="id" type="StringMatcher">
  Matches volumes by ID.
</ResponseField>

<ResponseField name="tag" type="StringMatcher">
  Matches volumes by tag.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-destroypersistentvolumes-return-value">
  Return value
</h4>

Returns a `DestroyPersistentVolumesResponse` with `destroyedVolumes`, the metadata of the volumes that were destroyed.

Omitting both matchers or using `IS_NOT` fails with `InvalidArgument`. When no volume matches, the call fails with `NotFound`.

***

## `storage.listPersistentVolumeSnapshots()`

Return every snapshot of a persistent volume.

<h3 id="storage-listpersistentvolumesnapshots-example">
  Example
</h3>

```typescript {1-4} theme={null}
const { snapshots } = await client.storage.listPersistentVolumeSnapshots({
  id: volumeId,
  tag: "workspace-data",
});

for (const snapshot of snapshots) {
  console.log(snapshot.id, snapshot.usedBytes, snapshot.abandonedAt);
}
```

<h3 id="storage-listpersistentvolumesnapshots-api-reference">
  API reference
</h3>

```typescript theme={null}
listPersistentVolumeSnapshots(
  request: MessageInitShape<typeof ListPersistentVolumeSnapshotsRequestSchema>,
  options?: CallOptions,
): Promise<ListPersistentVolumeSnapshotsResponse>
```

<h4 id="storage-listpersistentvolumesnapshots-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="id" type="string" required>
  The unique identifier of the persistent volume.
</ResponseField>

<ResponseField name="tag" type="string" required>
  The tag of the persistent volume.
</ResponseField>

<ResponseField name="site" type="string">
  The site the volume is located in. When provided, only that site is queried.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-listpersistentvolumesnapshots-return-value">
  Return value
</h4>

Returns a `ListPersistentVolumeSnapshotsResponse` with `snapshots`. Each `PersistentVolumeSnapshot` carries `id`, `createdAt`, `usedBytes`, `netNewUsedBytes`, the parent in `snapshotFrom`, and the attachment and release state.

***

## `storage.destroyPersistentVolumeSnapshot()`

Mark a snapshot as abandoned. Abandoned snapshots are excluded when Namespace selects a base snapshot for new volumes, which is useful for skipping a corrupted snapshot without destroying the volume.

<h3 id="storage-destroypersistentvolumesnapshot-example">
  Example
</h3>

```typescript {1-4} theme={null}
const { snapshot } = await client.storage.destroyPersistentVolumeSnapshot({
  id: volumeId,
  tag: "workspace-data",
});

console.log(snapshot?.abandonedAt);
```

<h3 id="storage-destroypersistentvolumesnapshot-api-reference">
  API reference
</h3>

```typescript theme={null}
destroyPersistentVolumeSnapshot(
  request: MessageInitShape<typeof DestroyPersistentVolumeSnapshotRequestSchema>,
  options?: CallOptions,
): Promise<DestroyPersistentVolumeSnapshotResponse>
```

<h4 id="storage-destroypersistentvolumesnapshot-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="id" type="string" required>
  The unique identifier of the snapshot, which is the volume ID.
</ResponseField>

<ResponseField name="tag" type="string" required>
  The tag of the persistent volume.
</ResponseField>

<ResponseField name="site" type="string">
  The site the volume is located in. When provided, only that site is queried.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="storage-destroypersistentvolumesnapshot-return-value">
  Return value
</h4>

Returns a `DestroyPersistentVolumeSnapshotResponse` with the abandoned `snapshot`.

If the snapshot does not exist, the call fails with `NotFound`. If it is still attached to an instance, the call fails with `FailedPrecondition`.

## Related documentation

<Columns cols={2}>
  <Card title="Storage platform" icon="database" href="/docs/architecture/storage">
    Cache volumes, artifact storage, and the container registry.
  </Card>

  <Card title="Volume usage" icon="chart-column" href="/docs/reference/typescript-sdk/compute/usage">
    Report on cache and persistent volume storage.
  </Card>
</Columns>
