Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions Sandboxes/Proxy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,61 @@ A few things to keep in mind:

## Update proxy configuration

You can update proxy routing rules, secrets, domain filters, and bypass lists on a running sandbox by calling the [Update sandbox](/api-reference/compute/update-sandbox) API endpoint. Pass the full sandbox object with an updated `network` field in the spec:
You can update proxy routing rules, secrets, domain filters, and bypass lists on a running sandbox using the SDK's `updateNetwork` method. This fetches the current sandbox, merges the new network config, and applies the update in one call:

```bash
<CodeGroup>

```typescript TypeScript
import { SandboxInstance } from "@blaxel/core";

await SandboxInstance.updateNetwork("my-sandbox", {
network: {
allowedDomains: ["api.stripe.com", "api.openai.com", "api.anthropic.com"],
proxy: {
routing: [
{
destinations: ["api.stripe.com"],
headers: { "Authorization": "Bearer {{SECRET:stripe-key}}" },
secrets: { "stripe-key": "sk_live_REPLACE_WITH_YOUR_KEY" },
},
{
destinations: ["api.anthropic.com"],
headers: { "x-api-key": "{{SECRET:anthropic-key}}" },
secrets: { "anthropic-key": "REPLACE_WITH_YOUR_ANTHROPIC_KEY" },
},
],
},
},
});
```

```python Python
from blaxel.core.sandbox import SandboxInstance
from blaxel.core.sandbox.types import SandboxUpdateNetwork

await SandboxInstance.update_network(
"my-sandbox",
SandboxUpdateNetwork(network={
"allowedDomains": ["api.stripe.com", "api.openai.com", "api.anthropic.com"],
"proxy": {
"routing": [
{
"destinations": ["api.stripe.com"],
"headers": {"Authorization": "Bearer {{SECRET:stripe-key}}"},
"secrets": {"stripe-key": "sk_live_REPLACE_WITH_YOUR_KEY"},
},
{
"destinations": ["api.anthropic.com"],
"headers": {"x-api-key": "{{SECRET:anthropic-key}}"},
"secrets": {"anthropic-key": "REPLACE_WITH_YOUR_ANTHROPIC_KEY"},
},
],
},
}),
)
Comment on lines +251 to +268
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug (P2): Python dict keys use camelCase (allowedDomains, routing) where the Python SDK likely expects snake_case (allowed_domains). If SandboxUpdateNetwork is a Pydantic model without camelCase aliases, these keys will be silently dropped, producing an empty network config.

Suggested change
Suggested change
SandboxUpdateNetwork(network={
"allowedDomains": ["api.stripe.com", "api.openai.com", "api.anthropic.com"],
"proxy": {
"routing": [
{
"destinations": ["api.stripe.com"],
"headers": {"Authorization": "Bearer {{SECRET:stripe-key}}"},
"secrets": {"stripe-key": "sk_live_REPLACE_WITH_YOUR_KEY"},
},
{
"destinations": ["api.anthropic.com"],
"headers": {"x-api-key": "{{SECRET:anthropic-key}}"},
"secrets": {"anthropic-key": "REPLACE_WITH_YOUR_ANTHROPIC_KEY"},
},
],
},
}),
)
await SandboxInstance.update_network(
"my-sandbox",
SandboxUpdateNetwork(network={
"allowed_domains": ["api.stripe.com", "api.openai.com", "api.anthropic.com"],
"proxy": {
"routing": [
{
"destinations": ["api.stripe.com"],
"headers": {"Authorization": "Bearer {{SECRET:stripe-key}}"},
"secrets": {"stripe-key": "sk_live_REPLACE_WITH_YOUR_KEY"},
},
{
"destinations": ["api.anthropic.com"],
"headers": {"x-api-key": "{{SECRET:anthropic-key}}"},
"secrets": {"anthropic-key": "REPLACE_WITH_YOUR_ANTHROPIC_KEY"},
},
],
},
}),
)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Sandboxes/Proxy.mdx, line 251:

<issue>
Python dict keys use camelCase (`allowedDomains`, `routing`) where the Python SDK likely expects snake_case (`allowed_domains`). If `SandboxUpdateNetwork` is a Pydantic model without camelCase aliases, these keys will be silently dropped, producing an empty network config.
</issue>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug — the Python SDK integration tests use camelCase dict keys:

SandboxUpdateNetwork(network={"allowedDomains": ["httpbin.org", "*.httpbin.org"]})
SandboxUpdateNetwork(network={"forbiddenDomains": ["httpbin.org", "*.httpbin.org"]})

See tests/integration/core/sandbox/test_network.py. The network parameter accepts a Union[SandboxNetwork, Dict[str, Any]] — when a dict is passed, it goes through the API client which uses camelCase field names matching the REST API schema.

```

```bash cURL
curl -X PUT "https://api.blaxel.ai/v0/sandboxes/my-sandbox" \
-H "Authorization: Bearer $BL_API_KEY" \
-H "X-Blaxel-Workspace: my-workspace" \
Expand Down Expand Up @@ -245,6 +297,8 @@ curl -X PUT "https://api.blaxel.ai/v0/sandboxes/my-sandbox" \
}'
```

</CodeGroup>

The update replaces the entire `network` configuration. Include all routing rules, domain filters, and secrets you want active after the update.

<Warning>
Expand Down