Change a sandbox's egress policy
Replaces the sandbox's `egress` policy (mode and allow list) while it runs or is paused. New outbound connections and DNS answers follow the new policy at once, and open connections it does not allow (SOCKS5, HTTP CONNECT and transparently redirected TCP alike) are closed: under `allowlist`, a connection stays open only if the host name it was opened for is on the new list (one opened by address alone is closed); under `deny`, every connection closes. Private, loopback, tailnet and metadata addresses stay refused in every mode. A sandbox cannot change its own policy (its in-VM API gets `403 forbidden`, `reason: self`, whatever its grant); call from outside it. Code in a sandbox may only narrow another sandbox's policy, to one within both that sandbox's current policy and its own (otherwise `403 forbidden`, `reason: egress_escalation`). A change cuts the streams code in other sandboxes holds open into this sandbox, and those code in this sandbox holds into others, once their target is no longer within the caller's reach (`sandboxesCreateSandbox`); the processes and files such code placed stay.
/v1/sandboxes/{sandbox_id}/egress
Authentication
Path Parameters
sandbox_id
string
required
path
"sbx_01m5t68q1b590rj801nbzsqzkk"Request Body required
application/jsonmode
string
public, allowlist, denyallow
string[]
Responses
application/jsonid
string
REQUIRED
object
string
REQUIRED
sandboxstatus
string
REQUIRED
running, paused, stopped, failedhost_id
string
REQUIRED
template
object
REQUIRED
id
string
REQUIRED
name
string
REQUIRED
snapshot
string | null
REQUIRED
vcpu
integer
REQUIRED
memory_mib
integer
REQUIRED
disk_gib
integer
REQUIRED
timeout_s
integer
REQUIRED
on_idle
string
REQUIRED
stop, pauseexpires_at
string (date-time)
REQUIRED
env
object
REQUIRED
secret_names
string[]
REQUIRED
ports
object[]
REQUIRED
port
integer
REQUIRED
public
boolean
REQUIRED
url
string (uri) | null
REQUIRED
api
object
REQUIRED
scopes
string[]
REQUIRED
spend_cap_usd
number | null
REQUIRED
connections
string[]
REQUIRED
egress
object
REQUIRED
mode
string
REQUIRED
public, allowlist, denyallow
string[]
REQUIRED
forkable
boolean
REQUIRED
created_at
string (date-time)
REQUIRED
started_at
string (date-time)
REQUIRED
paused_at
string (date-time) | null
REQUIRED
stopped_at
string (date-time) | null
REQUIRED
stop_reason
string | null
REQUIRED
deleted, timeout, failed, budget, revoked, nullusage
object
REQUIRED
vcpu_ms
integer
REQUIRED
gib_ms
integer
REQUIRED
readiness
object | null
status
string
REQUIRED
pending, ready, failedprobe
object
REQUIRED
port
integer
cmd
string | string[]
interval_ms
integer
timeout_s
integer
attempts
integer
REQUIRED
ready_at
string (date-time) | null
REQUIRED
time_to_ready_ms
integer | null
REQUIRED
last_error
string | null
REQUIRED
timing
object
total_ms
number
REQUIRED
metadata
object
REQUIRED
curl -X POST 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/egress' \ -H 'Authorization: Bearer YOUR_API_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "mode": "public", "allow": [ "string" ]}'
const response = await fetch('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/egress', { method: 'POST', headers: { "Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ "mode": "public", "allow": [ "string" ] })});const data = await response.json();console.log(data);
import requestsheaders = { 'Authorization': 'Bearer YOUR_API_TOKEN'}response = requests.post('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/egress', headers=headers, json={ "mode": "public", "allow": [ "string" ]})print(response.json())
{ "id": "sbx_01m5t68q1b590rj801nbzsqzkk", "object": "sandbox", "status": "running", "host_id": "sbx-01m5t68q1b590rj801nbzsqzkk", "template": { "id": "tpl_01m5t59b2ps0djyzdf082s18bz", "name": "base" }, "snapshot": null, "vcpu": 1, "memory_mib": 512, "disk_gib": 4, "timeout_s": 900, "on_idle": "stop", "expires_at": "2026-10-25T19:15:00.004Z", "env": {}, "secret_names": [], "ports": [], "api": { "scopes": [], "spend_cap_usd": null, "connections": [] }, "egress": { "mode": "allowlist", "allow": [ "github.com", "*.githubusercontent.com", "pypi.org", "files.pythonhosted.org" ] }, "forkable": false, "created_at": "2026-10-25T19:00:00.000Z", "started_at": "2026-10-25T19:00:00.004Z", "paused_at": null, "stopped_at": null, "stop_reason": null, "usage": { "vcpu_ms": 2100, "gib_ms": 300000 }, "metadata": {}}
Try this endpoint
/v1/sandboxes/{sandbox_id}/egress