From d9a1177b1f84a1ddf0bda863242f9d3750c4fa0c Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Wed, 18 Feb 2026 15:49:06 +0100 Subject: [PATCH 1/9] added volume docs --- docs.json | 10 +++ docs/volumes.mdx | 121 ++++++++++++++++++++++++++ docs/volumes/download.mdx | 31 +++++++ docs/volumes/info.mdx | 165 ++++++++++++++++++++++++++++++++++++ docs/volumes/read-write.mdx | 135 +++++++++++++++++++++++++++++ docs/volumes/upload.mdx | 75 ++++++++++++++++ 6 files changed, 537 insertions(+) create mode 100644 docs/volumes.mdx create mode 100644 docs/volumes/download.mdx create mode 100644 docs/volumes/info.mdx create mode 100644 docs/volumes/read-write.mdx create mode 100644 docs/volumes/upload.mdx diff --git a/docs.json b/docs.json index 2e722f14..10e3f829 100644 --- a/docs.json +++ b/docs.json @@ -164,6 +164,16 @@ "docs/filesystem/download" ] }, + { + "group": "Volumes", + "pages": [ + "docs/volumes", + "docs/volumes/read-write", + "docs/volumes/info", + "docs/volumes/upload", + "docs/volumes/download" + ] + }, { "group": "Commands", "pages": [ diff --git a/docs/volumes.mdx b/docs/volumes.mdx new file mode 100644 index 00000000..e39a8db2 --- /dev/null +++ b/docs/volumes.mdx @@ -0,0 +1,121 @@ +--- +title: "Volumes" +sidebarTitle: Overview +--- + +Volumes provide persistent storage that exists independently of sandbox lifecycles. Data written to a volume persists even after a sandbox is shut down, and volumes can be mounted to multiple sandboxes over time. + +With E2B SDK you can: +- [Read and write files to a volume.](/docs/volumes/read-write) +- [Get file and directory metadata.](/docs/volumes/info) +- [Upload data to a volume.](/docs/volumes/upload) +- [Download data from a volume.](/docs/volumes/download) + +## Create a volume + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') +console.log(volume.volumeId) // Volume ID +console.log(volume.name) // 'my-volume' +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') +print(volume.volume_id) # Volume ID +print(volume.name) # 'my-volume' +``` + + +## Mount a volume to a sandbox + +You can mount one or more volumes to a sandbox when creating it. The keys of the `volumeMounts` / `volume_mounts` object are the mount paths inside the sandbox. + + +```js JavaScript & TypeScript +import { Volume, Sandbox } from 'e2b' + +const volume = await Volume.create('my-volume') + +const sandbox = await Sandbox.create({ + volumeMounts: { + '/mnt/my-data': volume, + }, +}) + +// Files written to /mnt/my-data inside the sandbox are persisted in the volume +await sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!') +``` +```python Python +from e2b import Volume, Sandbox + +volume = Volume.create('my-volume') + +sandbox = Sandbox.create( + volume_mounts={ + '/mnt/my-data': volume, + }, +) + +# Files written to /mnt/my-data inside the sandbox are persisted in the volume +sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!') +``` + + +## List volumes + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volumes = await Volume.list() +console.log(volumes) +// [{ volumeId: '...', name: 'my-volume' }, ...] +``` +```python Python +from e2b import Volume + +volumes = Volume.list() +print(volumes) +# [VolumeInfo(volume_id='...', name='my-volume'), ...] +``` + + +## Get volume info + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const info = await Volume.getInfo('volume-id') +console.log(info) +// { volumeId: '...', name: 'my-volume' } +``` +```python Python +from e2b import Volume + +info = Volume.get_info('volume-id') +print(info) +# VolumeInfo(volume_id='...', name='my-volume') +``` + + +## Destroy a volume + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const success = await Volume.destroy('volume-id') +console.log(success) // true +``` +```python Python +from e2b import Volume + +success = Volume.destroy('volume-id') +print(success) # True +``` + diff --git a/docs/volumes/download.mdx b/docs/volumes/download.mdx new file mode 100644 index 00000000..e2f0ef2a --- /dev/null +++ b/docs/volumes/download.mdx @@ -0,0 +1,31 @@ +--- +title: "Download data from volume" +sidebarTitle: Download data +--- + +You can download data from a volume using the `readFile()` / `read_file()` method. + + +```js JavaScript & TypeScript +import fs from 'fs' +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +// Read file from volume +const content = await volume.readFile('/path/in/volume') +// Write file to local filesystem +fs.writeFileSync('/local/path', content) +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +# Read file from volume +content = volume.read_file('/path/in/volume') +# Write file to local filesystem +with open('/local/path', 'w') as file: + file.write(content) +``` + diff --git a/docs/volumes/info.mdx b/docs/volumes/info.mdx new file mode 100644 index 00000000..e3b1aa54 --- /dev/null +++ b/docs/volumes/info.mdx @@ -0,0 +1,165 @@ +--- +title: "Get information about a file or directory" +sidebarTitle: File & directory metadata +--- + +You can get information about a file or directory in a volume using the `getEntryInfo()` / `get_entry_info()` method. + +### Getting information about a file + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +// Create a new file +await volume.writeFile('/test_file.txt', 'Hello, world!') + +// Get information about the file +const info = await volume.getEntryInfo('/test_file.txt') + +console.log(info) +// { +// name: 'test_file.txt', +// type: 'file', +// path: '/test_file.txt', +// size: 13, +// mode: 0o644, +// uid: 0, +// gid: 0, +// mtime: 2025-05-26T12:00:00.000Z, +// ctime: 2025-05-26T12:00:00.000Z, +// target: null +// } +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +# Create a new file +volume.write_file('/test_file.txt', 'Hello, world!') + +# Get information about the file +info = volume.get_entry_info('/test_file.txt') + +print(info) +# VolumeEntryStat( +# name='test_file.txt', +# type_='file', +# path='/test_file.txt', +# size=13, +# mode=0o644, +# uid=0, +# gid=0, +# mtime=datetime(2025, 5, 26, 12, 0, 0), +# ctime=datetime(2025, 5, 26, 12, 0, 0), +# target=None +# ) +``` + + +### Getting information about a directory + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +// Create a new directory +await volume.makeDir('/test_dir') + +// Get information about the directory +const info = await volume.getEntryInfo('/test_dir') + +console.log(info) +// { +// name: 'test_dir', +// type: 'directory', +// path: '/test_dir', +// size: 0, +// mode: 0o755, +// uid: 0, +// gid: 0, +// mtime: 2025-05-26T12:00:00.000Z, +// ctime: 2025-05-26T12:00:00.000Z, +// target: null +// } +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +# Create a new directory +volume.make_dir('/test_dir') + +# Get information about the directory +info = volume.get_entry_info('/test_dir') + +print(info) +# VolumeEntryStat( +# name='test_dir', +# type_='directory', +# path='/test_dir', +# size=0, +# mode=0o755, +# uid=0, +# gid=0, +# mtime=datetime(2025, 5, 26, 12, 0, 0), +# ctime=datetime(2025, 5, 26, 12, 0, 0), +# target=None +# ) +``` + + +### Updating metadata + +You can update file or directory metadata such as user ID, group ID, and permissions mode using the `updateMetadata()` / `update_metadata()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +await volume.writeFile('/test_file.txt', 'Hello, world!') + +const updated = await volume.updateMetadata('/test_file.txt', { uid: 1000, gid: 1000, mode: 0o600 }) + +console.log(updated) +// { +// name: 'test_file.txt', +// type: 'file', +// path: '/test_file.txt', +// size: 13, +// mode: 0o600, +// uid: 1000, +// gid: 1000, +// ... +// } +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +volume.write_file('/test_file.txt', 'Hello, world!') + +updated = volume.update_metadata('/test_file.txt', uid=1000, gid=1000, mode=0o600) + +print(updated) +# VolumeEntryStat( +# name='test_file.txt', +# type_='file', +# path='/test_file.txt', +# size=13, +# mode=0o600, +# uid=1000, +# gid=1000, +# ... +# ) +``` + diff --git a/docs/volumes/read-write.mdx b/docs/volumes/read-write.mdx new file mode 100644 index 00000000..53f33df0 --- /dev/null +++ b/docs/volumes/read-write.mdx @@ -0,0 +1,135 @@ +--- +title: "Read & write files" +sidebarTitle: Read & write +--- + +## Reading files + +You can read files from a volume using the `readFile()` / `read_file()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +const content = await volume.readFile('/path/to/file') +console.log(content) +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +content = volume.read_file('/path/to/file') +print(content) +``` + + +## Writing files + +You can write files to a volume using the `writeFile()` / `write_file()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +await volume.writeFile('/path/to/file', 'file content') +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +volume.write_file('/path/to/file', 'file content') +``` + + +## Creating directories + +You can create directories in a volume using the `makeDir()` / `make_dir()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +await volume.makeDir('/path/to/dir') + +// Create nested directories with force option +await volume.makeDir('/path/to/nested/dir', { force: true }) +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +volume.make_dir('/path/to/dir') + +# Create nested directories with create_parents option +volume.make_dir('/path/to/nested/dir', create_parents=True) +``` + + +## Listing directory contents + +You can list the contents of a directory in a volume using the `list()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +const entries = await volume.list('/path/to/dir') +console.log(entries) +// [ +// { name: 'file.txt', type: 'file', path: '/path/to/dir/file.txt', size: 13, ... }, +// { name: 'subdir', type: 'directory', path: '/path/to/dir/subdir', size: 0, ... }, +// ] +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +entries = volume.list('/path/to/dir') +print(entries) +# [ +# VolumeEntryStat(name='file.txt', type_='file', path='/path/to/dir/file.txt', size=13, ...), +# VolumeEntryStat(name='subdir', type_='directory', path='/path/to/dir/subdir', size=0, ...), +# ] +``` + + +## Removing files or directories + +You can remove files or directories from a volume using the `remove()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +// Remove a file +await volume.remove('/path/to/file') + +// Remove a directory recursively +await volume.remove('/path/to/dir', { recursive: true }) +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +# Remove a file +volume.remove('/path/to/file') + +# Remove a directory recursively +volume.remove('/path/to/dir', recursive=True) +``` + diff --git a/docs/volumes/upload.mdx b/docs/volumes/upload.mdx new file mode 100644 index 00000000..dee64c68 --- /dev/null +++ b/docs/volumes/upload.mdx @@ -0,0 +1,75 @@ +--- +title: "Upload data to volume" +sidebarTitle: Upload data +--- + +You can upload data to a volume using the `writeFile()` / `write_file()` method. + +## Upload single file + + +```js JavaScript & TypeScript +import fs from 'fs' +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +// Read file from local filesystem +const content = fs.readFileSync('/local/path') +// Upload file to volume +await volume.writeFile('/path/in/volume', content) +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +# Read file from local filesystem +with open('/local/path', 'rb') as file: + # Upload file to volume + volume.write_file('/path/in/volume', file) +``` + + +## Upload directory / multiple files + + +```js JavaScript & TypeScript +import fs from 'fs' +import path from 'path' +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +const directoryPath = '/local/dir' +const files = fs.readdirSync(directoryPath) + +for (const file of files) { + const fullPath = path.join(directoryPath, file) + + // Skip directories + if (!fs.statSync(fullPath).isFile()) continue + + const content = fs.readFileSync(fullPath) + await volume.writeFile(`/upload/${file}`, content) +} +``` +```python Python +import os +from e2b import Volume + +volume = Volume.create('my-volume') + +directory_path = '/local/dir' + +for filename in os.listdir(directory_path): + file_path = os.path.join(directory_path, filename) + + # Skip directories + if not os.path.isfile(file_path): + continue + + with open(file_path, 'rb') as file: + volume.write_file(f'/upload/{filename}', file) +``` + From 67c659a01cd2b372ccf069f07892383ba329e95f Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 23 Feb 2026 18:53:52 +0100 Subject: [PATCH 2/9] updated docs --- docs/volumes.mdx | 21 +++++++++++++++++++ docs/volumes/info.mdx | 41 +++++++++++++++++++++++++++++-------- docs/volumes/read-write.mdx | 4 ++-- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/docs/volumes.mdx b/docs/volumes.mdx index e39a8db2..4ad193dc 100644 --- a/docs/volumes.mdx +++ b/docs/volumes.mdx @@ -30,6 +30,27 @@ print(volume.name) # 'my-volume' ``` +## Connect to an existing volume + +You can connect to an existing volume by its ID using the `connect()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.connect('volume-id') +console.log(volume.volumeId) // Volume ID +console.log(volume.name) // Volume name +``` +```python Python +from e2b import Volume + +volume = Volume.connect('volume-id') +print(volume.volume_id) # Volume ID +print(volume.name) # Volume name +``` + + ## Mount a volume to a sandbox You can mount one or more volumes to a sandbox when creating it. The keys of the `volumeMounts` / `volume_mounts` object are the mount paths inside the sandbox. diff --git a/docs/volumes/info.mdx b/docs/volumes/info.mdx index e3b1aa54..91c3c7ef 100644 --- a/docs/volumes/info.mdx +++ b/docs/volumes/info.mdx @@ -3,7 +3,7 @@ title: "Get information about a file or directory" sidebarTitle: File & directory metadata --- -You can get information about a file or directory in a volume using the `getEntryInfo()` / `get_entry_info()` method. +You can get information about a file or directory in a volume using the `getInfo()` / `get_info()` method. ### Getting information about a file @@ -17,7 +17,7 @@ const volume = await Volume.create('my-volume') await volume.writeFile('/test_file.txt', 'Hello, world!') // Get information about the file -const info = await volume.getEntryInfo('/test_file.txt') +const info = await volume.getInfo('/test_file.txt') console.log(info) // { @@ -28,9 +28,9 @@ console.log(info) // mode: 0o644, // uid: 0, // gid: 0, +// atime: 2025-05-26T12:00:00.000Z, // mtime: 2025-05-26T12:00:00.000Z, // ctime: 2025-05-26T12:00:00.000Z, -// target: null // } ``` ```python Python @@ -42,7 +42,7 @@ volume = Volume.create('my-volume') volume.write_file('/test_file.txt', 'Hello, world!') # Get information about the file -info = volume.get_entry_info('/test_file.txt') +info = volume.get_info('/test_file.txt') print(info) # VolumeEntryStat( @@ -53,9 +53,9 @@ print(info) # mode=0o644, # uid=0, # gid=0, +# atime=datetime(2025, 5, 26, 12, 0, 0), # mtime=datetime(2025, 5, 26, 12, 0, 0), # ctime=datetime(2025, 5, 26, 12, 0, 0), -# target=None # ) ``` @@ -72,7 +72,7 @@ const volume = await Volume.create('my-volume') await volume.makeDir('/test_dir') // Get information about the directory -const info = await volume.getEntryInfo('/test_dir') +const info = await volume.getInfo('/test_dir') console.log(info) // { @@ -83,9 +83,9 @@ console.log(info) // mode: 0o755, // uid: 0, // gid: 0, +// atime: 2025-05-26T12:00:00.000Z, // mtime: 2025-05-26T12:00:00.000Z, // ctime: 2025-05-26T12:00:00.000Z, -// target: null // } ``` ```python Python @@ -97,7 +97,7 @@ volume = Volume.create('my-volume') volume.make_dir('/test_dir') # Get information about the directory -info = volume.get_entry_info('/test_dir') +info = volume.get_info('/test_dir') print(info) # VolumeEntryStat( @@ -108,13 +108,36 @@ print(info) # mode=0o755, # uid=0, # gid=0, +# atime=datetime(2025, 5, 26, 12, 0, 0), # mtime=datetime(2025, 5, 26, 12, 0, 0), # ctime=datetime(2025, 5, 26, 12, 0, 0), -# target=None # ) ``` +### Checking if a path exists + +You can check whether a file or directory exists in a volume using the `exists()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') + +const fileExists = await volume.exists('/test_file.txt') +console.log(fileExists) // true or false +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') + +file_exists = volume.exists('/test_file.txt') +print(file_exists) # True or False +``` + + ### Updating metadata You can update file or directory metadata such as user ID, group ID, and permissions mode using the `updateMetadata()` / `update_metadata()` method. diff --git a/docs/volumes/read-write.mdx b/docs/volumes/read-write.mdx index 53f33df0..43838b6c 100644 --- a/docs/volumes/read-write.mdx +++ b/docs/volumes/read-write.mdx @@ -69,8 +69,8 @@ volume = Volume.create('my-volume') volume.make_dir('/path/to/dir') -# Create nested directories with create_parents option -volume.make_dir('/path/to/nested/dir', create_parents=True) +# Create nested directories with force option +volume.make_dir('/path/to/nested/dir', force=True) ``` From 7e6be2f978994cbe365b4a9d5bcf0df24e5d5285 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 23 Feb 2026 19:17:14 +0100 Subject: [PATCH 3/9] diagram --- docs/volumes.mdx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/volumes.mdx b/docs/volumes.mdx index 4ad193dc..147e41ab 100644 --- a/docs/volumes.mdx +++ b/docs/volumes.mdx @@ -5,6 +5,23 @@ sidebarTitle: Overview Volumes provide persistent storage that exists independently of sandbox lifecycles. Data written to a volume persists even after a sandbox is shut down, and volumes can be mounted to multiple sandboxes over time. +### One volume shared across multiple sandboxes + +```mermaid +graph LR + V1[Volume A] --- S1[Sandbox 1] + V1 --- S2[Sandbox 2] + V1 --- S3[Sandbox 3] +``` + +### Each sandbox with its own volume + +```mermaid +graph LR + V2[Volume A] --- S4[Sandbox 1] + V3[Volume B] --- S5[Sandbox 2] +``` + With E2B SDK you can: - [Read and write files to a volume.](/docs/volumes/read-write) - [Get file and directory metadata.](/docs/volumes/info) From 3655dc343995c67e8cbd8cb5ff0e5a666c42cc2b Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 23 Feb 2026 19:28:12 +0100 Subject: [PATCH 4/9] added examples, note --- docs/volumes.mdx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/volumes.mdx b/docs/volumes.mdx index 147e41ab..4cdb738f 100644 --- a/docs/volumes.mdx +++ b/docs/volumes.mdx @@ -30,6 +30,10 @@ With E2B SDK you can: ## Create a volume + +Volume names can only contain letters, numbers, and hyphens. + + ```js JavaScript & TypeScript import { Volume } from 'e2b' @@ -78,12 +82,20 @@ import { Volume, Sandbox } from 'e2b' const volume = await Volume.create('my-volume') +// You can pass a Volume object const sandbox = await Sandbox.create({ volumeMounts: { '/mnt/my-data': volume, }, }) +// Or pass the volume name directly +const sandbox2 = await Sandbox.create({ + volumeMounts: { + '/mnt/my-data': 'my-volume', + }, +}) + // Files written to /mnt/my-data inside the sandbox are persisted in the volume await sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!') ``` @@ -92,12 +104,20 @@ from e2b import Volume, Sandbox volume = Volume.create('my-volume') +# You can pass a Volume object sandbox = Sandbox.create( volume_mounts={ '/mnt/my-data': volume, }, ) +# Or pass the volume name directly +sandbox2 = Sandbox.create( + volume_mounts={ + '/mnt/my-data': 'my-volume', + }, +) + # Files written to /mnt/my-data inside the sandbox are persisted in the volume sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!') ``` From 820eba192a2f610d1792738df859256b3e9599d0 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Mon, 23 Feb 2026 19:37:38 +0100 Subject: [PATCH 5/9] added clarification --- docs/volumes.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/volumes.mdx b/docs/volumes.mdx index 4cdb738f..dd0252f9 100644 --- a/docs/volumes.mdx +++ b/docs/volumes.mdx @@ -5,7 +5,7 @@ sidebarTitle: Overview Volumes provide persistent storage that exists independently of sandbox lifecycles. Data written to a volume persists even after a sandbox is shut down, and volumes can be mounted to multiple sandboxes over time. -### One volume shared across multiple sandboxes +**One volume shared across multiple sandboxes** ```mermaid graph LR @@ -14,7 +14,7 @@ graph LR V1 --- S3[Sandbox 3] ``` -### Each sandbox with its own volume +**Each sandbox with its own volume** ```mermaid graph LR @@ -22,6 +22,8 @@ graph LR V3[Volume B] --- S5[Sandbox 2] ``` +When a volume is mounted to a sandbox, files can be read and written directly at the mount path. The SDK methods are meant to be used when the volume is not mounted to any sandbox. + With E2B SDK you can: - [Read and write files to a volume.](/docs/volumes/read-write) - [Get file and directory metadata.](/docs/volumes/info) From 9082105cd0352deb866ceecb7ee3855e5d89cef5 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Thu, 26 Feb 2026 23:27:02 +0100 Subject: [PATCH 6/9] removed diagram controls --- docs/volumes.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/volumes.mdx b/docs/volumes.mdx index dd0252f9..ae2d15e4 100644 --- a/docs/volumes.mdx +++ b/docs/volumes.mdx @@ -7,7 +7,7 @@ Volumes provide persistent storage that exists independently of sandbox lifecycl **One volume shared across multiple sandboxes** -```mermaid +```mermaid actions={false} graph LR V1[Volume A] --- S1[Sandbox 1] V1 --- S2[Sandbox 2] From 8e0db0331849320d9ef2655d12d6740fca1ff316 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Thu, 26 Feb 2026 23:29:10 +0100 Subject: [PATCH 7/9] remove the diagram controls --- docs/volumes.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/volumes.mdx b/docs/volumes.mdx index ae2d15e4..83311365 100644 --- a/docs/volumes.mdx +++ b/docs/volumes.mdx @@ -16,7 +16,7 @@ graph LR **Each sandbox with its own volume** -```mermaid +```mermaid actions={false} graph LR V2[Volume A] --- S4[Sandbox 1] V3[Volume B] --- S5[Sandbox 2] From 0c6f62f448c70ea37b87d4cdf801580f36269ffe Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Fri, 20 Mar 2026 16:39:17 +0100 Subject: [PATCH 8/9] added standalone diagram --- docs/volumes.mdx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/volumes.mdx b/docs/volumes.mdx index 83311365..497e879b 100644 --- a/docs/volumes.mdx +++ b/docs/volumes.mdx @@ -22,6 +22,14 @@ graph LR V3[Volume B] --- S5[Sandbox 2] ``` +**Standalone usage via SDK** + +```mermaid actions={false} +graph LR + SDK[SDK] --- V4[Volume A] + SDK --- V5[Volume B] +``` + When a volume is mounted to a sandbox, files can be read and written directly at the mount path. The SDK methods are meant to be used when the volume is not mounted to any sandbox. With E2B SDK you can: From c8e9964bedfd0bc2cf8b80c522d2d2705ca3c918 Mon Sep 17 00:00:00 2001 From: Mish Ushakov <10400064+mishushakov@users.noreply.github.com> Date: Fri, 20 Mar 2026 16:56:49 +0100 Subject: [PATCH 9/9] updated volumes docs --- docs.json | 2 + docs/volumes.mdx | 127 +--------------------------------------- docs/volumes/manage.mdx | 102 ++++++++++++++++++++++++++++++++ docs/volumes/mount.mdx | 52 ++++++++++++++++ 4 files changed, 159 insertions(+), 124 deletions(-) create mode 100644 docs/volumes/manage.mdx create mode 100644 docs/volumes/mount.mdx diff --git a/docs.json b/docs.json index 4de6c4f9..1744cf15 100644 --- a/docs.json +++ b/docs.json @@ -161,6 +161,8 @@ "group": "Volumes", "pages": [ "docs/volumes", + "docs/volumes/manage", + "docs/volumes/mount", "docs/volumes/read-write", "docs/volumes/info", "docs/volumes/upload", diff --git a/docs/volumes.mdx b/docs/volumes.mdx index 497e879b..d489d777 100644 --- a/docs/volumes.mdx +++ b/docs/volumes.mdx @@ -33,58 +33,14 @@ graph LR When a volume is mounted to a sandbox, files can be read and written directly at the mount path. The SDK methods are meant to be used when the volume is not mounted to any sandbox. With E2B SDK you can: +- [Manage volumes.](/docs/volumes/manage) +- [Mount volumes to sandboxes.](/docs/volumes/mount) - [Read and write files to a volume.](/docs/volumes/read-write) - [Get file and directory metadata.](/docs/volumes/info) - [Upload data to a volume.](/docs/volumes/upload) - [Download data from a volume.](/docs/volumes/download) -## Create a volume - - -Volume names can only contain letters, numbers, and hyphens. - - - -```js JavaScript & TypeScript -import { Volume } from 'e2b' - -const volume = await Volume.create('my-volume') -console.log(volume.volumeId) // Volume ID -console.log(volume.name) // 'my-volume' -``` -```python Python -from e2b import Volume - -volume = Volume.create('my-volume') -print(volume.volume_id) # Volume ID -print(volume.name) # 'my-volume' -``` - - -## Connect to an existing volume - -You can connect to an existing volume by its ID using the `connect()` method. - - -```js JavaScript & TypeScript -import { Volume } from 'e2b' - -const volume = await Volume.connect('volume-id') -console.log(volume.volumeId) // Volume ID -console.log(volume.name) // Volume name -``` -```python Python -from e2b import Volume - -volume = Volume.connect('volume-id') -print(volume.volume_id) # Volume ID -print(volume.name) # Volume name -``` - - -## Mount a volume to a sandbox - -You can mount one or more volumes to a sandbox when creating it. The keys of the `volumeMounts` / `volume_mounts` object are the mount paths inside the sandbox. +## Example ```js JavaScript & TypeScript @@ -92,98 +48,21 @@ import { Volume, Sandbox } from 'e2b' const volume = await Volume.create('my-volume') -// You can pass a Volume object const sandbox = await Sandbox.create({ volumeMounts: { '/mnt/my-data': volume, }, }) - -// Or pass the volume name directly -const sandbox2 = await Sandbox.create({ - volumeMounts: { - '/mnt/my-data': 'my-volume', - }, -}) - -// Files written to /mnt/my-data inside the sandbox are persisted in the volume -await sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!') ``` ```python Python from e2b import Volume, Sandbox volume = Volume.create('my-volume') -# You can pass a Volume object sandbox = Sandbox.create( volume_mounts={ '/mnt/my-data': volume, }, ) - -# Or pass the volume name directly -sandbox2 = Sandbox.create( - volume_mounts={ - '/mnt/my-data': 'my-volume', - }, -) - -# Files written to /mnt/my-data inside the sandbox are persisted in the volume -sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!') -``` - - -## List volumes - - -```js JavaScript & TypeScript -import { Volume } from 'e2b' - -const volumes = await Volume.list() -console.log(volumes) -// [{ volumeId: '...', name: 'my-volume' }, ...] -``` -```python Python -from e2b import Volume - -volumes = Volume.list() -print(volumes) -# [VolumeInfo(volume_id='...', name='my-volume'), ...] -``` - - -## Get volume info - - -```js JavaScript & TypeScript -import { Volume } from 'e2b' - -const info = await Volume.getInfo('volume-id') -console.log(info) -// { volumeId: '...', name: 'my-volume' } -``` -```python Python -from e2b import Volume - -info = Volume.get_info('volume-id') -print(info) -# VolumeInfo(volume_id='...', name='my-volume') -``` - - -## Destroy a volume - - -```js JavaScript & TypeScript -import { Volume } from 'e2b' - -const success = await Volume.destroy('volume-id') -console.log(success) // true -``` -```python Python -from e2b import Volume - -success = Volume.destroy('volume-id') -print(success) # True ``` diff --git a/docs/volumes/manage.mdx b/docs/volumes/manage.mdx new file mode 100644 index 00000000..08bbd6c0 --- /dev/null +++ b/docs/volumes/manage.mdx @@ -0,0 +1,102 @@ +--- +title: "Managing volumes" +--- + +## Create a volume + + +Volume names can only contain letters, numbers, and hyphens. + + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.create('my-volume') +console.log(volume.volumeId) // Volume ID +console.log(volume.name) // 'my-volume' +``` +```python Python +from e2b import Volume + +volume = Volume.create('my-volume') +print(volume.volume_id) # Volume ID +print(volume.name) # 'my-volume' +``` + + +## Connect to an existing volume + +You can connect to an existing volume by its ID using the `connect()` method. + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volume = await Volume.connect('volume-id') +console.log(volume.volumeId) // Volume ID +console.log(volume.name) // Volume name +``` +```python Python +from e2b import Volume + +volume = Volume.connect('volume-id') +print(volume.volume_id) # Volume ID +print(volume.name) # Volume name +``` + + +## List volumes + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const volumes = await Volume.list() +console.log(volumes) +// [{ volumeId: '...', name: 'my-volume' }, ...] +``` +```python Python +from e2b import Volume + +volumes = Volume.list() +print(volumes) +# [VolumeInfo(volume_id='...', name='my-volume'), ...] +``` + + +## Get volume info + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const info = await Volume.getInfo('volume-id') +console.log(info) +// { volumeId: '...', name: 'my-volume' } +``` +```python Python +from e2b import Volume + +info = Volume.get_info('volume-id') +print(info) +# VolumeInfo(volume_id='...', name='my-volume') +``` + + +## Destroy a volume + + +```js JavaScript & TypeScript +import { Volume } from 'e2b' + +const success = await Volume.destroy('volume-id') +console.log(success) // true +``` +```python Python +from e2b import Volume + +success = Volume.destroy('volume-id') +print(success) # True +``` + diff --git a/docs/volumes/mount.mdx b/docs/volumes/mount.mdx new file mode 100644 index 00000000..ab02a12d --- /dev/null +++ b/docs/volumes/mount.mdx @@ -0,0 +1,52 @@ +--- +title: "Mounting volumes" +--- + +You can mount one or more volumes to a sandbox when creating it. The keys of the `volumeMounts` / `volume_mounts` object are the mount paths inside the sandbox. + + +```js JavaScript & TypeScript +import { Volume, Sandbox } from 'e2b' + +const volume = await Volume.create('my-volume') + +// You can pass a Volume object +const sandbox = await Sandbox.create({ + volumeMounts: { + '/mnt/my-data': volume, + }, +}) + +// Or pass the volume name directly +const sandbox = await Sandbox.create({ + volumeMounts: { + '/mnt/my-data': 'my-volume', + }, +}) + +// Files written to /mnt/my-data inside the sandbox are persisted in the volume +await sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!') +``` +```python Python +from e2b import Volume, Sandbox + +volume = Volume.create('my-volume') + +# You can pass a Volume object +sandbox = Sandbox.create( + volume_mounts={ + '/mnt/my-data': volume, + }, +) + +# Or pass the volume name directly +sandbox = Sandbox.create( + volume_mounts={ + '/mnt/my-data': 'my-volume', + }, +) + +# Files written to /mnt/my-data inside the sandbox are persisted in the volume +sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!') +``` +