> ## Documentation Index
> Fetch the complete documentation index at: https://e2b-automation-sdk-reference-sync.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Volume

### VolumeFileType

File type enum.

#### Enumeration Members

| Enumeration Member               | Value         |
| -------------------------------- | ------------- |
| <a id="directory" /> `DIRECTORY` | `"directory"` |
| <a id="file" /> `FILE`           | `"file"`      |
| <a id="symlink" /> `SYMLINK`     | `"symlink"`   |
| <a id="unknown" /> `UNKNOWN`     | `"unknown"`   |

## Classes

### Volume

Module for interacting with E2B volumes.

Create a `Volume` instance to interact with a volume by its ID,
or use the static methods to manage volumes.

#### Constructors

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
new Volume(
   volumeId: string, 
   name: string, 
   token: string, 
   domain?: string, 
   debug?: boolean, 
   proxy?: string): Volume
```

Create a local Volume instance with no API call.

###### Parameters

| Parameter  | Type      | Description                           |
| ---------- | --------- | ------------------------------------- |
| `volumeId` | `string`  | volume ID.                            |
| `name`     | `string`  | volume name.                          |
| `token`    | `string`  | volume auth token.                    |
| `domain`?  | `string`  | domain for the volume API.            |
| `debug`?   | `boolean` | whether to use debug mode.            |
| `proxy`?   | `string`  | proxy URL for the volume content API. |

###### Returns

`Volume`

#### Properties

| Property                       | Modifier   | Type      | Description                                                      |
| ------------------------------ | ---------- | --------- | ---------------------------------------------------------------- |
| <a id="debug" /> `debug?`      | `readonly` | `boolean` | Whether to use debug mode (connects to local volume API server). |
| <a id="domain" /> `domain?`    | `readonly` | `string`  | Domain used for constructing the volume API URL.                 |
| <a id="name" /> `name`         | `readonly` | `string`  | Volume name.                                                     |
| <a id="proxy" /> `proxy?`      | `readonly` | `string`  | Proxy URL used for requests to the volume content API.           |
| <a id="token" /> `token`       | `readonly` | `string`  | Volume auth token.                                               |
| <a id="volumeid" /> `volumeId` | `readonly` | `string`  | Volume ID.                                                       |

#### Methods

### exists()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
exists(path: string, opts?: VolumeApiOpts): Promise<boolean>
```

Check whether a file or directory exists.

Uses getInfo under the hood. Returns `true` if the path exists,
`false` if it does not (404). Other errors are rethrown.

###### Parameters

| Parameter | Type            | Description                    |
| --------- | --------------- | ------------------------------ |
| `path`    | `string`        | path to the file or directory. |
| `opts`?   | `VolumeApiOpts` | connection options.            |

###### Returns

`Promise`\<`boolean`>

`true` if the path exists, `false` otherwise.

### getInfo()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getInfo(path: string, opts?: VolumeApiOpts): Promise<VolumeEntryStat>
```

Get information about a file or directory.

###### Parameters

| Parameter | Type            | Description                    |
| --------- | --------------- | ------------------------------ |
| `path`    | `string`        | path to the file or directory. |
| `opts`?   | `VolumeApiOpts` | connection options.            |

###### Returns

`Promise`\<`VolumeEntryStat`>

information about the entry.

### list()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
list(path: string, opts?: VolumeApiOpts & object): Promise<VolumeEntryStat[]>
```

List directory contents.

###### Parameters

| Parameter | Type                       | Description            |
| --------- | -------------------------- | ---------------------- |
| `path`    | `string`                   | path to the directory. |
| `opts`?   | `VolumeApiOpts` & `object` | connection options.    |

###### Returns

`Promise`\<`VolumeEntryStat`\[]>

list of entries in the directory.

### makeDir()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
makeDir(path: string, opts?: VolumeMetadataOpts & object & VolumeApiOpts): Promise<VolumeEntryStat>
```

Create a directory.

###### Parameters

| Parameter | Type                                              | Description                      |
| --------- | ------------------------------------------------- | -------------------------------- |
| `path`    | `string`                                          | path to the directory to create. |
| `opts`?   | `VolumeMetadataOpts` & `object` & `VolumeApiOpts` | connection options.              |

###### Returns

`Promise`\<`VolumeEntryStat`>

### readFile()

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
readFile(path: string, opts?: VolumeApiOpts & object & object): Promise<string>
```

