Quick start
Start an HTTP server inside a sandbox, then access it from anywhere using the proxy URL.- Python
- TypeScript
- Go
X-API-Key header.
How it works
- Your client sends an HTTP request to
https://api.declaw.ai/sandboxes/{sandbox_id}/ports/{port}/{path}. - Declaw authenticates the request using the
X-API-Keyheader. - If
allow_public_trafficis enabled (the default), the request is proxied to the target port inside the sandbox. - The response from the in-sandbox server is returned to the client.
.../ports/8080/api/v1/users reaches the sandbox as GET /api/v1/users.
MCP servers
Declaw provides a convenience method for the common pattern of running an MCP server on port 50005 inside a sandbox.- Python
- TypeScript
- Go
get_host(50005) + "/mcp". Use the mcp-server template to get a sandbox pre-configured with FastMCP and the standard MCP dependencies.
WebSocket
Port proxy supports WebSocket connections. Use the same URL fromget_host(), replacing https:// with wss://.
- Python
- TypeScript
- Go
X-API-Key header as HTTP requests, passed during the upgrade handshake via additional_headers (Python) or connection options (TypeScript/Go).
Security
Authentication
All port proxy requests require a validX-API-Key header, the same key used for every other sandbox operation. Unauthenticated requests receive HTTP 401.
Disabling port proxy
Port proxy access is controlled by theallow_public_traffic field in the sandbox’s network configuration. It defaults to true. Set it to false to block all inbound port proxy requests.
- Python
- TypeScript
- Go
Blocked ports
Port 49983 is reserved for internal use and cannot be proxied. Requests targeting this port returnHTTP 403.
Cookie stripping
Set-Cookie headers are stripped from all proxied responses to prevent cookie injection attacks against the API domain.
Limits
CORS
CORS preflight (OPTIONS) requests are handled automatically by the proxy and do not require an X-API-Key header. This allows browser-based applications to call sandbox services directly without a backend relay.
All other HTTP methods (GET, POST, etc.) still require the
X-API-Key header, even when called from a browser. Use a backend proxy or serverless function if you cannot expose your API key to the client.