Documentation Index
Fetch the complete documentation index at: https://e2b-automation-sdk-reference-sync.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
VolumeFileType
File type enum.
Enumeration Members
| Enumeration Member | Value |
|---|
DIRECTORY | "directory" |
FILE | "file" |
SYMLINK | "symlink" |
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
new Volume(
volumeId: string,
name: string,
token: string,
domain?: string,
debug?: boolean): 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. |
Returns
Volume
Properties
| Property | Modifier | Type | Description |
|---|
debug? | readonly | boolean | Whether to use debug mode (connects to local volume API server). |
domain? | readonly | string | Domain used for constructing the volume API URL. |
name | readonly | string | Volume name. |
token | readonly | string | Volume auth token. |
volumeId | readonly | string | Volume ID. |
Methods
exists()
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()
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()
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()
makeDir(path: string, opts?: VolumeMetadataOptions & object & VolumeApiOpts): Promise<VolumeEntryStat>
Create a directory.
Parameters
| Parameter | Type | Description |
|---|
path | string | path to the directory to create. |
opts? | VolumeMetadataOptions & object & VolumeApiOpts | connection options. |
Returns
Promise<VolumeEntryStat>
readFile()
Call Signature
readFile(path: string, opts?: VolumeApiOpts & 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 | connection options. |
Returns
Promise<string>
file content as string
Call Signature
readFile(path: string, opts?: VolumeApiOpts & 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 | connection options. |
Returns
Promise<Uint8Array<ArrayBufferLike>>
file content as Uint8Array
Call Signature
readFile(path: string, opts?: VolumeApiOpts & 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 | connection options. |
Returns
Promise<Blob>
file content as Blob
Call Signature
readFile(path: string, opts?: VolumeApiOpts & 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 | connection options. |
Returns
Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>
file content as ReadableStream
remove()
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(
path: string,
metadata: VolumeMetadataOptions,
opts?: VolumeApiOpts): Promise<VolumeEntryStat>
Update file or directory metadata.
Parameters
| Parameter | Type | Description |
|---|
path | string | path to the file or directory. |
metadata | VolumeMetadataOptions | metadata to update (uid, gid, mode). |
opts? | VolumeApiOpts | connection options. |
Returns
Promise<VolumeEntryStat>
updated entry information.
writeFile()
writeFile(
path: string,
data:
| string
| ArrayBuffer
| Blob
| ReadableStream<Uint8Array<ArrayBufferLike>>,
opts?: VolumeMetadataOptions & 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. |
opts? | VolumeMetadataOptions & object & VolumeApiOpts | connection options. |
Returns
Promise<VolumeEntryStat>
information about the written file
connect()
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()
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()
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()
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()
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
new VolumeConnectionConfig(volume: Volume, opts?: VolumeApiOpts): VolumeConnectionConfig
Parameters
| Parameter | Type |
|---|
volume | Volume |
opts? | VolumeApiOpts |
Returns
VolumeConnectionConfig
Properties
| Property | Modifier | Type |
|---|
apiUrl | readonly | string |
debug | readonly | boolean |
domain | readonly | string |
headers? | readonly | Record<string, string> |
logger? | readonly | Logger |
requestTimeoutMs? | readonly | number |
token? | readonly | string |
Methods
getSignal()
getSignal(requestTimeoutMs?: number): undefined | AbortSignal
Parameters
| Parameter | Type |
|---|
requestTimeoutMs? | number |
Returns
undefined | AbortSignal
Interfaces
VolumeApiOpts
Properties
domain?
Domain to use for the volume API.
Default
E2B_DOMAIN // environment variable or e2b.app
optional headers: Record<string, string>;
Additional headers to send with the request.
logger?
Logger to use for logging messages. It can accept any object that implements Logger interface—for example, console.
requestTimeoutMs?
optional requestTimeoutMs: number;
Timeout for requests to the API in milliseconds.
Default
token?
E2B API key to use for authentication.
Default
E2B_API_KEY // environment variable
Type Aliases
VolumeAndToken
type VolumeAndToken = VolumeInfo & object;
Information about a volume and its auth token.
Type declaration
| Name | Type | Description |
|---|
token | string | Volume auth token. |
VolumeEntryStat
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
type VolumeInfo = object;
Information about a volume.
Type declaration
| Name | Type | Description |
|---|
name | string | Volume name. |
volumeId | string | Volume ID. |
type VolumeMetadataOptions = object;
Options for updating file metadata.
Type declaration
| Name | Type | Description |
|---|
gid? | number | Group ID of the file or directory. |
mode? | number | Mode of the file or directory. |
uid? | number | User ID of the file or directory. |
VolumeWriteOptions
type VolumeWriteOptions = VolumeMetadataOptions & 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. |