Outbound traffic hits the attached policy. Listed destinations are allowed. Everything else is denied.
1RuntimeAgent codePackage installs, HTTP calls, database queries
outbound
2Attached policyAllowlist check
DestinationPortResultapi.example.com443allowpypi.org443allow10.20.0.0/165432allowanything else*deny
allowed
3DestinationListed host and portModel APIs, registries, your database
No policy attached means blockedMetadata and link-local are always blockedDNS still resolves
Manage policies on the Network Policies page in the console, or with
client.network_policies (TypeScript: client.networkPolicies). This is separate from Identity → Providers.Allow outbound traffic
Use an allowlist when the sandbox must reach both a public API and an internal system:What stays blocked
Every new runtime starts with no outbound access:
The built-in system default is hidden from the Network Policies list and from
list_for_runtime (use include_system=True to see it). It cannot be detached or deleted. Once you attach any network policy of your own, those policies define egress; the system default is only the fallback when nothing else is attached.
DNS needed to resolve hostnames still works under restrictive modes. Private / link-local / cloud metadata ranges stay blocked unless you explicitly allowlist that destination — including under allow_all.
Choose a mode
Every policy has an egress mode. Destination rules (host / IP / CIDR + port + protocol) apply to allowlist and denylist.
Prefer
allowlist for production agents. Use allow_all only when you truly need broad egress. Use denylist when most of the internet is fine but a few hosts must stay blocked.
Name a destination
- Destination — hostname, IP, or CIDR
- Port — specific port, or
0for any port - Protocol —
tcp,udp, orany
Combine policies
You can attach more than one network policy to a runtime. When that happens, the most restrictive mode wins:
Examples:
- Any attached
deny_all→ no outbound access. - Any
allowlist(and nodeny_all) → default deny; destinations from attached allowlists are allowed. If a denylist is also attached, overlapping destinations stay denied. - Only
denylist→ outbound allowed except denied destinations. - Only
allow_all→ broad outbound access (sensitive private/metadata ranges still blocked unless explicitly allowed).
Reach a registry or a private host
Name every host. A public API and a private database are separate rules.
List every destination the workload needs. An allowlist that includes only
api.openai.com will block your internal DB — and an allowlist that includes only the DB will block the LLM API. To reach a private database or internal API under allowlist, add an explicit rule for that host (and port).
Attach a policy
Passnetwork_policy_ids when you create the sandbox, or call attach on a sandbox that is already running. The example below allows api.openai.com and blocks a host that is not on the list.
When you create the sandbox
On a running sandbox
Change a policy
Rename a policy, switch its mode, or add and remove destinations. Changes apply to a running sandbox.Rename it
Add or remove a destination
Methods
Python methods are onclient.network_policies. TypeScript uses client.networkPolicies.
Remove a policy
Keep the list narrow
- Stay closed by default — attach a policy only when the sandbox must call out, and prefer
allowlistoverallow_all. - List every needed destination — public APIs and internal hosts (DB, private API) must each have a rule under allowlist mode.
- Keep rules narrow — hostname + exact port beats “any port”; avoid wide CIDRs unless necessary.
- Combine with secrets — inject credentials via Store a credential, and only allow the destinations those credentials should talk to.
- Detach when unused — remove network policies from idle runtimes; delete unused policies.
Next
Expose a web service
An HTTPS URL for an HTTP server inside the runtime
Store a credential
Attach a key as an environment variable
Create Runtime
Attach policies at sandbox create