Read file content as a `string`.

You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.

###### Parameters

| Parameter | Type                                  | Description         |
| --------- | ------------------------------------- | ------------------- |
| `path`    | `string`                              | path to the file.   |
| `opts`?   | `VolumeApiOpts` & `object` & `object` | connection options. |

###### Returns

`Promise`\<`string`>

file content as string

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
readFile(path: string, opts?: VolumeApiOpts & object & object): Promise<Uint8Array<ArrayBufferLike>>
```

Read file content as a `Uint8Array`.

You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.

###### Parameters

| Parameter | Type                                  | Description         |
| --------- | ------------------------------------- | ------------------- |
| `path`    | `string`                              | path to the file.   |
| `opts`?   | `VolumeApiOpts` & `object` & `object` | connection options. |

###### Returns

`Promise`\<`Uint8Array`\<`ArrayBufferLike`>>

file content as `Uint8Array`

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
readFile(path: string, opts?: VolumeApiOpts & object & object): Promise<Blob>
```

Read file content as a `Blob`.

You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.

###### Parameters

| Parameter | Type                                  | Description         |
| --------- | ------------------------------------- | ------------------- |
| `path`    | `string`                              | path to the file.   |
| `opts`?   | `VolumeApiOpts` & `object` & `object` | connection options. |

###### Returns

`Promise`\<`Blob`>

file content as `Blob`

###### Call Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
readFile(path: string, opts?: VolumeApiOpts & object & object): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>
```

Read file content as a `ReadableStream`.

You can pass `text`, `bytes`, `blob`, or `stream` to `opts.format` to change the return type.

###### Parameters

| Parameter | Type                                  | Description         |
| --------- | ------------------------------------- | ------------------- |
| `path`    | `string`                              | path to the file.   |
| `opts`?   | `VolumeApiOpts` & `object` & `object` | connection options. |

###### Returns

`Promise`\<`ReadableStream`\<`Uint8Array`\<`ArrayBufferLike`>>>

file content as `ReadableStream`

### remove()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
remove(path: string, opts?: VolumeApiOpts): Promise<void>
```

Remove a file or directory.

###### Parameters

| Parameter | Type            | Description                              |
| --------- | --------------- | ---------------------------------------- |
| `path`    | `string`        | path to the file or directory to remove. |
| `opts`?   | `VolumeApiOpts` | connection options.                      |

###### Returns

`Promise`\<`void`>

### updateMetadata()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
updateMetadata(
   path: string, 
   metadata: VolumeMetadataOpts, 
opts?: VolumeApiOpts): Promise<VolumeEntryStat>
```

Update file or directory metadata.

###### Parameters

| Parameter  | Type                 | Description                          |
| ---------- | -------------------- | ------------------------------------ |
| `path`     | `string`             | path to the file or directory.       |
| `metadata` | `VolumeMetadataOpts` | metadata to update (uid, gid, mode). |
| `opts`?    | `VolumeApiOpts`      | connection options.                  |

###### Returns

`Promise`\<`VolumeEntryStat`>

updated entry information.

### writeFile()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
writeFile(
   path: string, 
   data: 
  | string
  | ArrayBuffer
  | Blob
  | ReadableStream<Uint8Array<ArrayBufferLike>>, 
opts?: VolumeMetadataOpts & object & VolumeApiOpts): Promise<VolumeEntryStat>
```

Write content to a file.

Writing to a file that doesn't exist creates the file.

Writing to a file that already exists overwrites the file.

###### Parameters

| Parameter | Type                                                                                          | Description                                                                                                                                                                                         |
| --------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `path`    | `string`                                                                                      | path to the file.                                                                                                                                                                                   |
| `data`    | \| `string` \| `ArrayBuffer` \| `Blob` \| `ReadableStream`\<`Uint8Array`\<`ArrayBufferLike`>> | data to write to the file. Data can be a string, `ArrayBuffer`, `Blob`, or `ReadableStream`. Outside the browser, `ReadableStream` data is streamed to the API instead of being buffered in memory. |
| `opts`?   | `VolumeMetadataOpts` & `object` & `VolumeApiOpts`                                             | connection options.                                                                                                                                                                                 |

