Open a TCP tunnel WebSocket
curl --request GET \
--url wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp \
--header 'Authorization: Bearer <token>'import requests
url = "wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"error": "<string>",
"code": "<string>"
}{
"error": "<string>",
"code": "<string>"
}{
"error": "<string>",
"code": "<string>"
}TCP Tunnels
TCP Tunnel WebSocket
Upgrade to a WebSocket that relays binary frames to and from a sandbox-local TCP port.
GET
/
api
/
v1
/
tunnels
/
tcp
Open a TCP tunnel WebSocket
curl --request GET \
--url wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp \
--header 'Authorization: Bearer <token>'import requests
url = "wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("wss://{identifier}.sandbox.tensorlake.ai/api/v1/tunnels/tcp")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"error": "<string>",
"code": "<string>"
}{
"error": "<string>",
"code": "<string>"
}{
"error": "<string>",
"code": "<string>"
}Open an authenticated WebSocket tunnel to a TCP port listening inside the sandbox.
Use this endpoint when you need raw TCP byte forwarding, such as VNC, Postgres, Redis, or Chrome DevTools over a private local tunnel. For most users, the
Use the WebSocket endpoint on the sandbox proxy host:
tl sbx tunnel CLI or SDK helper manages this protocol for you.
Endpoint
GET /api/v1/tunnels/tcp?port=<remote-port>
wss://<sandbox-id-or-name>.sandbox.tensorlake.ai/api/v1/tunnels/tcp?port=9222
Example Connection
Authenticate to the sandbox proxy with your API key. The proxy injects the internal forwarded-auth headers that the daemon requires.wscat -c "wss://<sandbox-id>.sandbox.tensorlake.ai/api/v1/tunnels/tcp?port=9222" \
-H "Authorization: Bearer $TENSORLAKE_API_KEY"
WebSocket Protocol
After the WebSocket upgrade succeeds, binary frames are relayed verbatim:- Client binary frames are written to
127.0.0.1:<port>inside the sandbox. - Bytes read from that TCP connection are sent back as WebSocket binary frames.
- Text frames are rejected.
Response Semantics
101 Switching Protocolsmeans the tunnel is open.400 Bad Requestmeansportis missing, invalid, or0.401 Unauthorizedmeans authenticated sandbox-proxy forwarding was not present.502 Bad Gatewaymeans nothing accepted the TCP connection on127.0.0.1:<port>inside the sandbox.
Was this page helpful?