From 764016791d51523e9183e8ef9723b77663a70c46 Mon Sep 17 00:00:00 2001 From: mjoffre Date: Thu, 28 May 2026 01:03:31 +0000 Subject: [PATCH] docs: add SDK examples for updateNetwork in proxy configuration Update the 'Update proxy configuration' section to showcase the new SandboxInstance.updateNetwork (TypeScript) and SandboxInstance.update_network (Python) SDK methods alongside the existing cURL example. Refs: ENG-2665 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- Sandboxes/Proxy.mdx | 58 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/Sandboxes/Proxy.mdx b/Sandboxes/Proxy.mdx index 115f5a7d..dd8b5b28 100644 --- a/Sandboxes/Proxy.mdx +++ b/Sandboxes/Proxy.mdx @@ -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 + + +```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"}, + }, + ], + }, + }), +) +``` + +```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" \ @@ -245,6 +297,8 @@ curl -X PUT "https://api.blaxel.ai/v0/sandboxes/my-sandbox" \ }' ``` + + The update replaces the entire `network` configuration. Include all routing rules, domain filters, and secrets you want active after the update.