###### Returns

`Promise`\<`VolumeEntryStat`>

information about the written file

### connect()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
static connect(volumeId: string, opts?: ConnectionOpts): Promise<Volume>
```

Connect to an existing volume by ID.

###### Parameters

| Parameter  | Type             | Description         |
| ---------- | ---------------- | ------------------- |
| `volumeId` | `string`         | volume ID.          |
| `opts`?    | `ConnectionOpts` | connection options. |

###### Returns

`Promise`\<`Volume`>

Volume instance.

### create()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
static create(name: string, opts?: ConnectionOpts): Promise<Volume>
```

Create a new volume.

###### Parameters

| Parameter | Type             | Description         |
| --------- | ---------------- | ------------------- |
| `name`    | `string`         | name of the volume. |
| `opts`?   | `ConnectionOpts` | connection options. |

###### Returns

`Promise`\<`Volume`>

new Volume instance.

### destroy()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
static destroy(volumeId: string, opts?: ConnectionOpts): Promise<boolean>
```

Destroy a volume.

###### Parameters

| Parameter  | Type             | Description         |
| ---------- | ---------------- | ------------------- |
| `volumeId` | `string`         | volume ID.          |
| `opts`?    | `ConnectionOpts` | connection options. |

###### Returns

`Promise`\<`boolean`>

### getInfo()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
static getInfo(volumeId: string, opts?: ConnectionOpts): Promise<VolumeAndToken>
```

Get volume information.

###### Parameters

| Parameter  | Type             | Description         |
| ---------- | ---------------- | ------------------- |
| `volumeId` | `string`         | volume ID.          |
| `opts`?    | `ConnectionOpts` | connection options. |

###### Returns

`Promise`\<`VolumeAndToken`>

volume information.

### list()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
static list(opts?: ConnectionOpts): Promise<VolumeInfo[]>
```

List all volumes.

###### Parameters

| Parameter | Type             | Description         |
| --------- | ---------------- | ------------------- |
| `opts`?   | `ConnectionOpts` | connection options. |

###### Returns

`Promise`\<`VolumeInfo`\[]>

list of volume information.

***

### VolumeConnectionConfig

#### Constructors

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
new VolumeConnectionConfig(volume: Volume, opts?: VolumeApiOpts): VolumeConnectionConfig
```

###### Parameters

| Parameter | Type            |
| --------- | --------------- |
| `volume`  | `Volume`        |
| `opts`?   | `VolumeApiOpts` |

###### Returns

`VolumeConnectionConfig`

#### Properties

| Property                                       | Modifier   | Type                          |
| ---------------------------------------------- | ---------- | ----------------------------- |
| <a id="apiurl" /> `apiUrl`                     | `readonly` | `string`                      |
| <a id="debug-1" /> `debug`                     | `readonly` | `boolean`                     |
| <a id="domain-1" /> `domain`                   | `readonly` | `string`                      |
| <a id="headers" /> `headers?`                  | `readonly` | `Record`\<`string`, `string`> |
| <a id="logger" /> `logger?`                    | `readonly` | `Logger`                      |
| <a id="proxy-1" /> `proxy?`                    | `readonly` | `string`                      |
| <a id="requesttimeoutms" /> `requestTimeoutMs` | `readonly` | `number`                      |
| <a id="signal" /> `signal?`                    | `readonly` | `AbortSignal`                 |
| <a id="token-1" /> `token?`                    | `readonly` | `string`                      |

#### Methods

### getSignal()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
getSignal(requestTimeoutMs?: number, signal?: AbortSignal): undefined | AbortSignal
```

###### Parameters

| Parameter           | Type          |
| ------------------- | ------------- |
| `requestTimeoutMs`? | `number`      |
| `signal`?           | `AbortSignal` |

###### Returns

`undefined` | `AbortSignal`

## Interfaces

### VolumeApiOpts

#### Properties

### domain?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional domain: string;
```

