Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Update docs

Vasek Mlejnskycd5f6adcf29d
diff --git a/apps/web/src/app/(docs)/docs/sandbox/metadata/page.mdx b/apps/web/src/app/(docs)/docs/sandbox/metadata/page.mdx
new file mode 100644
index 000000000..0db8a8e01
--- /dev/null
+++ b/apps/web/src/app/(docs)/docs/sandbox/metadata/page.mdx
@@ -0,0 +1,49 @@
+# Sandbox metadata
+
+Metadata is a way to attach arbitrary key-value pairs for a sandbox.
+
+This is useful in various scenarios, for example:
+- Associate a sandbox with a user session.
+- Store custom user data for a sandbox like API keys.
+- Associate a sandbox with a user ID and [connect to it later](/docs/sandbox/connect).
+
+You specify metadata when creating a sandbox and can access it later through listing running sandboxes with `Sandbox.list()` method.
+
+<CodeGroup>
+```js
+import { Sandbox } from '@e2b/code-interpreter'
+
+// Create sandbox with metadata.
+const sandbox = await Sandbox.create({
+ metadata: {
+ userId: '123', // $HighlightLine
+ },
+})
+
+// List running sandboxes and access metadata.
+const runningSandboxes = await Sandbox.list()
+// Will print:
+// {
+// 'userId': '123',
+// }
+console.log(runningSandboxes[0].metadata)
+```
+```python
+from e2b_code_interpreter import Sandbox
+
+# Create sandbox with metadata.
+sandbox = Sandbox(
+ metadata={
+ 'userId': '123', # $HighlightLine
+ },
+)
+
+# List running sandboxes and access metadata.
+running_sandboxes = Sandbox.list()
+# Will print:
+# {
+# 'userId': '123',
+# }
+print(running_sandboxes[0].metadata)
+```
+</CodeGroup>
diff --git a/apps/web/src/components/Navigation/routes.tsx b/apps/web/src/components/Navigation/routes.tsx
index 6c0f2ee7b..6e5928fd8 100644
--- a/apps/web/src/components/Navigation/routes.tsx
+++ b/apps/web/src/components/Navigation/routes.tsx
@@ -287,13 +287,25 @@ export const routes: NavGroup[] = [
href: '/docs/sandbox',
},
{
- title: '* Metadata',
- href: '/docs/sandbox/filesystem',
+ title: 'Metadata',
+ href: '/docs/sandbox/metadata',
},
{
title: '* Environment variables',
href: '/docs/sandbox/environment-variables',
},
+ {
+ title: '* List running sandboxes',
+ href: '/docs/sandbox/list',
+ },
+ {
+ title: '* Connect to running sandbox',
+ href: '/docs/sandbox/connect',
+ },
+ {
+ title: '* Request timeouts',
+ href: '/docs/sandbox/request-timeouts',
+ },
{
title: '* Persistence',
href: '/docs/sandbox/persistence',