Skip to content

armgit / E2B

Public Imported from GitHub
0

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

feat: implement network out allow/deny list support (#1016)

Jakub Dobry4c612888d428
diff --git a/.changeset/cuddly-horses-push.md b/.changeset/cuddly-horses-push.md
new file mode 100644
index 000000000..c90884e59
--- /dev/null
+++ b/.changeset/cuddly-horses-push.md
@@ -0,0 +1,6 @@
+---
+'@e2b/python-sdk': minor
+'e2b': minor
+---
+
+add possibility to mask the Host in public requests with custom value
diff --git a/.changeset/loud-bottles-provide.md b/.changeset/loud-bottles-provide.md
new file mode 100644
index 000000000..7bb8b15de
--- /dev/null
+++ b/.changeset/loud-bottles-provide.md
@@ -0,0 +1,6 @@
+---
+'@e2b/python-sdk': minor
+'e2b': minor
+---
+
+add ability to secure public traffic using token
diff --git a/.changeset/moody-carpets-speak.md b/.changeset/moody-carpets-speak.md
new file mode 100644
index 000000000..730148ea2
--- /dev/null
+++ b/.changeset/moody-carpets-speak.md
@@ -0,0 +1,6 @@
+---
+'@e2b/python-sdk': minor
+'e2b': minor
+---
+
+add ability to configure sandbox network out allow/deny addresses
diff --git a/packages/js-sdk/package.json b/packages/js-sdk/package.json
index 68556f43c..b8a2b0e09 100644
--- a/packages/js-sdk/package.json
+++ b/packages/js-sdk/package.json
@@ -29,7 +29,7 @@
"example": "tsx example.mts",
"test": "vitest run",
"generate": "npm-run-all generate:* && pnpm run format",
- "generate:api": "python ./../../spec/remove_extra_tags.py sandboxes templates auth && openapi-typescript ../../spec/openapi_generated.yml -x api_key --array-length --alphabetize --output src/api/schema.gen.ts",
+ "generate:api": "python ./../../spec/remove_extra_tags.py sandboxes templates auth && openapi-typescript ../../spec/openapi_generated.yml -x api_key --array-length --alphabetize --default-non-nullable false --output src/api/schema.gen.ts",
"generate:envd": "cd ../../spec/envd && buf generate --template buf-js.gen.yaml\n",
"generate:envd-api": "openapi-typescript ../../spec/envd/envd.yaml -x api_key --array-length --alphabetize --output src/envd/schema.gen.ts",
"generate:mcp": "json2ts -i ./../../spec/mcp-server.json -o src/sandbox/mcp.d.ts --unreachableDefinitions --style.singleQuote --no-style.semi",
diff --git a/packages/js-sdk/src/api/schema.gen.ts b/packages/js-sdk/src/api/schema.gen.ts
index eda37ca6d..e4a64f899 100644
--- a/packages/js-sdk/src/api/schema.gen.ts
+++ b/packages/js-sdk/src/api/schema.gen.ts
@@ -718,7 +718,36 @@ export interface paths {
path?: never;
cookie?: never;
};
- get?: never;
+ /** @description List all builds for a template */
+ get: {
+ parameters: {
+ query?: {
+ /** @description Maximum number of items to return per page */
+ limit?: components["parameters"]["paginationLimit"];
+ /** @description Cursor to start the list from */
+ nextToken?: components["parameters"]["paginationNextToken"];
+ };
+ header?: never;
+ path: {
+ templateID: components["parameters"]["templateID"];
+ };
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ /** @description Successfully returned the template with its builds */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["TemplateWithBuilds"];
+ };
+ };
+ 401: components["responses"]["401"];
+ 500: components["responses"]["500"];
+ };
+ };
put?: never;
/**
* @deprecated
@@ -879,7 +908,7 @@ export interface paths {
[name: string]: unknown;
};
content: {
- "application/json": components["schemas"]["TemplateBuild"];
+ "application/json": components["schemas"]["TemplateBuildInfo"];
};
};
401: components["responses"]["401"];
@@ -950,11 +979,11 @@ export interface paths {
parameters: {
query?: {
/** @description Maximum number of items to return per page */
- limit?: number;
+ limit?: components["parameters"]["paginationLimit"];
/** @description Metadata query used to filter the sandboxes (e.g. "user=abc&app=prod"). Each key and values must be URL encoded. */
metadata?: string;
/** @description Cursor to start the list from */
- nextToken?: string;
+ nextToken?: components["parameters"]["paginationNextToken"];
/** @description Filter sandboxes by one or more states */
state?: components["schemas"]["SandboxState"][];
};
@@ -1152,7 +1181,7 @@ export interface components {
* @description Log entries related to the status reason
* @default []
*/
- logEntries: components["schemas"]["BuildLogEntry"][];
+ logEntries?: components["schemas"]["BuildLogEntry"][];
/** @description Message with the status reason, currently reporting only for error status */
message: string;
/** @description Step that failed */
@@ -1342,16 +1371,17 @@ export interface components {
name: string;
};
NewSandbox: {
- /** @description Allow sandbox to access the internet */
+ /** @description Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut to 0.0.0.0/0 in the network config. */
allow_internet_access?: boolean;
/**
* @description Automatically pauses the sandbox after the timeout
* @default false
*/
- autoPause: boolean;
+ autoPause?: boolean;
envVars?: components["schemas"]["EnvVars"];
mcp?: components["schemas"]["Mcp"];
metadata?: components["schemas"]["SandboxMetadata"];
+ network?: components["schemas"]["SandboxNetworkConfig"];
/** @description Secure all system communication with sandbox */
secure?: boolean;
/** @description Identifier of the required template */
@@ -1361,7 +1391,7 @@ export interface components {
* @description Time to live for the sandbox in seconds.
* @default 15
*/
- timeout: number;
+ timeout?: number;
};
NewTeamAPIKey: {
/** @description Name of the API key */
@@ -1498,7 +1528,7 @@ export interface components {
* @description Time to live for the sandbox in seconds.
* @default 15
*/
- timeout: number;
+ timeout?: number;
};
Sandbox: {
/** @description Alias of the template */
@@ -1517,6 +1547,8 @@ export interface components {
sandboxID: string;
/** @description Identifier of the template from which is the sandbox created */
templateID: string;
+ /** @description Token required for accessing sandbox via proxy. */
+ trafficAccessToken?: string | null;
};
SandboxDetail: {
/** @description Alias of the template */
@@ -1632,6 +1664,19 @@ export interface components {
*/
timestampUnix: number;
};
+ SandboxNetworkConfig: {
+ /** @description List of allowed CIDR blocks or IP addresses for egress traffic. Allowed addresses always take precedence over blocked addresses. */
+ allowOut?: string[];
+ /**
+ * @description Specify if the sandbox URLs should be accessible only with authentication.
+ * @default true
+ */
+ allowPublicTraffic?: boolean;
+ /** @description List of denied CIDR blocks or IP addresses for egress traffic */
+ denyOut?: string[];
+ /** @description Specify host mask which will be used for all sandbox requests */
+ maskRequestHost?: string;
+ };
/**
* @description State of the sandbox
* @enum {string}
@@ -1743,6 +1788,39 @@ export interface components {
updatedAt: string;
};
TemplateBuild: {
+ /**
+ * Format: uuid
+ * @description Identifier of the build
+ */
+ buildID: string;
+ cpuCount: components["schemas"]["CPUCount"];
+ /**
+ * Format: date-time
+ * @description Time when the build was created
+ */
+ createdAt: string;
+ diskSizeMB?: components["schemas"]["DiskSizeMB"];
+ envdVersion?: components["schemas"]["EnvdVersion"];
+ /**
+ * Format: date-time
+ * @description Time when the build was finished
+ */
+ finishedAt?: string;
+ memoryMB: components["schemas"]["MemoryMB"];
+ status: components["schemas"]["TemplateBuildStatus"];
+ /**
+ * Format: date-time
+ * @description Time when the build was last updated
+ */
+ updatedAt: string;
+ };
+ TemplateBuildFileUpload: {
+ /** @description Whether the file is already present in the cache */
+ present: boolean;
+ /** @description Url where the file should be uploaded to */
+ url?: string;
+ };
+ TemplateBuildInfo: {
/** @description Identifier of the build */
buildID: string;
/**
@@ -1760,12 +1838,6 @@ export interface components {
/** @description Identifier of the template */
templateID: string;
};
- TemplateBuildFileUpload: {
- /** @description Whether the file is already present in the cache */
- present: boolean;
- /** @description Url where the file should be uploaded to */
- url?: string;
- };
TemplateBuildRequest: {
/** @description Alias of the template */
alias?: string;
@@ -1801,7 +1873,7 @@ export interface components {
* @description Whether the whole build should be forced to run regardless of the cache
* @default false
*/
- force: boolean;
+ force?: boolean;
/** @description Image to use as a base for the template build */
fromImage?: string;
fromImageRegistry?: components["schemas"]["FromImageRegistry"];
@@ -1815,7 +1887,7 @@ export interface components {
* @description List of steps to execute in the template build
* @default []
*/
- steps: components["schemas"]["TemplateStep"][];
+ steps?: components["schemas"]["TemplateStep"][];
};
/**
* @description Status of the template build
@@ -1878,14 +1950,14 @@ export interface components {
* @description Arguments for the step
* @default []
*/
- args: string[];
+ args?: string[];
/** @description Hash of the files used in the step */
filesHash?: string;
/**
* @description Whether the step should be forced to run regardless of the cache
* @default false
*/
- force: boolean;
+ force?: boolean;
/** @description Type of the step */
type: string;
};
@@ -1893,6 +1965,36 @@ export interface components {
/** @description Whether the template is public or only accessible by the team */
public?: boolean;
};
+ TemplateWithBuilds: {
+ /** @description Aliases of the template */
+ aliases: string[];
+ /** @description List of builds for the template */
+ builds: components["schemas"]["TemplateBuild"][];
+ /**
+ * Format: date-time
+ * @description Time when the template was created
+ */
+ createdAt: string;
+ /**
+ * Format: date-time
+ * @description Time when the template was last used
+ */
+ lastSpawnedAt: string | null;
+ /** @description Whether the template is public or only accessible by the team */
+ public: boolean;
+ /**
+ * Format: int64
+ * @description Number of times the template was used
+ */
+ spawnCount: number;
+ /** @description Identifier of the template */
+ templateID: string;
+ /**
+ * Format: date-time
+ * @description Time when the template was last updated
+ */
+ updatedAt: string;
+ };
UpdateTeamAPIKey: {
/** @description New name for the API key */
name: string;
@@ -1959,6 +2061,10 @@ export interface components {
apiKeyID: string;
buildID: string;
nodeID: string;
+ /** @description Maximum number of items to return per page */
+ paginationLimit: number;
+ /** @description Cursor to start the list from */
+ paginationNextToken: string;
sandboxID: string;
teamID: string;
templateID: string;
diff --git a/packages/js-sdk/src/index.ts b/packages/js-sdk/src/index.ts
index 8d1ca5694..61c13ac1a 100644
--- a/packages/js-sdk/src/index.ts
+++ b/packages/js-sdk/src/index.ts
@@ -46,10 +46,13 @@ export type {
SandboxState,
SandboxListOpts,
SandboxPaginator,
+ SandboxNetworkOpts,
} from './sandbox/sandboxApi'
export type { McpServer } from './sandbox/mcp'
+export { ALL_TRAFFIC } from './sandbox/network'
+
export type {
ProcessInfo,
CommandRequestOpts,
diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts
index 524bf3360..3c5f077bd 100644
--- a/packages/js-sdk/src/sandbox/index.ts
+++ b/packages/js-sdk/src/sandbox/index.ts
@@ -90,6 +90,11 @@ export class Sandbox extends SandboxApi {
*/
readonly sandboxDomain: string
+ /**
+ * Traffic access token for accessing sandbox services with restricted public traffic.
+ */
+ readonly trafficAccessToken?: string
+
protected readonly envdPort = 49983
protected readonly mcpPort = 50005
@@ -113,6 +118,7 @@ export class Sandbox extends SandboxApi {
sandboxDomain?: string
envdVersion: string
envdAccessToken?: string
+ trafficAccessToken?: string
}
) {
super()
@@ -123,6 +129,7 @@ export class Sandbox extends SandboxApi {
this.sandboxDomain = opts.sandboxDomain ?? this.connectionConfig.domain
this.envdAccessToken = opts.envdAccessToken
+ this.trafficAccessToken = opts.trafficAccessToken
this.envdApiUrl = this.connectionConfig.getSandboxUrl(this.sandboxId, {
sandboxDomain: this.sandboxDomain,
envdPort: this.envdPort,
@@ -420,6 +427,7 @@ export class Sandbox extends SandboxApi {
sandboxId,
sandboxDomain: sandbox.sandboxDomain,
envdAccessToken: sandbox.envdAccessToken,
+ trafficAccessToken: sandbox.trafficAccessToken,
envdVersion: sandbox.envdVersion,
...config,
}) as InstanceType<S>
diff --git a/packages/js-sdk/src/sandbox/network.ts b/packages/js-sdk/src/sandbox/network.ts
new file mode 100644
index 000000000..39314f808
--- /dev/null
+++ b/packages/js-sdk/src/sandbox/network.ts
@@ -0,0 +1,4 @@
+/**
+ * CIDR range that represents all traffic.
+ */
+export const ALL_TRAFFIC = '0.0.0.0/0'
diff --git a/packages/js-sdk/src/sandbox/sandboxApi.ts b/packages/js-sdk/src/sandbox/sandboxApi.ts
index 0c49d349b..54fcb7aa0 100644
--- a/packages/js-sdk/src/sandbox/sandboxApi.ts
+++ b/packages/js-sdk/src/sandbox/sandboxApi.ts
@@ -31,6 +31,39 @@ export type GitHubMcpServer = {
envs?: Record<string, string>
}
}
+
+export type SandboxNetworkOpts = {
+ /**
+ * Allow outbound traffic from the sandbox to the specified addresses.
+ * If `allowOut` is not specified, all outbound traffic is allowed.
+ *
+ * Examples:
+ * - To allow traffic to a specific addresses: `["1.1.1.1", "8.8.8.0/24"]`
+ */
+ allowOut?: string[]
+
+ /**
+ * Deny outbound traffic from the sandbox to the specified addresses.
+ *
+ * Examples:
+ * - To deny traffic to a specific addresses: `["1.1.1.1", "8.8.8.0/24"]`
+ */
+ denyOut?: string[]
+
+ /**
+ * Specify if the sandbox URLs should be accessible only with authentication.
+ * @default true
+ */
+ allowPublicTraffic?: boolean
+
+ /** Specify host mask which will be used for all sandbox requests in the header.
+ * You can use the ${PORT} variable that will be replaced with the actual port number of the service.
+ *
+ * @default ${PORT}-sandboxid.e2b.app
+ */
+ maskRequestHost?: string
+}
+
/**
* Options for request to the Sandbox API.
*/
@@ -79,7 +112,7 @@ export interface SandboxOpts extends ConnectionOpts {
secure?: boolean
/**
- * Allow sandbox to access the internet
+ * Allow sandbox to access the internet. If set to `False`, it works the same as setting network `denyOut` to `[0.0.0.0/0]`.
*
* @default true
*/
@@ -91,6 +124,11 @@ export interface SandboxOpts extends ConnectionOpts {
*/
mcp?: McpServer
+ /**
+ * Sandbox network configuration
+ */
+ network?: SandboxNetworkOpts
+
/**
* Sandbox URL. Used for local development
*/
@@ -504,6 +542,7 @@ export class SandboxApi {
timeout: timeoutToSeconds(timeoutMs),
secure: opts?.secure ?? true,
allow_internet_access: opts?.allowInternetAccess ?? true,
+ network: opts?.network,
},
signal: config.getSignal(opts?.requestTimeoutMs),
})
@@ -526,6 +565,7 @@ export class SandboxApi {
sandboxDomain: res.data!.domain || undefined,
envdVersion: res.data!.envdVersion,
envdAccessToken: res.data!.envdAccessToken,
+ trafficAccessToken: res.data!.trafficAccessToken || undefined,
}
}
@@ -564,6 +604,7 @@ export class SandboxApi {
sandboxDomain: res.data!.domain || undefined,
envdVersion: res.data!.envdVersion,
envdAccessToken: res.data!.envdAccessToken,
+ trafficAccessToken: res.data!.trafficAccessToken || undefined,
}
}
}
diff --git a/packages/js-sdk/tests/sandbox/network.test.ts b/packages/js-sdk/tests/sandbox/network.test.ts
new file mode 100644
index 000000000..c728b3f58
--- /dev/null
+++ b/packages/js-sdk/tests/sandbox/network.test.ts
@@ -0,0 +1,248 @@
+import { assert, expect, describe } from 'vitest'
+
+import { CommandExitError, ALL_TRAFFIC } from '../../src'
+import { sandboxTest, isDebug } from '../setup.js'
+
+describe('allow only 1.1.1.1', () => {
+ sandboxTest.scoped({
+ sandboxOpts: {
+ network: {
+ denyOut: [ALL_TRAFFIC],
+ allowOut: ['1.1.1.1'],
+ },
+ },
+ })
+
+ sandboxTest.skipIf(isDebug)(
+ 'allow specific IP with deny all traffic',
+ async ({ sandbox }) => {
+ // Test that allowed IP works
+ const result = await sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert.equal(result.exitCode, 0)
+ assert.equal(result.stdout.trim(), '301')
+
+ // Test that other IPs are denied
+ await expect(
+ sandbox.commands.run(
+ 'curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8'
+ )
+ ).rejects.toBeInstanceOf(CommandExitError)
+ }
+ )
+})
+
+describe('deny specific IP address', () => {
+ sandboxTest.scoped({
+ sandboxOpts: {
+ network: {
+ denyOut: ['8.8.8.8'],
+ },
+ },
+ })
+
+ sandboxTest.skipIf(isDebug)(
+ 'deny specific IP address',
+ async ({ sandbox }) => {
+ // Test that denied IP fails
+ await expect(
+ sandbox.commands.run(
+ 'curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8'
+ )
+ ).rejects.toBeInstanceOf(CommandExitError)
+
+ // Test that other IPs work
+ const result = await sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert.equal(result.exitCode, 0)
+ assert.equal(result.stdout.trim(), '301')
+ }
+ )
+})
+
+describe('deny all traffic using allTraffic helper', () => {
+ sandboxTest.scoped({
+ sandboxOpts: {
+ network: {
+ denyOut: [ALL_TRAFFIC],
+ },
+ },
+ })
+
+ sandboxTest.skipIf(isDebug)(
+ 'deny all traffic using allTraffic helper',
+ async ({ sandbox }) => {
+ // Test that all traffic is denied
+ await expect(
+ sandbox.commands.run(
+ 'curl --connect-timeout 3 --max-time 5 -Is https://1.1.1.1'
+ )
+ ).rejects.toBeInstanceOf(CommandExitError)
+
+ await expect(
+ sandbox.commands.run(
+ 'curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8'
+ )
+ ).rejects.toBeInstanceOf(CommandExitError)
+ }
+ )
+})
+
+describe('allow takes precedence over deny', () => {
+ sandboxTest.scoped({
+ sandboxOpts: {
+ network: {
+ denyOut: [ALL_TRAFFIC],
+ allowOut: ['1.1.1.1', '8.8.8.8'],
+ },
+ },
+ })
+
+ sandboxTest.skipIf(isDebug)(
+ 'allow takes precedence over deny',
+ async ({ sandbox }) => {
+ // Test that 1.1.1.1 works (explicitly allowed)
+ const result1 = await sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert.equal(result1.exitCode, 0)
+ assert.equal(result1.stdout.trim(), '301')
+
+ // Test that 8.8.8.8 also works (explicitly allowed, takes precedence over denyOut)
+ const result2 = await sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://8.8.8.8"
+ )
+ assert.equal(result2.exitCode, 0)
+ assert.equal(result2.stdout.trim(), '302')
+ }
+ )
+})
+
+describe('allowPublicTraffic=false', () => {
+ sandboxTest.scoped({
+ sandboxOpts: {
+ network: {
+ allowPublicTraffic: false,
+ },
+ },
+ })
+
+ sandboxTest.skipIf(isDebug)(
+ 'sandbox requires traffic access token',
+ async ({ sandbox }) => {
+ // Verify the sandbox was created successfully and has a traffic access token
+ assert(sandbox.trafficAccessToken)
+
+ // Start a simple HTTP server in the sandbox
+ const port = 8080
+ sandbox.commands.run(`python3 -m http.server ${port}`, {
+ background: true,
+ })
+
+ // Wait for server to start
+ await new Promise((resolve) => setTimeout(resolve, 3000))
+
+ // Get the public URL for the sandbox
+ const sandboxUrl = `https://${sandbox.getHost(port)}`
+
+ // Test 1: Request without traffic access token should fail with 403
+ const response1 = await fetch(sandboxUrl)
+ assert.equal(response1.status, 403)
+
+ // Test 2: Request with valid traffic access token should succeed
+ const response2 = await fetch(sandboxUrl, {
+ headers: {
+ 'e2b-traffic-access-token': sandbox.trafficAccessToken,
+ },
+ })
+ assert.equal(response2.status, 200)
+ }
+ )
+})
+
+describe('allowPublicTraffic=true', () => {
+ sandboxTest.scoped({
+ sandboxOpts: {
+ network: {
+ allowPublicTraffic: true,
+ },
+ },
+ })
+
+ sandboxTest.skipIf(isDebug)(
+ 'sandbox works without token',
+ async ({ sandbox }) => {
+ // Start a simple HTTP server in the sandbox
+ const port = 8080
+ sandbox.commands.run(`python3 -m http.server ${port}`, {
+ background: true,
+ })
+
+ // Wait for server to start
+ await new Promise((resolve) => setTimeout(resolve, 3000))
+
+ // Get the public URL for the sandbox
+ const sandboxUrl = `https://${sandbox.getHost(port)}`
+
+ // Request without traffic access token should succeed (public access enabled)
+ const response = await fetch(sandboxUrl)
+ assert.equal(response.status, 200)
+ }
+ )
+})
+
+describe('maskRequestHost option', () => {
+ sandboxTest.scoped({
+ sandboxOpts: {
+ network: {
+ maskRequestHost: 'custom-host.example.com:${PORT}',
+ },
+ },
+ })
+
+ sandboxTest.skipIf(isDebug)(
+ 'verify maskRequestHost modifies Host header correctly',
+ async ({ sandbox }) => {
+ // Install netcat for testing
+ await sandbox.commands.run('apt-get update', { user: 'root' })
+ await sandbox.commands.run('apt-get install -y netcat-traditional', {
+ user: 'root',
+ })
+
+ const port = 8080
+ const outputFile = '/tmp/nc_output.txt'
+
+ // Start netcat listener in background to capture request headers
+ sandbox.commands.run(`nc -l -p ${port} > ${outputFile}`, {
+ background: true,
+ user: 'root',
+ })
+
+ // Wait for netcat to start
+ await new Promise((resolve) => setTimeout(resolve, 3000))
+
+ // Get the public URL for the sandbox
+ const sandboxUrl = `https://${sandbox.getHost(port)}`
+
+ // Make a request from OUTSIDE the sandbox through the proxy
+ // The Host header should be modified according to maskRequestHost
+ try {
+ await fetch(sandboxUrl, { signal: AbortSignal.timeout(5000) })
+ } catch (error) {
+ // Request may fail since netcat doesn't respond properly, but headers are captured
+ }
+
+ // Read the captured output from inside the sandbox
+ const result = await sandbox.commands.run(`cat ${outputFile}`, {
+ user: 'root',
+ })
+
+ // Verify the Host header was modified according to maskRequestHost
+ assert.include(result.stdout, 'Host:')
+ assert.include(result.stdout, 'custom-host.example.com')
+ assert.include(result.stdout, `${port}`)
+ }
+ )
+})
diff --git a/packages/js-sdk/tests/setup.ts b/packages/js-sdk/tests/setup.ts
index 49fd8ef61..9928b3aa4 100644
--- a/packages/js-sdk/tests/setup.ts
+++ b/packages/js-sdk/tests/setup.ts
@@ -1,12 +1,20 @@
import { randomUUID } from 'node:crypto'
import { test as base } from 'vitest'
-import { BuildInfo, LogEntry, Sandbox, Template, TemplateClass } from '../src'
+import {
+ BuildInfo,
+ LogEntry,
+ Sandbox,
+ SandboxOpts,
+ Template,
+ TemplateClass,
+} from '../src'
import { template } from './template'
interface SandboxFixture {
sandbox: Sandbox
template: string
sandboxTestId: string
+ sandboxOpts: Partial<SandboxOpts>
}
interface BuildTemplateFixture {
@@ -41,10 +49,12 @@ export const sandboxTest = base.extend<SandboxFixture>({
},
{ auto: true },
],
+ sandboxOpts: {},
sandbox: [
- async ({ sandboxTestId }, use) => {
+ async ({ sandboxTestId, sandboxOpts }, use) => {
const sandbox = await Sandbox.create(template, {
metadata: { sandboxTestId },
+ ...sandboxOpts,
})
try {
await use(sandbox)
diff --git a/packages/python-sdk/e2b/__init__.py b/packages/python-sdk/e2b/__init__.py
index 4501d6660..0890278b3 100644
--- a/packages/python-sdk/e2b/__init__.py
+++ b/packages/python-sdk/e2b/__init__.py
@@ -34,38 +34,40 @@ from .connection_config import (
ProxyTypes,
)
from .exceptions import (
- SandboxException,
- TimeoutException,
- NotFoundException,
AuthenticationException,
+ BuildException,
+ FileUploadException,
InvalidArgumentException,
NotEnoughSpaceException,
+ NotFoundException,
+ SandboxException,
TemplateException,
- BuildException,
- FileUploadException,
+ TimeoutException,
)
from .sandbox.commands.command_handle import (
- CommandResult,
- Stderr,
- Stdout,
CommandExitException,
+ CommandResult,
PtyOutput,
PtySize,
+ Stderr,
+ Stdout,
)
from .sandbox.commands.main import ProcessInfo
-from .sandbox.filesystem.filesystem import EntryInfo, WriteInfo, FileType
+from .sandbox.filesystem.filesystem import EntryInfo, FileType, WriteInfo
from .sandbox.filesystem.watch_handle import (
FilesystemEvent,
FilesystemEventType,
)
+from .sandbox.network import ALL_TRAFFIC
from .sandbox.sandbox_api import (
+ GitHubMcpServer,
+ GitHubMcpServerConfig,
+ McpServer,
SandboxInfo,
+ SandboxMetrics,
+ SandboxNetworkOpts,
SandboxQuery,
SandboxState,
- SandboxMetrics,
- McpServer,
- GitHubMcpServer,
- GitHubMcpServerConfig,
)
from .sandbox_async.commands.command_handle import AsyncCommandHandle
from .sandbox_async.filesystem.watch_handle import AsyncWatchHandle
@@ -78,21 +80,21 @@ from .sandbox_sync.main import Sandbox
from .sandbox_sync.paginator import SandboxPaginator
from .template.logger import (
LogEntry,
+ LogEntryEnd,
LogEntryLevel,
LogEntryStart,
- LogEntryEnd,
default_build_logger,
)
from .template.main import TemplateBase, TemplateClass
from .template.readycmd import (
ReadyCmd,
wait_for_file,
- wait_for_url,
wait_for_port,
wait_for_process,
wait_for_timeout,
+ wait_for_url,
)
-from .template.types import CopyItem, BuildInfo
+from .template.types import BuildInfo, CopyItem
from .template_async.main import AsyncTemplate
from .template_sync.main import Template
@@ -133,6 +135,9 @@ __all__ = [
"EntryInfo",
"WriteInfo",
"FileType",
+ # Network
+ "SandboxNetworkOpts",
+ "ALL_TRAFFIC",
# Sync sandbox
"Sandbox",
"SandboxPaginator",
diff --git a/packages/python-sdk/e2b/api/__init__.py b/packages/python-sdk/e2b/api/__init__.py
index 44a1cc64e..4aed46582 100644
--- a/packages/python-sdk/e2b/api/__init__.py
+++ b/packages/python-sdk/e2b/api/__init__.py
@@ -1,20 +1,21 @@
-import os
-from types import TracebackType
import json
import logging
-from typing import Optional, Union
-from httpx import Limits, BaseTransport, AsyncBaseTransport
+import os
from dataclasses import dataclass
+from types import TracebackType
+from typing import Optional, Union
+
+from httpx import AsyncBaseTransport, BaseTransport, Limits
from e2b.api.client.client import AuthenticatedClient
-from e2b.connection_config import ConnectionConfig
+from e2b.api.client.types import Response
from e2b.api.metadata import default_headers
+from e2b.connection_config import ConnectionConfig
from e2b.exceptions import (
AuthenticationException,
- SandboxException,
RateLimitException,
+ SandboxException,
)
-from e2b.api.client.types import Response
logger = logging.getLogger(__name__)
@@ -31,6 +32,7 @@ class SandboxCreateResponse:
sandbox_domain: Optional[str]
envd_version: str
envd_access_token: str
+ traffic_access_token: Optional[str]
def handle_api_exception(
diff --git a/packages/python-sdk/e2b/api/client/api/templates/get_templates_template_id.py b/packages/python-sdk/e2b/api/client/api/templates/get_templates_template_id.py
new file mode 100644
index 000000000..875f9e945
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/api/templates/get_templates_template_id.py
@@ -0,0 +1,195 @@
+from http import HTTPStatus
+from typing import Any, Optional, Union
+
+import httpx
+
+from ... import errors
+from ...client import AuthenticatedClient, Client
+from ...models.error import Error
+from ...models.template_with_builds import TemplateWithBuilds
+from ...types import UNSET, Response, Unset
+
+
+def _get_kwargs(
+ template_id: str,
+ *,
+ next_token: Union[Unset, str] = UNSET,
+ limit: Union[Unset, int] = 100,
+) -> dict[str, Any]:
+ params: dict[str, Any] = {}
+
+ params["nextToken"] = next_token
+
+ params["limit"] = limit
+
+ params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
+
+ _kwargs: dict[str, Any] = {
+ "method": "get",
+ "url": f"/templates/{template_id}",
+ "params": params,
+ }
+
+ return _kwargs
+
+
+def _parse_response(
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
+) -> Optional[Union[Error, TemplateWithBuilds]]:
+ if response.status_code == 200:
+ response_200 = TemplateWithBuilds.from_dict(response.json())
+
+ return response_200
+ if response.status_code == 401:
+ response_401 = Error.from_dict(response.json())
+
+ return response_401
+ if response.status_code == 500:
+ response_500 = Error.from_dict(response.json())
+
+ return response_500
+ if client.raise_on_unexpected_status:
+ raise errors.UnexpectedStatus(response.status_code, response.content)
+ else:
+ return None
+
+
+def _build_response(
+ *, client: Union[AuthenticatedClient, Client], response: httpx.Response
+) -> Response[Union[Error, TemplateWithBuilds]]:
+ return Response(
+ status_code=HTTPStatus(response.status_code),
+ content=response.content,
+ headers=response.headers,
+ parsed=_parse_response(client=client, response=response),
+ )
+
+
+def sync_detailed(
+ template_id: str,
+ *,
+ client: AuthenticatedClient,
+ next_token: Union[Unset, str] = UNSET,
+ limit: Union[Unset, int] = 100,
+) -> Response[Union[Error, TemplateWithBuilds]]:
+ """List all builds for a template
+
+ Args:
+ template_id (str):
+ next_token (Union[Unset, str]):
+ limit (Union[Unset, int]): Default: 100.
+
+ Raises:
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
+
+ Returns:
+ Response[Union[Error, TemplateWithBuilds]]
+ """
+
+ kwargs = _get_kwargs(
+ template_id=template_id,
+ next_token=next_token,
+ limit=limit,
+ )
+
+ response = client.get_httpx_client().request(
+ **kwargs,
+ )
+
+ return _build_response(client=client, response=response)
+
+
+def sync(
+ template_id: str,
+ *,
+ client: AuthenticatedClient,
+ next_token: Union[Unset, str] = UNSET,
+ limit: Union[Unset, int] = 100,
+) -> Optional[Union[Error, TemplateWithBuilds]]:
+ """List all builds for a template
+
+ Args:
+ template_id (str):
+ next_token (Union[Unset, str]):
+ limit (Union[Unset, int]): Default: 100.
+
+ Raises:
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
+
+ Returns:
+ Union[Error, TemplateWithBuilds]
+ """
+
+ return sync_detailed(
+ template_id=template_id,
+ client=client,
+ next_token=next_token,
+ limit=limit,
+ ).parsed
+
+
+async def asyncio_detailed(
+ template_id: str,
+ *,
+ client: AuthenticatedClient,
+ next_token: Union[Unset, str] = UNSET,
+ limit: Union[Unset, int] = 100,
+) -> Response[Union[Error, TemplateWithBuilds]]:
+ """List all builds for a template
+
+ Args:
+ template_id (str):
+ next_token (Union[Unset, str]):
+ limit (Union[Unset, int]): Default: 100.
+
+ Raises:
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
+
+ Returns:
+ Response[Union[Error, TemplateWithBuilds]]
+ """
+
+ kwargs = _get_kwargs(
+ template_id=template_id,
+ next_token=next_token,
+ limit=limit,
+ )
+
+ response = await client.get_async_httpx_client().request(**kwargs)
+
+ return _build_response(client=client, response=response)
+
+
+async def asyncio(
+ template_id: str,
+ *,
+ client: AuthenticatedClient,
+ next_token: Union[Unset, str] = UNSET,
+ limit: Union[Unset, int] = 100,
+) -> Optional[Union[Error, TemplateWithBuilds]]:
+ """List all builds for a template
+
+ Args:
+ template_id (str):
+ next_token (Union[Unset, str]):
+ limit (Union[Unset, int]): Default: 100.
+
+ Raises:
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
+
+ Returns:
+ Union[Error, TemplateWithBuilds]
+ """
+
+ return (
+ await asyncio_detailed(
+ template_id=template_id,
+ client=client,
+ next_token=next_token,
+ limit=limit,
+ )
+ ).parsed
diff --git a/packages/python-sdk/e2b/api/client/api/templates/get_templates_template_id_builds_build_id_status.py b/packages/python-sdk/e2b/api/client/api/templates/get_templates_template_id_builds_build_id_status.py
index b233e7561..2fa0feed1 100644
--- a/packages/python-sdk/e2b/api/client/api/templates/get_templates_template_id_builds_build_id_status.py
+++ b/packages/python-sdk/e2b/api/client/api/templates/get_templates_template_id_builds_build_id_status.py
@@ -7,7 +7,7 @@ from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.log_level import LogLevel
-from ...models.template_build import TemplateBuild
+from ...models.template_build_info import TemplateBuildInfo
from ...types import UNSET, Response, Unset
@@ -41,9 +41,9 @@ def _get_kwargs(
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Optional[Union[Error, TemplateBuild]]:
+) -> Optional[Union[Error, TemplateBuildInfo]]:
if response.status_code == 200:
- response_200 = TemplateBuild.from_dict(response.json())
+ response_200 = TemplateBuildInfo.from_dict(response.json())
return response_200
if response.status_code == 401:
@@ -66,7 +66,7 @@ def _parse_response(
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
-) -> Response[Union[Error, TemplateBuild]]:
+) -> Response[Union[Error, TemplateBuildInfo]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
@@ -82,7 +82,7 @@ def sync_detailed(
client: AuthenticatedClient,
logs_offset: Union[Unset, int] = 0,
level: Union[Unset, LogLevel] = UNSET,
-) -> Response[Union[Error, TemplateBuild]]:
+) -> Response[Union[Error, TemplateBuildInfo]]:
"""Get template build info
Args:
@@ -96,7 +96,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, TemplateBuild]]
+ Response[Union[Error, TemplateBuildInfo]]
"""
kwargs = _get_kwargs(
@@ -120,7 +120,7 @@ def sync(
client: AuthenticatedClient,
logs_offset: Union[Unset, int] = 0,
level: Union[Unset, LogLevel] = UNSET,
-) -> Optional[Union[Error, TemplateBuild]]:
+) -> Optional[Union[Error, TemplateBuildInfo]]:
"""Get template build info
Args:
@@ -134,7 +134,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, TemplateBuild]
+ Union[Error, TemplateBuildInfo]
"""
return sync_detailed(
@@ -153,7 +153,7 @@ async def asyncio_detailed(
client: AuthenticatedClient,
logs_offset: Union[Unset, int] = 0,
level: Union[Unset, LogLevel] = UNSET,
-) -> Response[Union[Error, TemplateBuild]]:
+) -> Response[Union[Error, TemplateBuildInfo]]:
"""Get template build info
Args:
@@ -167,7 +167,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Response[Union[Error, TemplateBuild]]
+ Response[Union[Error, TemplateBuildInfo]]
"""
kwargs = _get_kwargs(
@@ -189,7 +189,7 @@ async def asyncio(
client: AuthenticatedClient,
logs_offset: Union[Unset, int] = 0,
level: Union[Unset, LogLevel] = UNSET,
-) -> Optional[Union[Error, TemplateBuild]]:
+) -> Optional[Union[Error, TemplateBuildInfo]]:
"""Get template build info
Args:
@@ -203,7 +203,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
- Union[Error, TemplateBuild]
+ Union[Error, TemplateBuildInfo]
"""
return (
diff --git a/packages/python-sdk/e2b/api/client/models/__init__.py b/packages/python-sdk/e2b/api/client/models/__init__.py
index 9fb84bf08..6c81cf276 100644
--- a/packages/python-sdk/e2b/api/client/models/__init__.py
+++ b/packages/python-sdk/e2b/api/client/models/__init__.py
@@ -38,6 +38,7 @@ from .sandbox_log_entry import SandboxLogEntry
from .sandbox_log_entry_fields import SandboxLogEntryFields
from .sandbox_logs import SandboxLogs
from .sandbox_metric import SandboxMetric
+from .sandbox_network_config import SandboxNetworkConfig
from .sandbox_state import SandboxState
from .sandboxes_with_metrics import SandboxesWithMetrics
from .team import Team
@@ -47,6 +48,7 @@ from .team_user import TeamUser
from .template import Template
from .template_build import TemplateBuild
from .template_build_file_upload import TemplateBuildFileUpload
+from .template_build_info import TemplateBuildInfo
from .template_build_request import TemplateBuildRequest
from .template_build_request_v2 import TemplateBuildRequestV2
from .template_build_request_v3 import TemplateBuildRequestV3
@@ -56,6 +58,7 @@ from .template_legacy import TemplateLegacy
from .template_request_response_v3 import TemplateRequestResponseV3
from .template_step import TemplateStep
from .template_update_request import TemplateUpdateRequest
+from .template_with_builds import TemplateWithBuilds
from .update_team_api_key import UpdateTeamAPIKey
__all__ = (
@@ -96,6 +99,7 @@ __all__ = (
"SandboxLogEntryFields",
"SandboxLogs",
"SandboxMetric",
+ "SandboxNetworkConfig",
"SandboxState",
"Team",
"TeamAPIKey",
@@ -104,6 +108,7 @@ __all__ = (
"Template",
"TemplateBuild",
"TemplateBuildFileUpload",
+ "TemplateBuildInfo",
"TemplateBuildRequest",
"TemplateBuildRequestV2",
"TemplateBuildRequestV3",
@@ -113,5 +118,6 @@ __all__ = (
"TemplateRequestResponseV3",
"TemplateStep",
"TemplateUpdateRequest",
+ "TemplateWithBuilds",
"UpdateTeamAPIKey",
)
diff --git a/packages/python-sdk/e2b/api/client/models/new_sandbox.py b/packages/python-sdk/e2b/api/client/models/new_sandbox.py
index 6044fe881..1f80c900c 100644
--- a/packages/python-sdk/e2b/api/client/models/new_sandbox.py
+++ b/packages/python-sdk/e2b/api/client/models/new_sandbox.py
@@ -8,6 +8,7 @@ from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.mcp_type_0 import McpType0
+ from ..models.sandbox_network_config import SandboxNetworkConfig
T = TypeVar("T", bound="NewSandbox")
@@ -18,11 +19,13 @@ class NewSandbox:
"""
Attributes:
template_id (str): Identifier of the required template
- allow_internet_access (Union[Unset, bool]): Allow sandbox to access the internet
+ allow_internet_access (Union[Unset, bool]): Allow sandbox to access the internet. When set to false, it behaves
+ the same as specifying denyOut to 0.0.0.0/0 in the network config.
auto_pause (Union[Unset, bool]): Automatically pauses the sandbox after the timeout Default: False.
env_vars (Union[Unset, Any]):
mcp (Union['McpType0', None, Unset]): MCP configuration for the sandbox
metadata (Union[Unset, Any]):
+ network (Union[Unset, SandboxNetworkConfig]):
secure (Union[Unset, bool]): Secure all system communication with sandbox
timeout (Union[Unset, int]): Time to live for the sandbox in seconds. Default: 15.
"""
@@ -33,6 +36,7 @@ class NewSandbox:
env_vars: Union[Unset, Any] = UNSET
mcp: Union["McpType0", None, Unset] = UNSET
metadata: Union[Unset, Any] = UNSET
+ network: Union[Unset, "SandboxNetworkConfig"] = UNSET
secure: Union[Unset, bool] = UNSET
timeout: Union[Unset, int] = 15
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
@@ -58,6 +62,10 @@ class NewSandbox:
metadata = self.metadata
+ network: Union[Unset, dict[str, Any]] = UNSET
+ if not isinstance(self.network, Unset):
+ network = self.network.to_dict()
+
secure = self.secure
timeout = self.timeout
@@ -79,6 +87,8 @@ class NewSandbox:
field_dict["mcp"] = mcp
if metadata is not UNSET:
field_dict["metadata"] = metadata
+ if network is not UNSET:
+ field_dict["network"] = network
if secure is not UNSET:
field_dict["secure"] = secure
if timeout is not UNSET:
@@ -89,6 +99,7 @@ class NewSandbox:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.mcp_type_0 import McpType0
+ from ..models.sandbox_network_config import SandboxNetworkConfig
d = dict(src_dict)
template_id = d.pop("templateID")
@@ -118,6 +129,13 @@ class NewSandbox:
metadata = d.pop("metadata", UNSET)
+ _network = d.pop("network", UNSET)
+ network: Union[Unset, SandboxNetworkConfig]
+ if isinstance(_network, Unset):
+ network = UNSET
+ else:
+ network = SandboxNetworkConfig.from_dict(_network)
+
secure = d.pop("secure", UNSET)
timeout = d.pop("timeout", UNSET)
@@ -129,6 +147,7 @@ class NewSandbox:
env_vars=env_vars,
mcp=mcp,
metadata=metadata,
+ network=network,
secure=secure,
timeout=timeout,
)
diff --git a/packages/python-sdk/e2b/api/client/models/sandbox.py b/packages/python-sdk/e2b/api/client/models/sandbox.py
index 7f3f9f54f..2eddc5f55 100644
--- a/packages/python-sdk/e2b/api/client/models/sandbox.py
+++ b/packages/python-sdk/e2b/api/client/models/sandbox.py
@@ -20,6 +20,7 @@ class Sandbox:
alias (Union[Unset, str]): Alias of the template
domain (Union[None, Unset, str]): Base domain where the sandbox traffic is accessible
envd_access_token (Union[Unset, str]): Access token used for envd communication
+ traffic_access_token (Union[None, Unset, str]): Token required for accessing sandbox via proxy.
"""
client_id: str
@@ -29,6 +30,7 @@ class Sandbox:
alias: Union[Unset, str] = UNSET
domain: Union[None, Unset, str] = UNSET
envd_access_token: Union[Unset, str] = UNSET
+ traffic_access_token: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
@@ -50,6 +52,12 @@ class Sandbox:
envd_access_token = self.envd_access_token
+ traffic_access_token: Union[None, Unset, str]
+ if isinstance(self.traffic_access_token, Unset):
+ traffic_access_token = UNSET
+ else:
+ traffic_access_token = self.traffic_access_token
+
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
@@ -66,6 +74,8 @@ class Sandbox:
field_dict["domain"] = domain
if envd_access_token is not UNSET:
field_dict["envdAccessToken"] = envd_access_token
+ if traffic_access_token is not UNSET:
+ field_dict["trafficAccessToken"] = traffic_access_token
return field_dict
@@ -93,6 +103,17 @@ class Sandbox:
envd_access_token = d.pop("envdAccessToken", UNSET)
+ def _parse_traffic_access_token(data: object) -> Union[None, Unset, str]:
+ if data is None:
+ return data
+ if isinstance(data, Unset):
+ return data
+ return cast(Union[None, Unset, str], data)
+
+ traffic_access_token = _parse_traffic_access_token(
+ d.pop("trafficAccessToken", UNSET)
+ )
+
sandbox = cls(
client_id=client_id,
envd_version=envd_version,
@@ -101,6 +122,7 @@ class Sandbox:
alias=alias,
domain=domain,
envd_access_token=envd_access_token,
+ traffic_access_token=traffic_access_token,
)
sandbox.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/sandbox_network_config.py b/packages/python-sdk/e2b/api/client/models/sandbox_network_config.py
new file mode 100644
index 000000000..08284c792
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/sandbox_network_config.py
@@ -0,0 +1,92 @@
+from collections.abc import Mapping
+from typing import Any, TypeVar, Union, cast
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+
+from ..types import UNSET, Unset
+
+T = TypeVar("T", bound="SandboxNetworkConfig")
+
+
+@_attrs_define
+class SandboxNetworkConfig:
+ """
+ Attributes:
+ allow_out (Union[Unset, list[str]]): List of allowed CIDR blocks or IP addresses for egress traffic. Allowed
+ addresses always take precedence over blocked addresses.
+ allow_public_traffic (Union[Unset, bool]): Specify if the sandbox URLs should be accessible only with
+ authentication. Default: True.
+ deny_out (Union[Unset, list[str]]): List of denied CIDR blocks or IP addresses for egress traffic
+ mask_request_host (Union[Unset, str]): Specify host mask which will be used for all sandbox requests
+ """
+
+ allow_out: Union[Unset, list[str]] = UNSET
+ allow_public_traffic: Union[Unset, bool] = True
+ deny_out: Union[Unset, list[str]] = UNSET
+ mask_request_host: Union[Unset, str] = UNSET
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ allow_out: Union[Unset, list[str]] = UNSET
+ if not isinstance(self.allow_out, Unset):
+ allow_out = self.allow_out
+
+ allow_public_traffic = self.allow_public_traffic
+
+ deny_out: Union[Unset, list[str]] = UNSET
+ if not isinstance(self.deny_out, Unset):
+ deny_out = self.deny_out
+
+ mask_request_host = self.mask_request_host
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update({})
+ if allow_out is not UNSET:
+ field_dict["allowOut"] = allow_out
+ if allow_public_traffic is not UNSET:
+ field_dict["allowPublicTraffic"] = allow_public_traffic
+ if deny_out is not UNSET:
+ field_dict["denyOut"] = deny_out
+ if mask_request_host is not UNSET:
+ field_dict["maskRequestHost"] = mask_request_host
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ allow_out = cast(list[str], d.pop("allowOut", UNSET))
+
+ allow_public_traffic = d.pop("allowPublicTraffic", UNSET)
+
+ deny_out = cast(list[str], d.pop("denyOut", UNSET))
+
+ mask_request_host = d.pop("maskRequestHost", UNSET)
+
+ sandbox_network_config = cls(
+ allow_out=allow_out,
+ allow_public_traffic=allow_public_traffic,
+ deny_out=deny_out,
+ mask_request_host=mask_request_host,
+ )
+
+ sandbox_network_config.additional_properties = d
+ return sandbox_network_config
+
+ @property
+ def additional_keys(self) -> list[str]:
+ return list(self.additional_properties.keys())
+
+ def __getitem__(self, key: str) -> Any:
+ return self.additional_properties[key]
+
+ def __setitem__(self, key: str, value: Any) -> None:
+ self.additional_properties[key] = value
+
+ def __delitem__(self, key: str) -> None:
+ del self.additional_properties[key]
+
+ def __contains__(self, key: str) -> bool:
+ return key in self.additional_properties
diff --git a/packages/python-sdk/e2b/api/client/models/template_build.py b/packages/python-sdk/e2b/api/client/models/template_build.py
index 157dea55d..f42a3f6fe 100644
--- a/packages/python-sdk/e2b/api/client/models/template_build.py
+++ b/packages/python-sdk/e2b/api/client/models/template_build.py
@@ -1,17 +1,15 @@
+import datetime
from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
+from typing import Any, TypeVar, Union
+from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
+from dateutil.parser import isoparse
from ..models.template_build_status import TemplateBuildStatus
from ..types import UNSET, Unset
-if TYPE_CHECKING:
- from ..models.build_log_entry import BuildLogEntry
- from ..models.build_status_reason import BuildStatusReason
-
-
T = TypeVar("T", bound="TemplateBuild")
@@ -19,91 +17,106 @@ T = TypeVar("T", bound="TemplateBuild")
class TemplateBuild:
"""
Attributes:
- build_id (str): Identifier of the build
- log_entries (list['BuildLogEntry']): Build logs structured
- logs (list[str]): Build logs
+ build_id (UUID): Identifier of the build
+ cpu_count (int): CPU cores for the sandbox
+ created_at (datetime.datetime): Time when the build was created
+ memory_mb (int): Memory for the sandbox in MiB
status (TemplateBuildStatus): Status of the template build
- template_id (str): Identifier of the template
- reason (Union[Unset, BuildStatusReason]):
+ updated_at (datetime.datetime): Time when the build was last updated
+ disk_size_mb (Union[Unset, int]): Disk size for the sandbox in MiB
+ envd_version (Union[Unset, str]): Version of the envd running in the sandbox
+ finished_at (Union[Unset, datetime.datetime]): Time when the build was finished
"""
- build_id: str
- log_entries: list["BuildLogEntry"]
- logs: list[str]
+ build_id: UUID
+ cpu_count: int
+ created_at: datetime.datetime
+ memory_mb: int
status: TemplateBuildStatus
- template_id: str
- reason: Union[Unset, "BuildStatusReason"] = UNSET
+ updated_at: datetime.datetime
+ disk_size_mb: Union[Unset, int] = UNSET
+ envd_version: Union[Unset, str] = UNSET
+ finished_at: Union[Unset, datetime.datetime] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
- build_id = self.build_id
+ build_id = str(self.build_id)
- log_entries = []
- for log_entries_item_data in self.log_entries:
- log_entries_item = log_entries_item_data.to_dict()
- log_entries.append(log_entries_item)
+ cpu_count = self.cpu_count
- logs = self.logs
+ created_at = self.created_at.isoformat()
+
+ memory_mb = self.memory_mb
status = self.status.value
- template_id = self.template_id
+ updated_at = self.updated_at.isoformat()
+
+ disk_size_mb = self.disk_size_mb
- reason: Union[Unset, dict[str, Any]] = UNSET
- if not isinstance(self.reason, Unset):
- reason = self.reason.to_dict()
+ envd_version = self.envd_version
+
+ finished_at: Union[Unset, str] = UNSET
+ if not isinstance(self.finished_at, Unset):
+ finished_at = self.finished_at.isoformat()
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"buildID": build_id,
- "logEntries": log_entries,
- "logs": logs,
+ "cpuCount": cpu_count,
+ "createdAt": created_at,
+ "memoryMB": memory_mb,
"status": status,
- "templateID": template_id,
+ "updatedAt": updated_at,
}
)
- if reason is not UNSET:
- field_dict["reason"] = reason
+ if disk_size_mb is not UNSET:
+ field_dict["diskSizeMB"] = disk_size_mb
+ if envd_version is not UNSET:
+ field_dict["envdVersion"] = envd_version
+ if finished_at is not UNSET:
+ field_dict["finishedAt"] = finished_at
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.build_log_entry import BuildLogEntry
- from ..models.build_status_reason import BuildStatusReason
-
d = dict(src_dict)
- build_id = d.pop("buildID")
+ build_id = UUID(d.pop("buildID"))
- log_entries = []
- _log_entries = d.pop("logEntries")
- for log_entries_item_data in _log_entries:
- log_entries_item = BuildLogEntry.from_dict(log_entries_item_data)
+ cpu_count = d.pop("cpuCount")
- log_entries.append(log_entries_item)
+ created_at = isoparse(d.pop("createdAt"))
- logs = cast(list[str], d.pop("logs"))
+ memory_mb = d.pop("memoryMB")
status = TemplateBuildStatus(d.pop("status"))
- template_id = d.pop("templateID")
+ updated_at = isoparse(d.pop("updatedAt"))
+
+ disk_size_mb = d.pop("diskSizeMB", UNSET)
+
+ envd_version = d.pop("envdVersion", UNSET)
- _reason = d.pop("reason", UNSET)
- reason: Union[Unset, BuildStatusReason]
- if isinstance(_reason, Unset):
- reason = UNSET
+ _finished_at = d.pop("finishedAt", UNSET)
+ finished_at: Union[Unset, datetime.datetime]
+ if isinstance(_finished_at, Unset):
+ finished_at = UNSET
else:
- reason = BuildStatusReason.from_dict(_reason)
+ finished_at = isoparse(_finished_at)
template_build = cls(
build_id=build_id,
- log_entries=log_entries,
- logs=logs,
+ cpu_count=cpu_count,
+ created_at=created_at,
+ memory_mb=memory_mb,
status=status,
- template_id=template_id,
- reason=reason,
+ updated_at=updated_at,
+ disk_size_mb=disk_size_mb,
+ envd_version=envd_version,
+ finished_at=finished_at,
)
template_build.additional_properties = d
diff --git a/packages/python-sdk/e2b/api/client/models/template_build_info.py b/packages/python-sdk/e2b/api/client/models/template_build_info.py
new file mode 100644
index 000000000..90b670c24
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/template_build_info.py
@@ -0,0 +1,126 @@
+from collections.abc import Mapping
+from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+
+from ..models.template_build_status import TemplateBuildStatus
+from ..types import UNSET, Unset
+
+if TYPE_CHECKING:
+ from ..models.build_log_entry import BuildLogEntry
+ from ..models.build_status_reason import BuildStatusReason
+
+
+T = TypeVar("T", bound="TemplateBuildInfo")
+
+
+@_attrs_define
+class TemplateBuildInfo:
+ """
+ Attributes:
+ build_id (str): Identifier of the build
+ log_entries (list['BuildLogEntry']): Build logs structured
+ logs (list[str]): Build logs
+ status (TemplateBuildStatus): Status of the template build
+ template_id (str): Identifier of the template
+ reason (Union[Unset, BuildStatusReason]):
+ """
+
+ build_id: str
+ log_entries: list["BuildLogEntry"]
+ logs: list[str]
+ status: TemplateBuildStatus
+ template_id: str
+ reason: Union[Unset, "BuildStatusReason"] = UNSET
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ build_id = self.build_id
+
+ log_entries = []
+ for log_entries_item_data in self.log_entries:
+ log_entries_item = log_entries_item_data.to_dict()
+ log_entries.append(log_entries_item)
+
+ logs = self.logs
+
+ status = self.status.value
+
+ template_id = self.template_id
+
+ reason: Union[Unset, dict[str, Any]] = UNSET
+ if not isinstance(self.reason, Unset):
+ reason = self.reason.to_dict()
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "buildID": build_id,
+ "logEntries": log_entries,
+ "logs": logs,
+ "status": status,
+ "templateID": template_id,
+ }
+ )
+ if reason is not UNSET:
+ field_dict["reason"] = reason
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.build_log_entry import BuildLogEntry
+ from ..models.build_status_reason import BuildStatusReason
+
+ d = dict(src_dict)
+ build_id = d.pop("buildID")
+
+ log_entries = []
+ _log_entries = d.pop("logEntries")
+ for log_entries_item_data in _log_entries:
+ log_entries_item = BuildLogEntry.from_dict(log_entries_item_data)
+
+ log_entries.append(log_entries_item)
+
+ logs = cast(list[str], d.pop("logs"))
+
+ status = TemplateBuildStatus(d.pop("status"))
+
+ template_id = d.pop("templateID")
+
+ _reason = d.pop("reason", UNSET)
+ reason: Union[Unset, BuildStatusReason]
+ if isinstance(_reason, Unset):
+ reason = UNSET
+ else:
+ reason = BuildStatusReason.from_dict(_reason)
+
+ template_build_info = cls(
+ build_id=build_id,
+ log_entries=log_entries,
+ logs=logs,
+ status=status,
+ template_id=template_id,
+ reason=reason,
+ )
+
+ template_build_info.additional_properties = d
+ return template_build_info
+
+ @property
+ def additional_keys(self) -> list[str]:
+ return list(self.additional_properties.keys())
+
+ def __getitem__(self, key: str) -> Any:
+ return self.additional_properties[key]
+
+ def __setitem__(self, key: str, value: Any) -> None:
+ self.additional_properties[key] = value
+
+ def __delitem__(self, key: str) -> None:
+ del self.additional_properties[key]
+
+ def __contains__(self, key: str) -> bool:
+ return key in self.additional_properties
diff --git a/packages/python-sdk/e2b/api/client/models/template_with_builds.py b/packages/python-sdk/e2b/api/client/models/template_with_builds.py
new file mode 100644
index 000000000..e047ce1a3
--- /dev/null
+++ b/packages/python-sdk/e2b/api/client/models/template_with_builds.py
@@ -0,0 +1,148 @@
+import datetime
+from collections.abc import Mapping
+from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
+
+from attrs import define as _attrs_define
+from attrs import field as _attrs_field
+from dateutil.parser import isoparse
+
+if TYPE_CHECKING:
+ from ..models.template_build import TemplateBuild
+
+
+T = TypeVar("T", bound="TemplateWithBuilds")
+
+
+@_attrs_define
+class TemplateWithBuilds:
+ """
+ Attributes:
+ aliases (list[str]): Aliases of the template
+ builds (list['TemplateBuild']): List of builds for the template
+ created_at (datetime.datetime): Time when the template was created
+ last_spawned_at (Union[None, datetime.datetime]): Time when the template was last used
+ public (bool): Whether the template is public or only accessible by the team
+ spawn_count (int): Number of times the template was used
+ template_id (str): Identifier of the template
+ updated_at (datetime.datetime): Time when the template was last updated
+ """
+
+ aliases: list[str]
+ builds: list["TemplateBuild"]
+ created_at: datetime.datetime
+ last_spawned_at: Union[None, datetime.datetime]
+ public: bool
+ spawn_count: int
+ template_id: str
+ updated_at: datetime.datetime
+ additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
+
+ def to_dict(self) -> dict[str, Any]:
+ aliases = self.aliases
+
+ builds = []
+ for builds_item_data in self.builds:
+ builds_item = builds_item_data.to_dict()
+ builds.append(builds_item)
+
+ created_at = self.created_at.isoformat()
+
+ last_spawned_at: Union[None, str]
+ if isinstance(self.last_spawned_at, datetime.datetime):
+ last_spawned_at = self.last_spawned_at.isoformat()
+ else:
+ last_spawned_at = self.last_spawned_at
+
+ public = self.public
+
+ spawn_count = self.spawn_count
+
+ template_id = self.template_id
+
+ updated_at = self.updated_at.isoformat()
+
+ field_dict: dict[str, Any] = {}
+ field_dict.update(self.additional_properties)
+ field_dict.update(
+ {
+ "aliases": aliases,
+ "builds": builds,
+ "createdAt": created_at,
+ "lastSpawnedAt": last_spawned_at,
+ "public": public,
+ "spawnCount": spawn_count,
+ "templateID": template_id,
+ "updatedAt": updated_at,
+ }
+ )
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.template_build import TemplateBuild
+
+ d = dict(src_dict)
+ aliases = cast(list[str], d.pop("aliases"))
+
+ builds = []
+ _builds = d.pop("builds")
+ for builds_item_data in _builds:
+ builds_item = TemplateBuild.from_dict(builds_item_data)
+
+ builds.append(builds_item)
+
+ created_at = isoparse(d.pop("createdAt"))
+
+ def _parse_last_spawned_at(data: object) -> Union[None, datetime.datetime]:
+ if data is None:
+ return data
+ try:
+ if not isinstance(data, str):
+ raise TypeError()
+ last_spawned_at_type_0 = isoparse(data)
+
+ return last_spawned_at_type_0
+ except: # noqa: E722
+ pass
+ return cast(Union[None, datetime.datetime], data)
+
+ last_spawned_at = _parse_last_spawned_at(d.pop("lastSpawnedAt"))
+
+ public = d.pop("public")
+
+ spawn_count = d.pop("spawnCount")
+
+ template_id = d.pop("templateID")
+
+ updated_at = isoparse(d.pop("updatedAt"))
+
+ template_with_builds = cls(
+ aliases=aliases,
+ builds=builds,
+ created_at=created_at,
+ last_spawned_at=last_spawned_at,
+ public=public,
+ spawn_count=spawn_count,
+ template_id=template_id,
+ updated_at=updated_at,
+ )
+
+ template_with_builds.additional_properties = d
+ return template_with_builds
+
+ @property
+ def additional_keys(self) -> list[str]:
+ return list(self.additional_properties.keys())
+
+ def __getitem__(self, key: str) -> Any:
+ return self.additional_properties[key]
+
+ def __setitem__(self, key: str, value: Any) -> None:
+ self.additional_properties[key] = value
+
+ def __delitem__(self, key: str) -> None:
+ del self.additional_properties[key]
+
+ def __contains__(self, key: str) -> bool:
+ return key in self.additional_properties
diff --git a/packages/python-sdk/e2b/sandbox/main.py b/packages/python-sdk/e2b/sandbox/main.py
index 6fa396042..cdfc63a1b 100644
--- a/packages/python-sdk/e2b/sandbox/main.py
+++ b/packages/python-sdk/e2b/sandbox/main.py
@@ -1,12 +1,12 @@
import urllib.parse
-from packaging.version import Version
-
from typing import Optional, TypedDict
-from e2b.sandbox.signature import get_signature
+from packaging.version import Version
+
from e2b.connection_config import ConnectionConfig, default_username
from e2b.envd.api import ENVD_API_FILES_ROUTE
from e2b.envd.versions import ENVD_DEFAULT_USER
+from e2b.sandbox.signature import get_signature
class SandboxOpts(TypedDict):
@@ -15,6 +15,7 @@ class SandboxOpts(TypedDict):
envd_version: Version
envd_access_token: Optional[str]
sandbox_url: Optional[str]
+ traffic_access_token: Optional[str]
connection_config: ConnectionConfig
@@ -33,12 +34,14 @@ class SandboxBase:
envd_access_token: Optional[str],
sandbox_domain: Optional[str],
connection_config: ConnectionConfig,
+ traffic_access_token: Optional[str] = None,
):
self.__connection_config = connection_config
self.__sandbox_id = sandbox_id
self.__sandbox_domain = sandbox_domain or self.connection_config.domain
self.__envd_version = envd_version
self.__envd_access_token = envd_access_token
+ self.__traffic_access_token = traffic_access_token
self.__envd_api_url = self.connection_config.get_sandbox_url(
self.sandbox_id, self.sandbox_domain
)
@@ -65,6 +68,10 @@ class SandboxBase:
def _envd_version(self) -> Version:
return self.__envd_version
+ @property
+ def traffic_access_token(self) -> Optional[str]:
+ return self.__traffic_access_token
+
@property
def sandbox_domain(self) -> Optional[str]:
return self.__sandbox_domain
diff --git a/packages/python-sdk/e2b/sandbox/network.py b/packages/python-sdk/e2b/sandbox/network.py
new file mode 100644
index 000000000..7041912a4
--- /dev/null
+++ b/packages/python-sdk/e2b/sandbox/network.py
@@ -0,0 +1,8 @@
+"""
+Network configuration helpers for E2B sandboxes.
+"""
+
+"""
+CIDR range that represents all traffic.
+"""
+ALL_TRAFFIC = "0.0.0.0/0"
diff --git a/packages/python-sdk/e2b/sandbox/sandbox_api.py b/packages/python-sdk/e2b/sandbox/sandbox_api.py
index bd8fcf1d4..3245a512f 100644
--- a/packages/python-sdk/e2b/sandbox/sandbox_api.py
+++ b/packages/python-sdk/e2b/sandbox/sandbox_api.py
@@ -1,10 +1,11 @@
from dataclasses import dataclass
-from typing import Optional, Dict, Union, Any, TypedDict
-from typing_extensions import Unpack, NotRequired
from datetime import datetime
+from typing import Any, Dict, List, Optional, TypedDict, Union
+
+from typing_extensions import NotRequired, Unpack
from e2b import ConnectionConfig
-from e2b.api.client.models import SandboxState, SandboxDetail, ListedSandbox
+from e2b.api.client.models import ListedSandbox, SandboxDetail, SandboxState
from e2b.connection_config import ApiParams
from e2b.sandbox.mcp import McpServer as BaseMcpServer
@@ -37,6 +38,44 @@ GitHubMcpServer = Dict[str, Union[GitHubMcpServerConfig, Any]]
McpServer = Union[BaseMcpServer, GitHubMcpServer]
+class SandboxNetworkOpts(TypedDict):
+ """
+ Sandbox network configuration options.
+ """
+
+ allow_out: NotRequired[List[str]]
+ """
+ Allow outbound traffic from the sandbox to the specified addresses.
+ If `allow_out` is not specified, all outbound traffic is allowed.
+
+ Examples:
+ - To allow traffic to specific addresses: `["1.1.1.1", "8.8.8.0/24"]`
+ """
+
+ deny_out: NotRequired[List[str]]
+ """
+ Deny outbound traffic from the sandbox to the specified addresses.
+
+ Examples:
+ - To deny traffic to specific addresses: `["1.1.1.1", "8.8.8.0/24"]`
+ """
+
+ allow_public_traffic: NotRequired[bool]
+ """
+ Controls whether sandbox URLs should be publicly accessible or require authentication.
+ Defaults to True.
+ """
+
+ mask_request_host: NotRequired[str]
+ """
+ Allows specifying a custom host mask for all sandbox requests.
+ Supports ${PORT} variable. Defaults to "${PORT}-sandboxid.e2b.app".
+
+ Examples:
+ - Custom subdomain: `"${PORT}-myapp.example.com"`
+ """
+
+
@dataclass
class SandboxInfo:
"""Information about a sandbox."""
diff --git a/packages/python-sdk/e2b/sandbox_async/main.py b/packages/python-sdk/e2b/sandbox_async/main.py
index 1a4600817..455315216 100644
--- a/packages/python-sdk/e2b/sandbox_async/main.py
+++ b/packages/python-sdk/e2b/sandbox_async/main.py
@@ -1,25 +1,24 @@
import datetime
+import json
import logging
-import httpx
import uuid
-import json
-
-from typing import Dict, Optional, overload, List
+from typing import Dict, List, Optional, overload
+import httpx
from packaging.version import Version
-from typing_extensions import Unpack, Self
+from typing_extensions import Self, Unpack
from e2b.api.client.types import Unset
-from e2b.connection_config import ConnectionConfig, ApiParams
+from e2b.connection_config import ApiParams, ConnectionConfig
from e2b.envd.api import ENVD_API_HEALTH_ROUTE, ahandle_envd_api_exception
from e2b.envd.versions import ENVD_DEBUG_FALLBACK
-from e2b.exceptions import format_request_timeout_error, SandboxException
+from e2b.exceptions import SandboxException, format_request_timeout_error
from e2b.sandbox.main import SandboxOpts
-from e2b.sandbox.sandbox_api import SandboxMetrics, McpServer
+from e2b.sandbox.sandbox_api import McpServer, SandboxMetrics, SandboxNetworkOpts
from e2b.sandbox.utils import class_method_variant
-from e2b.sandbox_async.filesystem.filesystem import Filesystem
from e2b.sandbox_async.commands.command import Commands
from e2b.sandbox_async.commands.pty import Pty
+from e2b.sandbox_async.filesystem.filesystem import Filesystem
from e2b.sandbox_async.sandbox_api import SandboxApi, SandboxInfo
from e2b.api.client_async import get_transport
@@ -153,6 +152,7 @@ class AsyncSandbox(SandboxApi):
secure: bool = True,
allow_internet_access: bool = True,
mcp: Optional[McpServer] = None,
+ network: Optional[SandboxNetworkOpts] = None,
**opts: Unpack[ApiParams],
) -> Self:
"""
@@ -165,8 +165,9 @@ class AsyncSandbox(SandboxApi):
:param metadata: Custom metadata for the sandbox
:param envs: Custom environment variables for the sandbox
:param secure: Envd is secured with access token and cannot be used without it, defaults to `True`.
- :param allow_internet_access: Allow sandbox to access the internet, defaults to `True`.
+ :param allow_internet_access: Allow sandbox to access the internet, defaults to `True`. If set to `False`, it works the same as setting network `deny_out` to `[0.0.0.0/0]`.
:param mcp: MCP server to enable in the sandbox
+ :param network: Sandbox network configuration
:return: A Sandbox instance for the new sandbox
@@ -186,6 +187,7 @@ class AsyncSandbox(SandboxApi):
secure=secure,
allow_internet_access=allow_internet_access,
mcp=mcp,
+ network=network,
**opts,
)
@@ -662,6 +664,7 @@ class AsyncSandbox(SandboxApi):
sandbox_domain=sandbox.domain,
envd_version=Version(sandbox.envd_version),
envd_access_token=envd_access_token,
+ traffic_access_token=sandbox.traffic_access_token,
connection_config=connection_config,
)
@@ -676,6 +679,7 @@ class AsyncSandbox(SandboxApi):
envs: Optional[Dict[str, str]],
secure: bool,
mcp: Optional[McpServer] = None,
+ network: Optional[SandboxNetworkOpts] = None,
**opts: Unpack[ApiParams],
) -> Self:
extra_sandbox_headers = {}
@@ -686,6 +690,7 @@ class AsyncSandbox(SandboxApi):
sandbox_domain = None
envd_version = ENVD_DEBUG_FALLBACK
envd_access_token = None
+ traffic_access_token = None
else:
response = await SandboxApi._create_sandbox(
template=template or cls.default_template,
@@ -696,6 +701,7 @@ class AsyncSandbox(SandboxApi):
secure=secure,
allow_internet_access=allow_internet_access,
mcp=mcp,
+ network=network,
**opts,
)
@@ -703,6 +709,7 @@ class AsyncSandbox(SandboxApi):
sandbox_domain = response.sandbox_domain
envd_version = Version(response.envd_version)
envd_access_token = response.envd_access_token
+ traffic_access_token = response.traffic_access_token
if envd_access_token is not None and not isinstance(
envd_access_token, Unset
@@ -722,5 +729,6 @@ class AsyncSandbox(SandboxApi):
sandbox_domain=sandbox_domain,
envd_version=envd_version,
envd_access_token=envd_access_token,
+ traffic_access_token=traffic_access_token,
connection_config=connection_config,
)
diff --git a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py
index 8aa92c2f5..763abee71 100644
--- a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py
+++ b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py
@@ -1,35 +1,40 @@
import datetime
-
-from typing import Optional, Dict, List
+from typing import Dict, List, Optional
from packaging.version import Version
from typing_extensions import Unpack
-from e2b.api.client.types import UNSET
-from e2b.sandbox.main import SandboxBase
-from e2b.sandbox.sandbox_api import SandboxInfo, SandboxMetrics, SandboxQuery, McpServer
-from e2b.exceptions import TemplateException, SandboxException, NotFoundException
-from e2b.api import SandboxCreateResponse
+from e2b.api import SandboxCreateResponse, handle_api_exception
+from e2b.api.client.api.sandboxes import (
+ delete_sandboxes_sandbox_id,
+ get_sandboxes_sandbox_id,
+ get_sandboxes_sandbox_id_metrics,
+ post_sandboxes,
+ post_sandboxes_sandbox_id_connect,
+ post_sandboxes_sandbox_id_pause,
+ post_sandboxes_sandbox_id_timeout,
+)
from e2b.api.client.models import (
+ ConnectSandbox,
+ Error,
NewSandbox,
PostSandboxesSandboxIDTimeoutBody,
- Error,
Sandbox,
- ConnectSandbox,
+ SandboxNetworkConfig,
)
-from e2b.api.client.api.sandboxes import (
- get_sandboxes_sandbox_id,
- post_sandboxes_sandbox_id_timeout,
- delete_sandboxes_sandbox_id,
- post_sandboxes,
- get_sandboxes_sandbox_id_metrics,
- post_sandboxes_sandbox_id_pause,
- post_sandboxes_sandbox_id_connect,
+from e2b.api.client.types import UNSET
+from e2b.api.client_async import get_api_client
+from e2b.connection_config import ApiParams, ConnectionConfig
+from e2b.exceptions import NotFoundException, SandboxException, TemplateException
+from e2b.sandbox.main import SandboxBase
+from e2b.sandbox.sandbox_api import (
+ McpServer,
+ SandboxInfo,
+ SandboxMetrics,
+ SandboxNetworkOpts,
+ SandboxQuery,
)
-from e2b.connection_config import ConnectionConfig, ApiParams
-from e2b.api import handle_api_exception
from e2b.sandbox_async.paginator import AsyncSandboxPaginator
-from e2b.api.client_async import get_api_client
class SandboxApi(SandboxBase):
@@ -153,6 +158,7 @@ class SandboxApi(SandboxBase):
env_vars: Optional[Dict[str, str]],
secure: bool,
mcp: Optional[McpServer] = None,
+ network: Optional[SandboxNetworkOpts] = None,
**opts: Unpack[ApiParams],
) -> SandboxCreateResponse:
config = ConnectionConfig(**opts)
@@ -168,6 +174,7 @@ class SandboxApi(SandboxBase):
mcp=mcp or UNSET,
secure=secure,
allow_internet_access=allow_internet_access,
+ network=SandboxNetworkConfig(**network) if network else UNSET,
),
client=api_client,
)
@@ -193,6 +200,7 @@ class SandboxApi(SandboxBase):
sandbox_domain=res.parsed.domain,
envd_version=res.parsed.envd_version,
envd_access_token=res.parsed.envd_access_token,
+ traffic_access_token=res.parsed.traffic_access_token,
)
@classmethod
diff --git a/packages/python-sdk/e2b/sandbox_sync/main.py b/packages/python-sdk/e2b/sandbox_sync/main.py
index 78be6052f..025838c1a 100644
--- a/packages/python-sdk/e2b/sandbox_sync/main.py
+++ b/packages/python-sdk/e2b/sandbox_sync/main.py
@@ -1,26 +1,24 @@
import datetime
+import json
import logging
import uuid
-import json
+from typing import Dict, List, Optional, overload
import httpx
-
-from typing import Dict, Optional, overload, List
-
from packaging.version import Version
-from typing_extensions import Unpack, Self
+from typing_extensions import Self, Unpack
from e2b.api.client.types import Unset
-from e2b.connection_config import ConnectionConfig, ApiParams
+from e2b.connection_config import ApiParams, ConnectionConfig
from e2b.envd.api import ENVD_API_HEALTH_ROUTE, handle_envd_api_exception
from e2b.envd.versions import ENVD_DEBUG_FALLBACK
from e2b.exceptions import SandboxException, format_request_timeout_error
from e2b.sandbox.main import SandboxOpts
-from e2b.sandbox.sandbox_api import SandboxMetrics, McpServer
+from e2b.sandbox.sandbox_api import McpServer, SandboxMetrics, SandboxNetworkOpts
from e2b.sandbox.utils import class_method_variant
-from e2b.sandbox_sync.filesystem.filesystem import Filesystem
from e2b.sandbox_sync.commands.command import Commands
from e2b.sandbox_sync.commands.pty import Pty
+from e2b.sandbox_sync.filesystem.filesystem import Filesystem
from e2b.sandbox_sync.sandbox_api import SandboxApi, SandboxInfo
from e2b.api.client_sync import get_transport
@@ -152,6 +150,7 @@ class Sandbox(SandboxApi):
secure: bool = True,
allow_internet_access: bool = True,
mcp: Optional[McpServer] = None,
+ network: Optional[SandboxNetworkOpts] = None,
**opts: Unpack[ApiParams],
) -> Self:
"""
@@ -164,8 +163,9 @@ class Sandbox(SandboxApi):
:param metadata: Custom metadata for the sandbox
:param envs: Custom environment variables for the sandbox
:param secure: Envd is secured with access token and cannot be used without it, defaults to `True`.
- :param allow_internet_access: Allow sandbox to access the internet, defaults to `True`.
+ :param allow_internet_access: Allow sandbox to access the internet, defaults to `True`. If set to `False`, it works the same as setting network `deny_out` to `[0.0.0.0/0]`.
:param mcp: MCP server to enable in the sandbox
+ :param network: Sandbox network configuration
:return: A Sandbox instance for the new sandbox
@@ -185,6 +185,7 @@ class Sandbox(SandboxApi):
secure=secure,
allow_internet_access=allow_internet_access,
mcp=mcp,
+ network=network,
**opts,
)
@@ -656,6 +657,7 @@ class Sandbox(SandboxApi):
connection_config=connection_config,
envd_version=Version(sandbox.envd_version),
envd_access_token=envd_access_token,
+ traffic_access_token=sandbox.traffic_access_token,
)
@classmethod
@@ -669,6 +671,7 @@ class Sandbox(SandboxApi):
secure: bool,
allow_internet_access: bool,
mcp: Optional[McpServer] = None,
+ network: Optional[SandboxNetworkOpts] = None,
**opts: Unpack[ApiParams],
) -> Self:
extra_sandbox_headers = {}
@@ -679,6 +682,7 @@ class Sandbox(SandboxApi):
sandbox_domain = None
envd_version = ENVD_DEBUG_FALLBACK
envd_access_token = None
+ traffic_access_token = None
else:
response = SandboxApi._create_sandbox(
template=template or cls.default_template,
@@ -689,6 +693,7 @@ class Sandbox(SandboxApi):
secure=secure,
allow_internet_access=allow_internet_access,
mcp=mcp,
+ network=network,
**opts,
)
@@ -696,6 +701,7 @@ class Sandbox(SandboxApi):
sandbox_domain = response.sandbox_domain
envd_version = Version(response.envd_version)
envd_access_token = response.envd_access_token
+ traffic_access_token = response.traffic_access_token
if envd_access_token is not None and not isinstance(
envd_access_token, Unset
@@ -715,5 +721,6 @@ class Sandbox(SandboxApi):
sandbox_domain=sandbox_domain,
envd_version=envd_version,
envd_access_token=envd_access_token,
+ traffic_access_token=traffic_access_token,
connection_config=connection_config,
)
diff --git a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py
index 269d72581..76e1a0f25 100644
--- a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py
+++ b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py
@@ -1,33 +1,38 @@
import datetime
-from typing import Optional, Dict, List
+from typing import Dict, List, Optional
from packaging.version import Version
from typing_extensions import Unpack
from e2b.api import SandboxCreateResponse, handle_api_exception
-from e2b.api.client.models import (
- Sandbox,
- ConnectSandbox,
-)
from e2b.api.client.api.sandboxes import (
- get_sandboxes_sandbox_id,
- post_sandboxes_sandbox_id_timeout,
delete_sandboxes_sandbox_id,
- post_sandboxes,
+ get_sandboxes_sandbox_id,
get_sandboxes_sandbox_id_metrics,
- post_sandboxes_sandbox_id_pause,
+ post_sandboxes,
post_sandboxes_sandbox_id_connect,
+ post_sandboxes_sandbox_id_pause,
+ post_sandboxes_sandbox_id_timeout,
)
from e2b.api.client.models import (
+ ConnectSandbox,
+ Error,
NewSandbox,
PostSandboxesSandboxIDTimeoutBody,
- Error,
+ Sandbox,
+ SandboxNetworkConfig,
)
from e2b.api.client.types import UNSET
-from e2b.connection_config import ConnectionConfig, ApiParams
-from e2b.exceptions import TemplateException, SandboxException, NotFoundException
+from e2b.connection_config import ApiParams, ConnectionConfig
+from e2b.exceptions import NotFoundException, SandboxException, TemplateException
from e2b.sandbox.main import SandboxBase
-from e2b.sandbox.sandbox_api import SandboxInfo, SandboxMetrics, SandboxQuery, McpServer
+from e2b.sandbox.sandbox_api import (
+ McpServer,
+ SandboxInfo,
+ SandboxMetrics,
+ SandboxNetworkOpts,
+ SandboxQuery,
+)
from e2b.sandbox_sync.paginator import SandboxPaginator, get_api_client
@@ -152,6 +157,7 @@ class SandboxApi(SandboxBase):
env_vars: Optional[Dict[str, str]],
secure: bool,
mcp: Optional[McpServer] = None,
+ network: Optional[SandboxNetworkOpts] = None,
**opts: Unpack[ApiParams],
) -> SandboxCreateResponse:
config = ConnectionConfig(**opts)
@@ -167,6 +173,7 @@ class SandboxApi(SandboxBase):
mcp=mcp or UNSET,
secure=secure,
allow_internet_access=allow_internet_access,
+ network=SandboxNetworkConfig(**network) if network else UNSET,
),
client=api_client,
)
@@ -192,6 +199,7 @@ class SandboxApi(SandboxBase):
sandbox_domain=res.parsed.domain,
envd_version=res.parsed.envd_version,
envd_access_token=res.parsed.envd_access_token,
+ traffic_access_token=res.parsed.traffic_access_token,
)
@classmethod
diff --git a/packages/python-sdk/e2b/template_async/main.py b/packages/python-sdk/e2b/template_async/main.py
index 809d0d804..52ecdcce2 100644
--- a/packages/python-sdk/e2b/template_async/main.py
+++ b/packages/python-sdk/e2b/template_async/main.py
@@ -9,6 +9,7 @@ from e2b.template.logger import LogEntry, LogEntryEnd, LogEntryStart
from e2b.template.main import TemplateBase, TemplateClass
from e2b.template.types import BuildInfo, InstructionType
from e2b.template.utils import read_dockerignore
+
from .build_api import (
get_build_status,
get_file_upload_link,
diff --git a/packages/python-sdk/tests/async/sandbox_async/test_network.py b/packages/python-sdk/tests/async/sandbox_async/test_network.py
new file mode 100644
index 000000000..1a7dd794a
--- /dev/null
+++ b/packages/python-sdk/tests/async/sandbox_async/test_network.py
@@ -0,0 +1,212 @@
+import pytest
+
+from e2b import ALL_TRAFFIC, SandboxNetworkOpts
+from e2b.sandbox.commands.command_handle import CommandExitException
+
+
+async def test_allow_specific_ip_with_deny_all(async_sandbox_factory):
+ """Test that sandbox with denyOut all and allowOut creates a whitelist."""
+ async_sandbox = await async_sandbox_factory(
+ network=SandboxNetworkOpts(deny_out=[ALL_TRAFFIC], allow_out=["1.1.1.1"])
+ )
+
+ # Test that allowed IP works
+ result = await async_sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert result.exit_code == 0
+ assert result.stdout.strip() == "301"
+
+ # Test that other IPs are denied
+ with pytest.raises(CommandExitException) as exc_info:
+ await async_sandbox.commands.run(
+ "curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8"
+ )
+ assert exc_info.value.exit_code != 0
+
+
+async def test_deny_specific_ip(async_sandbox_factory):
+ """Test that sandbox with denyOut denies specified IP addresses."""
+ async_sandbox = await async_sandbox_factory(
+ network=SandboxNetworkOpts(deny_out=["8.8.8.8"])
+ )
+
+ # Test that denied IP fails
+ with pytest.raises(CommandExitException) as exc_info:
+ await async_sandbox.commands.run(
+ "curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8"
+ )
+ assert exc_info.value.exit_code != 0
+
+ # Test that other IPs work
+ result = await async_sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert result.exit_code == 0
+ assert result.stdout.strip() == "301"
+
+
+async def test_deny_all_traffic(async_sandbox_factory):
+ """Test that sandbox can deny all traffic using all_traffic helper."""
+ async_sandbox = await async_sandbox_factory(
+ network=SandboxNetworkOpts(deny_out=[ALL_TRAFFIC]), timeout=30
+ )
+
+ # Test that all traffic is denied
+ with pytest.raises(CommandExitException) as exc_info:
+ await async_sandbox.commands.run(
+ "curl --connect-timeout 3 --max-time 5 -Is https://1.1.1.1"
+ )
+ assert exc_info.value.exit_code != 0
+
+ with pytest.raises(CommandExitException) as exc_info:
+ await async_sandbox.commands.run(
+ "curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8"
+ )
+ assert exc_info.value.exit_code != 0
+
+
+async def test_allow_takes_precedence_over_deny(async_sandbox_factory):
+ """Test that allowOut takes precedence over denyOut."""
+ async_sandbox = await async_sandbox_factory(
+ network=SandboxNetworkOpts(
+ deny_out=[ALL_TRAFFIC], allow_out=["1.1.1.1", "8.8.8.8"]
+ )
+ )
+
+ # Test that 1.1.1.1 works (explicitly allowed)
+ result1 = await async_sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert result1.exit_code == 0
+ assert result1.stdout.strip() == "301"
+
+ # Test that 8.8.8.8 also works (explicitly allowed, takes precedence over deny_out)
+ result2 = await async_sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://8.8.8.8"
+ )
+ assert result2.exit_code == 0
+ assert result2.stdout.strip() == "302"
+
+
+async def test_allow_public_traffic_false(async_sandbox_factory):
+ """Test that sandbox with allow_public_traffic=False requires traffic access token."""
+ async_sandbox = await async_sandbox_factory(
+ secure=True, network=SandboxNetworkOpts(allow_public_traffic=False)
+ )
+
+ import asyncio
+
+ import httpx
+
+ # Verify the sandbox was created successfully and has a traffic access token
+ assert async_sandbox.traffic_access_token is not None
+
+ # Start a simple HTTP server in the sandbox
+ port = 8080
+ await async_sandbox.commands.run(
+ f"python3 -m http.server {port}", background=True, timeout=0
+ )
+
+ # Wait for server to start
+ await asyncio.sleep(3)
+
+ # Get the public URL for the sandbox
+ sandbox_url = f"https://{async_sandbox.get_host(port)}"
+
+ async with httpx.AsyncClient() as client:
+ # Test 1: Request without traffic access token should fail with 403
+ response = await client.get(sandbox_url, follow_redirects=True)
+ assert response.status_code == 403
+
+ # Test 2: Request with valid traffic access token should succeed
+ headers = {"e2b-traffic-access-token": async_sandbox.traffic_access_token}
+ response = await client.get(sandbox_url, headers=headers, follow_redirects=True)
+ assert response.status_code == 200
+
+
+async def test_allow_public_traffic_true(async_sandbox_factory):
+ """Test that sandbox with allow_public_traffic=True works without token."""
+ async_sandbox = await async_sandbox_factory(
+ network=SandboxNetworkOpts(allow_public_traffic=True)
+ )
+
+ import asyncio
+
+ import httpx
+
+ # Start a simple HTTP server in the sandbox
+ port = 8080
+ await async_sandbox.commands.run(
+ f"python3 -m http.server {port}", background=True, timeout=0
+ )
+
+ # Wait for server to start
+ await asyncio.sleep(3)
+
+ # Get the public URL for the sandbox
+ sandbox_url = f"https://{async_sandbox.get_host(port)}"
+
+ async with httpx.AsyncClient() as client:
+ # Request without traffic access token should succeed (public access enabled)
+ response = await client.get(sandbox_url, follow_redirects=True)
+ assert response.status_code == 200
+
+
+async def test_mask_request_host(async_sandbox_factory):
+ """Test that mask_request_host modifies the Host header correctly."""
+ async_sandbox = await async_sandbox_factory(
+ network=SandboxNetworkOpts(mask_request_host="custom-host.example.com:${PORT}"),
+ timeout=60,
+ )
+
+ import asyncio
+
+ import httpx
+
+ # Install netcat for testing
+ await async_sandbox.commands.run("apt-get update", user="root")
+ await async_sandbox.commands.run(
+ "apt-get install -y netcat-traditional", user="root"
+ )
+
+ port = 8080
+ output_file = "/tmp/nc_output.txt"
+
+ # Start netcat listener in background to capture request headers
+ await async_sandbox.commands.run(
+ f"nc -l -p {port} > {output_file}",
+ background=True,
+ timeout=0,
+ user="root",
+ )
+
+ # Wait for netcat to start
+ await asyncio.sleep(3)
+
+ # Get the public URL for the sandbox
+ sandbox_url = f"https://{async_sandbox.get_host(port)}"
+
+ # Make a request from OUTSIDE the sandbox through the proxy
+ # The Host header should be modified according to mask_request_host
+ async with httpx.AsyncClient() as client:
+ try:
+ await client.get(sandbox_url, timeout=5.0)
+ except Exception:
+ # Request may fail since netcat doesn't respond properly, but headers are captured
+ pass
+
+ # Read the captured output from inside the sandbox
+ result = await async_sandbox.commands.run(f"cat {output_file}", user="root")
+
+ # Verify the Host header was modified according to mask_request_host
+ assert "Host:" in result.stdout
+ assert "custom-host.example.com" in result.stdout
+ assert str(port) in result.stdout
diff --git a/packages/python-sdk/tests/conftest.py b/packages/python-sdk/tests/conftest.py
index 97e54eed2..a6be393fa 100644
--- a/packages/python-sdk/tests/conftest.py
+++ b/packages/python-sdk/tests/conftest.py
@@ -1,22 +1,22 @@
import asyncio
-from typing import Callable, Optional
+import os
import uuid
+from typing import Callable, Optional
+from uuid import uuid4
import pytest
import pytest_asyncio
-import os
-from uuid import uuid4
from e2b import (
- Sandbox,
- AsyncSandbox,
AsyncCommandHandle,
+ AsyncSandbox,
+ AsyncTemplate,
CommandExitException,
CommandHandle,
- AsyncTemplate,
+ LogEntry,
+ Sandbox,
Template,
TemplateClass,
- LogEntry,
)
diff --git a/packages/python-sdk/tests/sync/sandbox_sync/test_network.py b/packages/python-sdk/tests/sync/sandbox_sync/test_network.py
new file mode 100644
index 000000000..6e93f1368
--- /dev/null
+++ b/packages/python-sdk/tests/sync/sandbox_sync/test_network.py
@@ -0,0 +1,207 @@
+import pytest
+
+from e2b import ALL_TRAFFIC, SandboxNetworkOpts
+from e2b.sandbox.commands.command_handle import CommandExitException
+
+
+def test_allow_specific_ip_with_deny_all(sandbox_factory):
+ """Test that sandbox with denyOut all and allowOut creates a whitelist."""
+ sandbox = sandbox_factory(
+ network=SandboxNetworkOpts(deny_out=[ALL_TRAFFIC], allow_out=["1.1.1.1"])
+ )
+
+ # Test that allowed IP works
+ result = sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert result.exit_code == 0
+ assert result.stdout.strip() == "301"
+
+ # Test that other IPs are denied
+ with pytest.raises(CommandExitException) as exc_info:
+ sandbox.commands.run(
+ "curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8"
+ )
+ assert exc_info.value.exit_code != 0
+
+
+def test_deny_specific_ip(sandbox_factory):
+ """Test that sandbox with denyOut denies specified IP addresses."""
+ sandbox = sandbox_factory(network=SandboxNetworkOpts(deny_out=["8.8.8.8"]))
+
+ # Test that denied IP fails
+ with pytest.raises(CommandExitException) as exc_info:
+ sandbox.commands.run(
+ "curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8"
+ )
+ assert exc_info.value.exit_code != 0
+
+ # Test that other IPs work
+ result = sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert result.exit_code == 0
+ assert result.stdout.strip() == "301"
+
+
+def test_deny_all_traffic(sandbox_factory):
+ """Test that sandbox can deny all traffic using all_traffic helper."""
+ sandbox = sandbox_factory(
+ network=SandboxNetworkOpts(deny_out=[ALL_TRAFFIC]), timeout=30
+ )
+
+ # Test that all traffic is denied
+ with pytest.raises(CommandExitException) as exc_info:
+ sandbox.commands.run(
+ "curl --connect-timeout 3 --max-time 5 -Is https://1.1.1.1"
+ )
+ assert exc_info.value.exit_code != 0
+
+ with pytest.raises(CommandExitException) as exc_info:
+ sandbox.commands.run(
+ "curl --connect-timeout 3 --max-time 5 -Is https://8.8.8.8"
+ )
+ assert exc_info.value.exit_code != 0
+
+
+def test_allow_takes_precedence_over_deny(sandbox_factory):
+ """Test that allowOut takes precedence over denyOut."""
+ sandbox = sandbox_factory(
+ network=SandboxNetworkOpts(
+ deny_out=[ALL_TRAFFIC], allow_out=["1.1.1.1", "8.8.8.8"]
+ )
+ )
+
+ # Test that 1.1.1.1 works (explicitly allowed)
+ result1 = sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://1.1.1.1"
+ )
+ assert result1.exit_code == 0
+ assert result1.stdout.strip() == "301"
+
+ # Test that 8.8.8.8 also works (explicitly allowed, takes precedence over deny_out)
+ result2 = sandbox.commands.run(
+ "curl -s -o /dev/null -w '%{http_code}' https://8.8.8.8"
+ )
+ assert result2.exit_code == 0
+ assert result2.stdout.strip() == "302"
+
+
+def test_allow_public_traffic_false(sandbox_factory):
+ """Test that sandbox with allow_public_traffic=False requires traffic access token."""
+ sandbox = sandbox_factory(
+ secure=True, network=SandboxNetworkOpts(allow_public_traffic=False)
+ )
+
+ import time
+
+ import httpx
+
+ # Verify the sandbox was created successfully and has a traffic access token
+ assert sandbox.traffic_access_token is not None
+
+ # Start a simple HTTP server in the sandbox
+ port = 8080
+ sandbox.commands.run(
+ f"python3 -m http.server {port}",
+ background=True,
+ )
+
+ # Wait for server to start
+ time.sleep(3)
+
+ # Get the public URL for the sandbox
+ sandbox_url = f"https://{sandbox.get_host(port)}"
+
+ with httpx.Client() as client:
+ # Test 1: Request without traffic access token should fail with 403
+ response = client.get(sandbox_url, follow_redirects=True)
+ assert response.status_code == 403
+
+ # Test 2: Request with valid traffic access token should succeed
+ headers = {"e2b-traffic-access-token": sandbox.traffic_access_token}
+ response = client.get(sandbox_url, headers=headers, follow_redirects=True)
+ assert response.status_code == 200
+
+
+def test_allow_public_traffic_true(sandbox_factory):
+ """Test that sandbox with allow_public_traffic=True works without token."""
+ sandbox = sandbox_factory(network=SandboxNetworkOpts(allow_public_traffic=True))
+
+ import time
+
+ import httpx
+
+ # Start a simple HTTP server in the sandbox
+ port = 8080
+ sandbox.commands.run(
+ f"python3 -m http.server {port}",
+ background=True,
+ )
+
+ # Wait for server to start
+ time.sleep(3)
+
+ # Get the public URL for the sandbox
+ sandbox_url = f"https://{sandbox.get_host(port)}"
+
+ with httpx.Client() as client:
+ # Request without traffic access token should succeed (public access enabled)
+ response = client.get(sandbox_url, follow_redirects=True)
+ assert response.status_code == 200
+
+
+def test_mask_request_host(sandbox_factory):
+ """Test that mask_request_host modifies the Host header correctly."""
+ sandbox = sandbox_factory(
+ network=SandboxNetworkOpts(mask_request_host="custom-host.example.com:${PORT}"),
+ timeout=60,
+ )
+
+ import time
+
+ import httpx
+
+ # Install netcat for testing
+ sandbox.commands.run("apt-get update", user="root")
+ sandbox.commands.run("apt-get install -y netcat-traditional", user="root")
+
+ port = 8080
+ output_file = "/tmp/nc_output.txt"
+
+ # Start netcat listener in background to capture request headers
+ sandbox.commands.run(
+ f"nc -l -p {port} > {output_file}",
+ background=True,
+ user="root",
+ )
+
+ # Wait for netcat to start
+ time.sleep(3)
+
+ # Get the public URL for the sandbox
+ sandbox_url = f"https://{sandbox.get_host(port)}"
+
+ # Make a request from OUTSIDE the sandbox through the proxy
+ # The Host header should be modified according to mask_request_host
+ with httpx.Client() as client:
+ try:
+ client.get(sandbox_url, timeout=5.0)
+ except Exception:
+ # Request may fail since netcat doesn't respond properly, but headers are captured
+ pass
+
+ # Read the captured output from inside the sandbox
+ result = sandbox.commands.run(f"cat {output_file}", user="root")
+
+ # Verify the Host header was modified according to mask_request_host
+ assert "Host:" in result.stdout
+ assert "custom-host.example.com" in result.stdout
+ assert str(port) in result.stdout
diff --git a/spec/openapi.yml b/spec/openapi.yml
index 10a6870a3..e05bf641f 100644
--- a/spec/openapi.yml
+++ b/spec/openapi.yml
@@ -75,44 +75,62 @@ components:
required: true
schema:
type: string
+ paginationLimit:
+ name: limit
+ in: query
+ description: Maximum number of items to return per page
+ required: false
+ schema:
+ type: integer
+ format: int32
+ minimum: 1
+ default: 100
+ maximum: 100
+ paginationNextToken:
+ name: nextToken
+ in: query
+ description: Cursor to start the list from
+ required: false
+ schema:
+ type: string
responses:
- "400":
+ '400':
description: Bad request
content:
application/json:
schema:
- $ref: "#/components/schemas/Error"
- "401":
+ $ref: '#/components/schemas/Error'
+ '401':
description: Authentication error
content:
application/json:
schema:
- $ref: "#/components/schemas/Error"
- "403":
+ $ref: '#/components/schemas/Error'
+ '403':
description: Forbidden
content:
application/json:
schema:
- $ref: "#/components/schemas/Error"
- "404":
+ $ref: '#/components/schemas/Error'
+ '404':
description: Not found
content:
application/json:
schema:
- $ref: "#/components/schemas/Error"
- "409":
+ $ref: '#/components/schemas/Error'
+ '409':
description: Conflict
content:
application/json:
schema:
- $ref: "#/components/schemas/Error"
- "500":
+ $ref: '#/components/schemas/Error'
+ '500':
description: Server error
content:
application/json:
schema:
- $ref: "#/components/schemas/Error"
+ $ref: '#/components/schemas/Error'
schemas:
Team:
@@ -199,6 +217,27 @@ components:
additionalProperties: {}
nullable: true
+ SandboxNetworkConfig:
+ type: object
+ properties:
+ allowPublicTraffic:
+ type: boolean
+ default: true
+ description: Specify if the sandbox URLs should be accessible only with authentication.
+ allowOut:
+ type: array
+ description: List of allowed CIDR blocks or IP addresses for egress traffic. Allowed addresses always take precedence over blocked addresses.
+ items:
+ type: string
+ denyOut:
+ type: array
+ description: List of denied CIDR blocks or IP addresses for egress traffic
+ items:
+ type: string
+ maskRequestHost:
+ type: string
+ description: Specify host mask which will be used for all sandbox requests
+
SandboxLog:
description: Log entry with timestamp and line
required:
@@ -228,7 +267,7 @@ components:
type: string
description: Log message content
level:
- $ref: "#/components/schemas/LogLevel"
+ $ref: '#/components/schemas/LogLevel'
fields:
type: object
additionalProperties:
@@ -243,12 +282,12 @@ components:
description: Logs of the sandbox
type: array
items:
- $ref: "#/components/schemas/SandboxLog"
+ $ref: '#/components/schemas/SandboxLog'
logEntries:
description: Structured logs of the sandbox
type: array
items:
- $ref: "#/components/schemas/SandboxLogEntry"
+ $ref: '#/components/schemas/SandboxLogEntry'
SandboxMetric:
description: Metric entry with timestamp and line
@@ -317,10 +356,14 @@ components:
deprecated: true
description: Identifier of the client
envdVersion:
- $ref: "#/components/schemas/EnvdVersion"
+ $ref: '#/components/schemas/EnvdVersion'
envdAccessToken:
type: string
description: Access token used for envd communication
+ trafficAccessToken:
+ type: string
+ nullable: true
+ description: Token required for accessing sandbox via proxy.
domain:
type: string
nullable: true
@@ -361,7 +404,7 @@ components:
format: date-time
description: Time when the sandbox will expire
envdVersion:
- $ref: "#/components/schemas/EnvdVersion"
+ $ref: '#/components/schemas/EnvdVersion'
envdAccessToken:
type: string
description: Access token used for envd communication
@@ -370,15 +413,15 @@ components:
nullable: true
description: Base domain where the sandbox traffic is accessible
cpuCount:
- $ref: "#/components/schemas/CPUCount"
+ $ref: '#/components/schemas/CPUCount'
memoryMB:
- $ref: "#/components/schemas/MemoryMB"
+ $ref: '#/components/schemas/MemoryMB'
diskSizeMB:
- $ref: "#/components/schemas/DiskSizeMB"
+ $ref: '#/components/schemas/DiskSizeMB'
metadata:
- $ref: "#/components/schemas/SandboxMetadata"
+ $ref: '#/components/schemas/SandboxMetadata'
state:
- $ref: "#/components/schemas/SandboxState"
+ $ref: '#/components/schemas/SandboxState'
ListedSandbox:
required:
@@ -415,17 +458,17 @@ components:
format: date-time
description: Time when the sandbox will expire
cpuCount:
- $ref: "#/components/schemas/CPUCount"
+ $ref: '#/components/schemas/CPUCount'
memoryMB:
- $ref: "#/components/schemas/MemoryMB"
+ $ref: '#/components/schemas/MemoryMB'
diskSizeMB:
- $ref: "#/components/schemas/DiskSizeMB"
+ $ref: '#/components/schemas/DiskSizeMB'
metadata:
- $ref: "#/components/schemas/SandboxMetadata"
+ $ref: '#/components/schemas/SandboxMetadata'
state:
- $ref: "#/components/schemas/SandboxState"
+ $ref: '#/components/schemas/SandboxState'
envdVersion:
- $ref: "#/components/schemas/EnvdVersion"
+ $ref: '#/components/schemas/EnvdVersion'
SandboxesWithMetrics:
required:
@@ -433,7 +476,7 @@ components:
properties:
sandboxes:
additionalProperties:
- $ref: "#/components/schemas/SandboxMetric"
+ $ref: '#/components/schemas/SandboxMetric'
NewSandbox:
required:
@@ -457,13 +500,17 @@ components:
description: Secure all system communication with sandbox
allow_internet_access:
type: boolean
- description: Allow sandbox to access the internet
+ description:
+ Allow sandbox to access the internet. When set to false, it behaves the same as specifying denyOut
+ to 0.0.0.0/0 in the network config.
+ network:
+ $ref: '#/components/schemas/SandboxNetworkConfig'
metadata:
- $ref: "#/components/schemas/SandboxMetadata"
+ $ref: '#/components/schemas/SandboxMetadata'
envVars:
- $ref: "#/components/schemas/EnvVars"
+ $ref: '#/components/schemas/EnvVars'
mcp:
- $ref: "#/components/schemas/Mcp"
+ $ref: '#/components/schemas/Mcp'
ResumedSandbox:
properties:
@@ -560,11 +607,11 @@ components:
type: string
description: Identifier of the last successful build for given template
cpuCount:
- $ref: "#/components/schemas/CPUCount"
+ $ref: '#/components/schemas/CPUCount'
memoryMB:
- $ref: "#/components/schemas/MemoryMB"
+ $ref: '#/components/schemas/MemoryMB'
diskSizeMB:
- $ref: "#/components/schemas/DiskSizeMB"
+ $ref: '#/components/schemas/DiskSizeMB'
public:
type: boolean
description: Whether the template is public or only accessible by the team
@@ -583,7 +630,7 @@ components:
description: Time when the template was last updated
createdBy:
allOf:
- - $ref: "#/components/schemas/TeamUser"
+ - $ref: '#/components/schemas/TeamUser'
nullable: true
lastSpawnedAt:
type: string
@@ -599,9 +646,9 @@ components:
format: int32
description: Number of times the template was built
envdVersion:
- $ref: "#/components/schemas/EnvdVersion"
+ $ref: '#/components/schemas/EnvdVersion'
buildStatus:
- $ref: "#/components/schemas/TemplateBuildStatus"
+ $ref: '#/components/schemas/TemplateBuildStatus'
TemplateRequestResponseV3:
required:
@@ -649,11 +696,11 @@ components:
type: string
description: Identifier of the last successful build for given template
cpuCount:
- $ref: "#/components/schemas/CPUCount"
+ $ref: '#/components/schemas/CPUCount'
memoryMB:
- $ref: "#/components/schemas/MemoryMB"
+ $ref: '#/components/schemas/MemoryMB'
diskSizeMB:
- $ref: "#/components/schemas/DiskSizeMB"
+ $ref: '#/components/schemas/DiskSizeMB'
public:
type: boolean
description: Whether the template is public or only accessible by the team
@@ -672,7 +719,7 @@ components:
description: Time when the template was last updated
createdBy:
allOf:
- - $ref: "#/components/schemas/TeamUser"
+ - $ref: '#/components/schemas/TeamUser'
nullable: true
lastSpawnedAt:
type: string
@@ -688,7 +735,88 @@ components:
format: int32
description: Number of times the template was built
envdVersion:
- $ref: "#/components/schemas/EnvdVersion"
+ $ref: '#/components/schemas/EnvdVersion'
+
+ TemplateBuild:
+ required:
+ - buildID
+ - status
+ - createdAt
+ - updatedAt
+ - cpuCount
+ - memoryMB
+ properties:
+ buildID:
+ type: string
+ format: uuid
+ description: Identifier of the build
+ status:
+ $ref: '#/components/schemas/TemplateBuildStatus'
+ createdAt:
+ type: string
+ format: date-time
+ description: Time when the build was created
+ updatedAt:
+ type: string
+ format: date-time
+ description: Time when the build was last updated
+ finishedAt:
+ type: string
+ format: date-time
+ description: Time when the build was finished
+ cpuCount:
+ $ref: '#/components/schemas/CPUCount'
+ memoryMB:
+ $ref: '#/components/schemas/MemoryMB'
+ diskSizeMB:
+ $ref: '#/components/schemas/DiskSizeMB'
+ envdVersion:
+ $ref: '#/components/schemas/EnvdVersion'
+
+ TemplateWithBuilds:
+ required:
+ - templateID
+ - public
+ - aliases
+ - createdAt
+ - updatedAt
+ - lastSpawnedAt
+ - spawnCount
+ - builds
+ properties:
+ templateID:
+ type: string
+ description: Identifier of the template
+ public:
+ type: boolean
+ description: Whether the template is public or only accessible by the team
+ aliases:
+ type: array
+ description: Aliases of the template
+ items:
+ type: string
+ createdAt:
+ type: string
+ format: date-time
+ description: Time when the template was created
+ updatedAt:
+ type: string
+ format: date-time
+ description: Time when the template was last updated
+ lastSpawnedAt:
+ type: string
+ nullable: true
+ format: date-time
+ description: Time when the template was last used
+ spawnCount:
+ type: integer
+ format: int64
+ description: Number of times the template was used
+ builds:
+ type: array
+ description: List of builds for the template
+ items:
+ $ref: '#/components/schemas/TemplateBuild'
TemplateBuildRequest:
required:
@@ -710,9 +838,9 @@ components:
description: Ready check command to execute in the template after the build
type: string
cpuCount:
- $ref: "#/components/schemas/CPUCount"
+ $ref: '#/components/schemas/CPUCount'
memoryMB:
- $ref: "#/components/schemas/MemoryMB"
+ $ref: '#/components/schemas/MemoryMB'
TemplateStep:
description: Step in the template build process
@@ -747,9 +875,9 @@ components:
type: string
description: Identifier of the team
cpuCount:
- $ref: "#/components/schemas/CPUCount"
+ $ref: '#/components/schemas/CPUCount'
memoryMB:
- $ref: "#/components/schemas/MemoryMB"
+ $ref: '#/components/schemas/MemoryMB'
TemplateBuildRequestV2:
required:
@@ -762,21 +890,21 @@ components:
type: string
description: Identifier of the team
cpuCount:
- $ref: "#/components/schemas/CPUCount"
+ $ref: '#/components/schemas/CPUCount'
memoryMB:
- $ref: "#/components/schemas/MemoryMB"
+ $ref: '#/components/schemas/MemoryMB'
FromImageRegistry:
oneOf:
- - $ref: "#/components/schemas/AWSRegistry"
- - $ref: "#/components/schemas/GCPRegistry"
- - $ref: "#/components/schemas/GeneralRegistry"
+ - $ref: '#/components/schemas/AWSRegistry'
+ - $ref: '#/components/schemas/GCPRegistry'
+ - $ref: '#/components/schemas/GeneralRegistry'
discriminator:
propertyName: type
mapping:
- aws: "#/components/schemas/AWSRegistry"
- gcp: "#/components/schemas/GCPRegistry"
- registry: "#/components/schemas/GeneralRegistry"
+ aws: '#/components/schemas/AWSRegistry'
+ gcp: '#/components/schemas/GCPRegistry'
+ registry: '#/components/schemas/GeneralRegistry'
AWSRegistry:
type: object
@@ -842,7 +970,7 @@ components:
type: string
description: Template to use as a base for the template build
fromImageRegistry:
- $ref: "#/components/schemas/FromImageRegistry"
+ $ref: '#/components/schemas/FromImageRegistry'
force:
default: false
type: boolean
@@ -852,7 +980,7 @@ components:
description: List of steps to execute in the template build
type: array
items:
- $ref: "#/components/schemas/TemplateStep"
+ $ref: '#/components/schemas/TemplateStep'
startCmd:
description: Start command to execute in the template after the build
type: string
@@ -894,7 +1022,7 @@ components:
type: string
description: Log message content
level:
- $ref: "#/components/schemas/LogLevel"
+ $ref: '#/components/schemas/LogLevel'
step:
type: string
description: Step in the build process related to the log entry
@@ -914,7 +1042,7 @@ components:
description: Log entries related to the status reason
type: array
items:
- $ref: "#/components/schemas/BuildLogEntry"
+ $ref: '#/components/schemas/BuildLogEntry'
TemplateBuildStatus:
type: string
@@ -925,7 +1053,7 @@ components:
- ready
- error
- TemplateBuild:
+ TemplateBuildInfo:
required:
- templateID
- buildID
@@ -944,7 +1072,7 @@ components:
description: Build logs structured
type: array
items:
- $ref: "#/components/schemas/BuildLogEntry"
+ $ref: '#/components/schemas/BuildLogEntry'
templateID:
type: string
description: Identifier of the template
@@ -952,9 +1080,9 @@ components:
type: string
description: Identifier of the build
status:
- $ref: "#/components/schemas/TemplateBuildStatus"
+ $ref: '#/components/schemas/TemplateBuildStatus'
reason:
- $ref: "#/components/schemas/BuildStatusReason"
+ $ref: '#/components/schemas/BuildStatusReason'
NodeStatus:
type: string
@@ -979,7 +1107,7 @@ components:
format: uuid
description: Identifier of the cluster
status:
- $ref: "#/components/schemas/NodeStatus"
+ $ref: '#/components/schemas/NodeStatus'
DiskMetrics:
required:
@@ -1046,7 +1174,7 @@ components:
type: array
description: Detailed metrics for each disk/mount point
items:
- $ref: "#/components/schemas/DiskMetrics"
+ $ref: '#/components/schemas/DiskMetrics'
Node:
required:
@@ -1083,13 +1211,13 @@ components:
type: string
description: Identifier of the cluster
status:
- $ref: "#/components/schemas/NodeStatus"
+ $ref: '#/components/schemas/NodeStatus'
sandboxCount:
type: integer
format: uint32
description: Number of sandboxes running on the node
metrics:
- $ref: "#/components/schemas/NodeMetrics"
+ $ref: '#/components/schemas/NodeMetrics'
createSuccesses:
type: integer
format: uint64
@@ -1138,14 +1266,14 @@ components:
deprecated: true
description: Identifier of the nomad node
status:
- $ref: "#/components/schemas/NodeStatus"
+ $ref: '#/components/schemas/NodeStatus'
sandboxes:
type: array
description: List of sandboxes running on the node
items:
- $ref: "#/components/schemas/ListedSandbox"
+ $ref: '#/components/schemas/ListedSandbox'
metrics:
- $ref: "#/components/schemas/NodeMetrics"
+ $ref: '#/components/schemas/NodeMetrics'
cachedBuilds:
type: array
description: List of cached builds id on the node
@@ -1179,7 +1307,7 @@ components:
type: string
description: The fully created access token
mask:
- $ref: "#/components/schemas/IdentifierMaskingDetails"
+ $ref: '#/components/schemas/IdentifierMaskingDetails'
createdAt:
type: string
format: date-time
@@ -1208,14 +1336,14 @@ components:
type: string
description: Name of the API key
mask:
- $ref: "#/components/schemas/IdentifierMaskingDetails"
+ $ref: '#/components/schemas/IdentifierMaskingDetails'
createdAt:
type: string
format: date-time
description: Timestamp of API key creation
createdBy:
allOf:
- - $ref: "#/components/schemas/TeamUser"
+ - $ref: '#/components/schemas/TeamUser'
nullable: true
lastUsed:
type: string
@@ -1239,7 +1367,7 @@ components:
type: string
description: Raw value of the API key
mask:
- $ref: "#/components/schemas/IdentifierMaskingDetails"
+ $ref: '#/components/schemas/IdentifierMaskingDetails'
name:
type: string
description: Name of the API key
@@ -1249,7 +1377,7 @@ components:
description: Timestamp of API key creation
createdBy:
allOf:
- - $ref: "#/components/schemas/TeamUser"
+ - $ref: '#/components/schemas/TeamUser'
nullable: true
lastUsed:
type: string
@@ -1318,10 +1446,10 @@ paths:
get:
description: Health check
responses:
- "200":
+ '200':
description: Request was successful
- "401":
- $ref: "#/components/responses/401"
+ '401':
+ $ref: '#/components/responses/401'
/teams:
get:
@@ -1331,7 +1459,7 @@ paths:
- AccessTokenAuth: []
- Supabase1TokenAuth: []
responses:
- "200":
+ '200':
description: Successfully returned all teams
content:
application/json:
@@ -1339,11 +1467,11 @@ paths:
type: array
items:
allOf:
- - $ref: "#/components/schemas/Team"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ - $ref: '#/components/schemas/Team'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/teams/{teamID}/metrics:
get:
@@ -1354,7 +1482,7 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/teamID"
+ - $ref: '#/components/parameters/teamID'
- in: query
name: start
schema:
@@ -1370,22 +1498,22 @@ paths:
minimum: 0
description: Unix timestamp for the end of the interval, in seconds, for which the metrics
responses:
- "200":
+ '200':
description: Successfully returned the team metrics
content:
application/json:
schema:
type: array
items:
- $ref: "#/components/schemas/TeamMetric"
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "403":
- $ref: "#/components/responses/403"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/TeamMetric'
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '403':
+ $ref: '#/components/responses/403'
+ '500':
+ $ref: '#/components/responses/500'
/teams/{teamID}/metrics/max:
get:
@@ -1396,7 +1524,7 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/teamID"
+ - $ref: '#/components/parameters/teamID'
- in: query
name: start
schema:
@@ -1419,20 +1547,20 @@ paths:
enum: [concurrent_sandboxes, sandbox_start_rate]
description: Metric to retrieve the maximum value for
responses:
- "200":
+ '200':
description: Successfully returned the team metrics
content:
application/json:
schema:
- $ref: "#/components/schemas/MaxTeamMetric"
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "403":
- $ref: "#/components/responses/403"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/MaxTeamMetric'
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '403':
+ $ref: '#/components/responses/403'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes:
get:
@@ -1450,7 +1578,7 @@ paths:
schema:
type: string
responses:
- "200":
+ '200':
description: Successfully returned all running sandboxes
content:
application/json:
@@ -1458,13 +1586,13 @@ paths:
type: array
items:
allOf:
- - $ref: "#/components/schemas/ListedSandbox"
- "401":
- $ref: "#/components/responses/401"
- "400":
- $ref: "#/components/responses/400"
- "500":
- $ref: "#/components/responses/500"
+ - $ref: '#/components/schemas/ListedSandbox'
+ '401':
+ $ref: '#/components/responses/401'
+ '400':
+ $ref: '#/components/responses/400'
+ '500':
+ $ref: '#/components/responses/500'
post:
description: Create a sandbox from the template
tags: [sandboxes]
@@ -1477,20 +1605,20 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/NewSandbox"
+ $ref: '#/components/schemas/NewSandbox'
responses:
- "201":
+ '201':
description: The sandbox was created successfully
content:
application/json:
schema:
- $ref: "#/components/schemas/Sandbox"
- "401":
- $ref: "#/components/responses/401"
- "400":
- $ref: "#/components/responses/400"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/Sandbox'
+ '401':
+ $ref: '#/components/responses/401'
+ '400':
+ $ref: '#/components/responses/400'
+ '500':
+ $ref: '#/components/responses/500'
/v2/sandboxes:
get:
@@ -1514,26 +1642,13 @@ paths:
schema:
type: array
items:
- $ref: "#/components/schemas/SandboxState"
+ $ref: '#/components/schemas/SandboxState'
style: form
explode: false
- - name: nextToken
- in: query
- description: Cursor to start the list from
- required: false
- schema:
- type: string
- - name: limit
- in: query
- description: Maximum number of items to return per page
- required: false
- schema:
- type: integer
- format: int32
- minimum: 1
- default: 100
+ - $ref: '#/components/parameters/paginationNextToken'
+ - $ref: '#/components/parameters/paginationLimit'
responses:
- "200":
+ '200':
description: Successfully returned all running sandboxes
content:
application/json:
@@ -1541,13 +1656,13 @@ paths:
type: array
items:
allOf:
- - $ref: "#/components/schemas/ListedSandbox"
- "401":
- $ref: "#/components/responses/401"
- "400":
- $ref: "#/components/responses/400"
- "500":
- $ref: "#/components/responses/500"
+ - $ref: '#/components/schemas/ListedSandbox'
+ '401':
+ $ref: '#/components/responses/401'
+ '400':
+ $ref: '#/components/responses/400'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes/metrics:
get:
@@ -1570,18 +1685,18 @@ paths:
maxItems: 100
uniqueItems: true
responses:
- "200":
+ '200':
description: Successfully returned all running sandboxes with metrics
content:
application/json:
schema:
- $ref: "#/components/schemas/SandboxesWithMetrics"
- "401":
- $ref: "#/components/responses/401"
- "400":
- $ref: "#/components/responses/400"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/SandboxesWithMetrics'
+ '401':
+ $ref: '#/components/responses/401'
+ '400':
+ $ref: '#/components/responses/400'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes/{sandboxID}/logs:
get:
@@ -1592,7 +1707,7 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
- in: query
name: start
schema:
@@ -1609,18 +1724,18 @@ paths:
type: integer
description: Maximum number of logs that should be returned
responses:
- "200":
+ '200':
description: Successfully returned the sandbox logs
content:
application/json:
schema:
- $ref: "#/components/schemas/SandboxLogs"
- "404":
- $ref: "#/components/responses/404"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/SandboxLogs'
+ '404':
+ $ref: '#/components/responses/404'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes/{sandboxID}:
get:
@@ -1631,20 +1746,20 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
responses:
- "200":
+ '200':
description: Successfully returned the sandbox
content:
application/json:
schema:
- $ref: "#/components/schemas/SandboxDetail"
- "404":
- $ref: "#/components/responses/404"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/SandboxDetail'
+ '404':
+ $ref: '#/components/responses/404'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
delete:
description: Kill a sandbox
@@ -1654,16 +1769,16 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
responses:
- "204":
+ '204':
description: The sandbox was killed successfully
- "404":
- $ref: "#/components/responses/404"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ '404':
+ $ref: '#/components/responses/404'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes/{sandboxID}/metrics:
get:
@@ -1674,7 +1789,7 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
- in: query
name: start
schema:
@@ -1691,22 +1806,22 @@ paths:
description: Unix timestamp for the end of the interval, in seconds, for which the metrics
responses:
- "200":
+ '200':
description: Successfully returned the sandbox metrics
content:
application/json:
schema:
type: array
items:
- $ref: "#/components/schemas/SandboxMetric"
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/SandboxMetric'
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
# TODO: Pause and resume might be exposed as POST /sandboxes/{sandboxID}/snapshot and then POST /sandboxes with specified snapshotting setup
/sandboxes/{sandboxID}/pause:
@@ -1718,18 +1833,18 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
responses:
- "204":
+ '204':
description: The sandbox was paused successfully and can be resumed
- "409":
- $ref: "#/components/responses/409"
- "404":
- $ref: "#/components/responses/404"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ '409':
+ $ref: '#/components/responses/409'
+ '404':
+ $ref: '#/components/responses/404'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes/{sandboxID}/resume:
post:
@@ -1741,28 +1856,28 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
requestBody:
required: true
content:
application/json:
schema:
- $ref: "#/components/schemas/ResumedSandbox"
+ $ref: '#/components/schemas/ResumedSandbox'
responses:
- "201":
+ '201':
description: The sandbox was resumed successfully
content:
application/json:
schema:
- $ref: "#/components/schemas/Sandbox"
- "409":
- $ref: "#/components/responses/409"
- "404":
- $ref: "#/components/responses/404"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/Sandbox'
+ '409':
+ $ref: '#/components/responses/409'
+ '404':
+ $ref: '#/components/responses/404'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes/{sandboxID}/connect:
post:
@@ -1773,34 +1888,34 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
requestBody:
required: true
content:
application/json:
schema:
- $ref: "#/components/schemas/ConnectSandbox"
+ $ref: '#/components/schemas/ConnectSandbox'
responses:
- "200":
+ '200':
description: The sandbox was already running
content:
application/json:
schema:
- $ref: "#/components/schemas/Sandbox"
- "201":
+ $ref: '#/components/schemas/Sandbox'
+ '201':
description: The sandbox was resumed successfully
content:
application/json:
schema:
- $ref: "#/components/schemas/Sandbox"
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/Sandbox'
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes/{sandboxID}/timeout:
post:
@@ -1824,16 +1939,16 @@ paths:
format: int32
minimum: 0
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
responses:
- "204":
+ '204':
description: Successfully set the sandbox timeout
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
/sandboxes/{sandboxID}/refreshes:
post:
@@ -1855,14 +1970,14 @@ paths:
maximum: 3600 # 1 hour
minimum: 0
parameters:
- - $ref: "#/components/parameters/sandboxID"
+ - $ref: '#/components/parameters/sandboxID'
responses:
- "204":
+ '204':
description: Successfully refreshed the sandbox
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
/v3/templates:
post:
@@ -1876,21 +1991,21 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateBuildRequestV3"
+ $ref: '#/components/schemas/TemplateBuildRequestV3'
responses:
- "202":
+ '202':
description: The build was requested successfully
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateRequestResponseV3"
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/TemplateRequestResponseV3'
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/v2/templates:
post:
@@ -1905,21 +2020,21 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateBuildRequestV2"
+ $ref: '#/components/schemas/TemplateBuildRequestV2'
responses:
- "202":
+ '202':
description: The build was requested successfully
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateLegacy"
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/TemplateLegacy'
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/templates/{templateID}/files/{hash}:
get:
@@ -1930,7 +2045,7 @@ paths:
- ApiKeyAuth: []
- Supabase1TokenAuth: []
parameters:
- - $ref: "#/components/parameters/templateID"
+ - $ref: '#/components/parameters/templateID'
- in: path
name: hash
required: true
@@ -1939,20 +2054,20 @@ paths:
description: Hash of the files
responses:
- "201":
+ '201':
description: The upload link where to upload the tar file
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateBuildFileUpload"
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/TemplateBuildFileUpload'
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
/templates:
get:
@@ -1970,7 +2085,7 @@ paths:
type: string
description: Identifier of the team
responses:
- "200":
+ '200':
description: Successfully returned all templates
content:
application/json:
@@ -1978,11 +2093,11 @@ paths:
type: array
items:
allOf:
- - $ref: "#/components/schemas/Template"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ - $ref: '#/components/schemas/Template'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
post:
description: Create a new template
deprecated: true
@@ -1995,23 +2110,45 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateBuildRequest"
+ $ref: '#/components/schemas/TemplateBuildRequest'
responses:
- "202":
+ '202':
description: The build was accepted
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateLegacy"
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/TemplateLegacy'
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/templates/{templateID}:
+ get:
+ description: List all builds for a template
+ tags: [templates]
+ security:
+ - ApiKeyAuth: []
+ - Supabase1TokenAuth: []
+ Supabase2TeamAuth: []
+ parameters:
+ - $ref: '#/components/parameters/templateID'
+ - $ref: '#/components/parameters/paginationNextToken'
+ - $ref: '#/components/parameters/paginationLimit'
+ responses:
+ '200':
+ description: Successfully returned the template with its builds
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/TemplateWithBuilds'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
post:
description: Rebuild an template
deprecated: true
@@ -2020,25 +2157,25 @@ paths:
- AccessTokenAuth: []
- Supabase1TokenAuth: []
parameters:
- - $ref: "#/components/parameters/templateID"
+ - $ref: '#/components/parameters/templateID'
requestBody:
required: true
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateBuildRequest"
+ $ref: '#/components/schemas/TemplateBuildRequest'
responses:
- "202":
+ '202':
description: The build was accepted
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateLegacy"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/TemplateLegacy'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
delete:
description: Delete a template
tags: [templates]
@@ -2047,14 +2184,14 @@ paths:
- AccessTokenAuth: []
- Supabase1TokenAuth: []
parameters:
- - $ref: "#/components/parameters/templateID"
+ - $ref: '#/components/parameters/templateID'
responses:
- "204":
+ '204':
description: The template was deleted successfully
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
patch:
description: Update template
tags: [templates]
@@ -2063,22 +2200,22 @@ paths:
- AccessTokenAuth: []
- Supabase1TokenAuth: []
parameters:
- - $ref: "#/components/parameters/templateID"
+ - $ref: '#/components/parameters/templateID'
requestBody:
required: true
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateUpdateRequest"
+ $ref: '#/components/schemas/TemplateUpdateRequest'
responses:
- "200":
+ '200':
description: The template was updated successfully
- "400":
- $ref: "#/components/responses/400"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ '400':
+ $ref: '#/components/responses/400'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/templates/{templateID}/builds/{buildID}:
post:
@@ -2089,15 +2226,15 @@ paths:
- AccessTokenAuth: []
- Supabase1TokenAuth: []
parameters:
- - $ref: "#/components/parameters/templateID"
- - $ref: "#/components/parameters/buildID"
+ - $ref: '#/components/parameters/templateID'
+ - $ref: '#/components/parameters/buildID'
responses:
- "202":
+ '202':
description: The build has started
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/v2/templates/{templateID}/builds/{buildID}:
post:
@@ -2107,21 +2244,21 @@ paths:
- ApiKeyAuth: []
- Supabase1TokenAuth: []
parameters:
- - $ref: "#/components/parameters/templateID"
- - $ref: "#/components/parameters/buildID"
+ - $ref: '#/components/parameters/templateID'
+ - $ref: '#/components/parameters/buildID'
requestBody:
required: true
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateBuildStartV2"
+ $ref: '#/components/schemas/TemplateBuildStartV2'
responses:
- "202":
+ '202':
description: The build has started
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/templates/{templateID}/builds/{buildID}/status:
get:
@@ -2132,8 +2269,8 @@ paths:
- ApiKeyAuth: []
- Supabase1TokenAuth: []
parameters:
- - $ref: "#/components/parameters/templateID"
- - $ref: "#/components/parameters/buildID"
+ - $ref: '#/components/parameters/templateID'
+ - $ref: '#/components/parameters/buildID'
- in: query
name: logsOffset
schema:
@@ -2145,20 +2282,20 @@ paths:
- in: query
name: level
schema:
- $ref: "#/components/schemas/LogLevel"
+ $ref: '#/components/schemas/LogLevel'
responses:
- "200":
+ '200':
description: Successfully returned the template
content:
application/json:
schema:
- $ref: "#/components/schemas/TemplateBuild"
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/TemplateBuildInfo'
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
/nodes:
get:
@@ -2167,7 +2304,7 @@ paths:
security:
- AdminTokenAuth: []
responses:
- "200":
+ '200':
description: Successfully returned all nodes
content:
application/json:
@@ -2175,11 +2312,11 @@ paths:
type: array
items:
allOf:
- - $ref: "#/components/schemas/Node"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ - $ref: '#/components/schemas/Node'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/nodes/{nodeID}:
get:
@@ -2188,7 +2325,7 @@ paths:
security:
- AdminTokenAuth: []
parameters:
- - $ref: "#/components/parameters/nodeID"
+ - $ref: '#/components/parameters/nodeID'
- in: query
name: clusterID
description: Identifier of the cluster
@@ -2197,39 +2334,39 @@ paths:
type: string
format: uuid
responses:
- "200":
+ '200':
description: Successfully returned the node
content:
application/json:
schema:
- $ref: "#/components/schemas/NodeDetail"
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/NodeDetail'
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
post:
description: Change status of a node
tags: [admin]
security:
- AdminTokenAuth: []
parameters:
- - $ref: "#/components/parameters/nodeID"
+ - $ref: '#/components/parameters/nodeID'
requestBody:
content:
application/json:
schema:
- $ref: "#/components/schemas/NodeStatusChange"
+ $ref: '#/components/schemas/NodeStatusChange'
responses:
- "204":
+ '204':
description: The node status was changed successfully
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
/access-tokens:
post:
@@ -2242,18 +2379,18 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/NewAccessToken"
+ $ref: '#/components/schemas/NewAccessToken'
responses:
- "201":
+ '201':
description: Access token created successfully
content:
application/json:
schema:
- $ref: "#/components/schemas/CreatedAccessToken"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/CreatedAccessToken'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/access-tokens/{accessTokenID}:
delete:
@@ -2262,16 +2399,16 @@ paths:
security:
- Supabase1TokenAuth: []
parameters:
- - $ref: "#/components/parameters/accessTokenID"
+ - $ref: '#/components/parameters/accessTokenID'
responses:
- "204":
+ '204':
description: Access token deleted successfully
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
/api-keys:
get:
@@ -2281,18 +2418,18 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
responses:
- "200":
+ '200':
description: Successfully returned all team API keys
content:
application/json:
schema:
type: array
items:
- $ref: "#/components/schemas/TeamAPIKey"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/TeamAPIKey'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
post:
description: Create a new team API key
tags: [api-keys]
@@ -2304,18 +2441,18 @@ paths:
content:
application/json:
schema:
- $ref: "#/components/schemas/NewTeamAPIKey"
+ $ref: '#/components/schemas/NewTeamAPIKey'
responses:
- "201":
+ '201':
description: Team API key created successfully
content:
application/json:
schema:
- $ref: "#/components/schemas/CreatedTeamAPIKey"
- "401":
- $ref: "#/components/responses/401"
- "500":
- $ref: "#/components/responses/500"
+ $ref: '#/components/schemas/CreatedTeamAPIKey'
+ '401':
+ $ref: '#/components/responses/401'
+ '500':
+ $ref: '#/components/responses/500'
/api-keys/{apiKeyID}:
patch:
@@ -2325,22 +2462,22 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/apiKeyID"
+ - $ref: '#/components/parameters/apiKeyID'
requestBody:
required: true
content:
application/json:
schema:
- $ref: "#/components/schemas/UpdateTeamAPIKey"
+ $ref: '#/components/schemas/UpdateTeamAPIKey'
responses:
- "200":
+ '200':
description: Team API key updated successfully
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'
delete:
description: Delete a team API key
tags: [api-keys]
@@ -2348,13 +2485,13 @@ paths:
- Supabase1TokenAuth: []
Supabase2TeamAuth: []
parameters:
- - $ref: "#/components/parameters/apiKeyID"
+ - $ref: '#/components/parameters/apiKeyID'
responses:
- "204":
+ '204':
description: Team API key deleted successfully
- "401":
- $ref: "#/components/responses/401"
- "404":
- $ref: "#/components/responses/404"
- "500":
- $ref: "#/components/responses/500"
+ '401':
+ $ref: '#/components/responses/401'
+ '404':
+ $ref: '#/components/responses/404'
+ '500':
+ $ref: '#/components/responses/500'