Skip to main content

Create a volume

Volume names can only contain letters, numbers, and hyphens.
import { Volume } from 'e2b'

const volume = await Volume.create('my-volume')
console.log(volume.volumeId) // Volume ID
console.log(volume.name)     // 'my-volume'

Connect to an existing volume

You can connect to an existing volume by its ID using the connect() method.
import { Volume } from 'e2b'

const volume = await Volume.connect('volume-id')
console.log(volume.volumeId) // Volume ID
console.log(volume.name)     // Volume name

List volumes

import { Volume } from 'e2b'

const volumes = await Volume.list()
console.log(volumes)
// [{ volumeId: '...', name: 'my-volume' }, ...]

Get volume info

import { Volume } from 'e2b'

const info = await Volume.getInfo('volume-id')
console.log(info)
// { volumeId: '...', name: 'my-volume' }

Destroy a volume

import { Volume } from 'e2b'

const success = await Volume.destroy('volume-id')
console.log(success) // true