Domain to use for the volume API.

###### Default

E2B\_DOMAIN // environment variable or `e2b.app`

### headers?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional headers: Record<string, string>;
```

Additional headers to send with the request.

### logger?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional logger: Logger;
```

Logger to use for logging messages. It can accept any object that implements `Logger` interface—for example, console.

### proxy?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional proxy: string;
```

Proxy URL to use for requests.

###### Example

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
'http://user:pass@127.0.0.1:8080'
```

### requestTimeoutMs?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional requestTimeoutMs: number;
```

Timeout for requests to the API in **milliseconds**.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
60_000 // 60 seconds
```

### signal?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional signal: AbortSignal;
```

An optional `AbortSignal` that can be used to cancel the in-flight request.
When the signal is aborted, the underlying `fetch` is aborted and the
returned promise rejects with an `AbortError`.

### token?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional token: string;
```

E2B API key to use for authentication.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
E2B_API_KEY // environment variable
```

## Type Aliases

### VolumeAndToken

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type VolumeAndToken = VolumeInfo & object;
```

Information about a volume and its auth token.

#### Type declaration

| Name    | Type     | Description        |
| ------- | -------- | ------------------ |
| `token` | `string` | Volume auth token. |

***

### VolumeEntryStat

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type VolumeEntryStat = Omit<VolumeApiComponents["schemas"]["VolumeEntryStat"], "atime" | "mtime" | "ctime" | "type"> & object;
```

Volume entry stat with dates converted to Date objects.

#### Type declaration

| Name    | Type             | Description                         |
| ------- | ---------------- | ----------------------------------- |
| `atime` | `Date`           | Access time as a Date object.       |
| `ctime` | `Date`           | Creation time as a Date object.     |
| `mtime` | `Date`           | Modification time as a Date object. |
| `type`  | `VolumeFileType` | File type.                          |

***

### VolumeInfo

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type VolumeInfo = object;
```

Information about a volume.

#### Type declaration

| Name                             | Type     | Description  |
| -------------------------------- | -------- | ------------ |
| <a id="name-1" /> `name`         | `string` | Volume name. |
| <a id="volumeid-1" /> `volumeId` | `string` | Volume ID.   |

***

### ~~VolumeMetadataOptions~~

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type VolumeMetadataOptions = VolumeMetadataOpts;
```

#### Deprecated

Use VolumeMetadataOpts instead.

***

### VolumeMetadataOpts

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type VolumeMetadataOpts = object;
```

Options for updating file metadata.

#### Type declaration

| Name                    | Type     | Description                        |
| ----------------------- | -------- | ---------------------------------- |
| <a id="gid" /> `gid`?   | `number` | Group ID of the file or directory. |
| <a id="mode" /> `mode`? | `number` | Mode of the file or directory.     |
| <a id="uid" /> `uid`?   | `number` | User ID of the file or directory.  |

***

### VolumeReadOpts

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type VolumeReadOpts = VolumeApiOpts & object;
```

Options for reading files from a volume.

#### Type declaration

| Name                   | Type     | Description                                                                                                                                                                                                                                                                                                                                                      |
| ---------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `streamIdleTimeoutMs`? | `number` | Idle timeout for a streamed read (`format: 'stream'`) in **milliseconds**: abort if no chunk arrives from the server within this window *while reading*. It bounds only the wire — a slow or paused consumer never trips it (a consumer that holds the stream but stops reading is reclaimed server-side). Defaults to the request timeout; pass `0` to disable. |

***

### ~~VolumeWriteOptions~~

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type VolumeWriteOptions = VolumeWriteOpts;
```

#### Deprecated

Use VolumeWriteOpts instead.

***

### VolumeWriteOpts

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type VolumeWriteOpts = VolumeMetadataOpts & object;
```

Options for file and directory operations.

#### Type declaration

| Name     | Type      | Description                                                                                                     |
| -------- | --------- | --------------------------------------------------------------------------------------------------------------- |
| `force`? | `boolean` | For makeDir: Create parent directories if they don't exist. For writeFile: Force overwrite of an existing file. |
