Skip to content

[Sandboxes] Document the new tunnels API#30876

Open
aron-cf wants to merge 3 commits into
productionfrom
sandbox-tunnels
Open

[Sandboxes] Document the new tunnels API#30876
aron-cf wants to merge 3 commits into
productionfrom
sandbox-tunnels

Conversation

@aron-cf
Copy link
Copy Markdown
Contributor

@aron-cf aron-cf commented May 18, 2026

Summary

This adds a new Tunnels page to the Sandbox documents that covers the new sandbox.tunnels interface recently added to the SDK. This gives an API reference as well as updating existing locations that reference exposePort() to point to the new API.

Currently Cloudflare Tunnels have limited use and need to exist next to exposePort() while we work on the remaining functionality. I've tried to capture this in the Preview URLs document.

Documentation checklist

  • The change adheres to the documentation style guide.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/sandbox/ @whoiskatrin, @ghostwriternr, @cloudflare/product-owners, @cloudflare/ai-agents

@github-actions
Copy link
Copy Markdown
Contributor

Preview URL: https://9798f0fa.preview.developers.cloudflare.com
Preview Branch URL: https://sandbox-tunnels.preview.developers.cloudflare.com

Files with changes (up to 15)

Original Link Updated Link
https://developers.cloudflare.com/sandbox/api/tunnels/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/api/tunnels/
https://developers.cloudflare.com/sandbox/concepts/preview-urls/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/concepts/preview-urls/
https://developers.cloudflare.com/sandbox/concepts/security/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/concepts/security/
https://developers.cloudflare.com/sandbox/api/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/api/
https://developers.cloudflare.com/sandbox/api/ports/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/api/ports/
https://developers.cloudflare.com/sandbox/get-started/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/get-started/
https://developers.cloudflare.com/sandbox/guides/expose-services/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/guides/expose-services/
https://developers.cloudflare.com/sandbox/guides/production-deployment/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/guides/production-deployment/
https://developers.cloudflare.com/sandbox/guides/websocket-connections/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/guides/websocket-connections/
https://developers.cloudflare.com/sandbox/concepts/ https://sandbox-tunnels.preview.developers.cloudflare.com/sandbox/concepts/


## Requirements

- **RPC transport.** Calling `sandbox.tunnels` on a route-based transport throws `"RPC transport required"`. See [Transport configuration](/sandbox/configuration/transport/).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: route-based is probably an implementation detail so:

Suggested change
- **RPC transport.** Calling `sandbox.tunnels` on a route-based transport throws `"RPC transport required"`. See [Transport configuration](/sandbox/configuration/transport/).
- **RPC transport.** Calling `sandbox.tunnels` on HTTP/Websocket transports will throw `"RPC transport required"`. See [Transport configuration](/sandbox/configuration/transport/).


### `tunnels.get()`

Return a tunnel record for `port`. Idempotent: repeated calls for the same port return the same record. On a cache miss, the SDK spawns a fresh `cloudflared` process inside the container and persists the record in Durable Object storage.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Return a tunnel record for `port`. Idempotent: repeated calls for the same port return the same record. On a cache miss, the SDK spawns a fresh `cloudflared` process inside the container and persists the record in Durable Object storage.
Return a tunnel record for `port`. The SDK spawns a fresh `cloudflared` process inside the container if not already running. The method is idempotent so repeated calls for the same port return the same record.


**Parameters**:

- `port` — Port number inside the sandbox to expose (1024-65535, excluding reserved ports). The service must already be listening on `0.0.0.0:<port>` inside the container.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- `port` — Port number inside the sandbox to expose (1024-65535, excluding reserved ports). The service must already be listening on `0.0.0.0:<port>` inside the container.
- `port` — Port number inside the sandbox to expose (1024-65535, excluding reserved ports). The service to tunnel to must already be listening on `0.0.0.0:<port>` inside the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants