Sandbox egress
Decide which hosts your agents' code sandboxes may reach, per organization, workspace or environment; open one more destination for one sandbox; and see how Titan's kill reaches sandboxes.
On this page
Agents that run code do it in sandboxes: isolated machines that Hexel Studio creates for your organization. A sandbox can reach only what your egress policy allows. With no policy, a sandbox reaches nothing out and nothing in.
The policy is set by your administrators, never by the caller that creates the sandbox: an agent can't widen its own network. A sandbox that needs one more destination gets an egress grant for that one sandbox.
Create sandboxes
Sandboxes use the E2B API, so the stock E2B SDKs work. Point them at Hexel Studio and use a Hexel Studio API key, not an E2B key:
import os
os.environ["E2B_API_URL"] = "https://api.hexelstudio.com/v1/sandbox/e2b"
os.environ["E2B_API_KEY"] = os.environ["HEXEL_API_KEY"] # a Hexel Studio API key
from e2b import Sandbox
sbx = Sandbox.create("browser") # its network comes from your egress policyThe workspace and environment come from the X-Workspace-Id and X-Environment-Id headers. Another organization's sandbox is always "not found", and lists show only your organization's sandboxes.
An agent governed by Titan calls the same API at https://api.hexelstudio.com/v1/titan/sandbox/e2b with its Titan runtime token as the bearer. It can create and manage its own sandboxes in its token's workspace and environment, but never change an egress policy or a grant.
Set the egress policy
One policy per scope: the organization, a workspace, or an environment of a workspace. The most specific policy that is set applies. X-Workspace-Id and X-Environment-Id choose the scope; send neither for the organization's.
curl -X PUT https://api.hexelstudio.com/v1/sandbox/egress-policy \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "X-Workspace-Id: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"allow_out": ["pypi.org", "*.pythonhosted.org", "github.com"],
"allow_internet": false,
"allowed_templates": ["browser"],
"max_timeout_seconds": 3600
}'| Field | Meaning |
|---|---|
allow_out | Hosts (wildcards such as *.pythonhosted.org allowed) and CIDR ranges a sandbox may reach. |
deny_out | Hosts and ranges denied. |
allow_internet | false (the default) denies everything except allow_out. true allows the internet except deny_out. |
allow_public_traffic | true lets anyone reach the sandbox's URLs without its traffic token. Applies to sandboxes created after the change. |
allowed_templates | Templates a sandbox may be created from; empty means any. |
max_timeout_seconds | The longest a sandbox may live, checked on create and on every request that extends it; 0 means the provider's own limit. |
allowed_isolation | Isolation kinds a sandbox may run with; empty means any. |
Unknown fields are refused. The change reaches running sandboxes at once: the answer lists each one it was applied to, and paused sandboxes as deferred (applied when they resume).
Private address ranges, link-local addresses (cloud metadata) and the cloud provider's internal endpoints are always denied, and refused in any allow_out entry or grant. GET /egress-policy returns them as always_deny.
| Method and path | What it does | Permission |
|---|---|---|
GET /v1/sandbox/egress-policy | The policy set at this scope (policy, or null) and the one that applies (effective, with from: the scope it comes from, or default) | sandbox:policy:read |
GET /v1/sandbox/egress-policies | Every policy of the organization | sandbox:policy:read |
PUT /v1/sandbox/egress-policy | Set the policy at this scope | sandbox:policy:write |
DELETE /v1/sandbox/egress-policy | Remove it; the next policy up applies | sandbox:policy:write |
Open one destination for one sandbox
An administrator can let one running sandbox reach one more destination, for a while or until revoked:
curl -X POST https://api.hexelstudio.com/v1/sandbox/sandboxes/$SANDBOX_ID/egress-grants \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"destination": "api.github.com", "reason": "clone the repository", "expires_in_seconds": 3600}'The grant (grant_id, destination, reason, granted_by, expires_at) applies to that sandbox only; expires_in_seconds: 0 means no expiry. List a sandbox's grants with GET .../egress-grants (sandbox:egress:read) and revoke one with DELETE .../egress-grants/{grant_id} (sandbox:egress:grant). An agent can't change a sandbox's network directly: the E2B PUT /sandboxes/{id}/network call is always refused.
From the CLI, hexel sandbox list lists running sandboxes, hexel sandbox get <SANDBOX_ID> shows one with its network and egress grants, and hexel sandbox kill <SANDBOX_ID> ends it.
Titan and sandboxes
- Kill. When you kill an agent, a session or a wider scope with the Kill switch, sandboxes that the agent created with its runtime token stop serving it: its next request is refused with
403. - Agents asking for a destination. Titan has a capability for an agent to ask for one more destination,
sandbox.egress.allow, which always needs a person's approval. It is not turned on for Titan Cloud yet; until it is, an administrator adds the grant as above.
Every policy change, grant and refusal is recorded in the sandbox audit trail (GET /v1/sandbox/audit-events, permission sandbox:audit:read).