import Runloop from '@runloop/api-client';
const client = new Runloop({
bearerToken: process.env['RUNLOOP_API_KEY'], // This is the default and can be omitted
});
const tunnelView = await client.devboxes.enableTunnel('id');
console.log(tunnelView.auth_mode);import os
from runloop_api_client import Runloop
client = Runloop(
bearer_token=os.environ.get("RUNLOOP_API_KEY"), # This is the default and can be omitted
)
tunnel_view = client.devboxes.enable_tunnel(
id="id",
)
print(tunnel_view.auth_mode)curl --request POST \
--url https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"http_keep_alive": true,
"wake_on_http": true
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'http_keep_alive' => true,
'wake_on_http' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel"
payload := strings.NewReader("{\n \"http_keep_alive\": true,\n \"wake_on_http\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"http_keep_alive\": true,\n \"wake_on_http\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"http_keep_alive\": true,\n \"wake_on_http\": true\n}"
response = http.request(request)
puts response.read_body{
"tunnel_key": "<string>",
"auth_mode": "open",
"create_time_ms": 123,
"http_keep_alive": true,
"wake_on_http": true,
"auth_token": "<string>"
}Enable a tunnel for a running Devbox.
Enable a V2 tunnel for an existing running Devbox. Tunnels provide encrypted URL-based access to the Devbox without exposing internal IDs. The tunnel URL format is: https://{port}-{tunnel_key}.tunnel.runloop.ai
Each Devbox can have one tunnel. If tunnel config is omitted, or auth_mode is omitted, the tunnel defaults to open (public hostname, no bearer token).
import Runloop from '@runloop/api-client';
const client = new Runloop({
bearerToken: process.env['RUNLOOP_API_KEY'], // This is the default and can be omitted
});
const tunnelView = await client.devboxes.enableTunnel('id');
console.log(tunnelView.auth_mode);import os
from runloop_api_client import Runloop
client = Runloop(
bearer_token=os.environ.get("RUNLOOP_API_KEY"), # This is the default and can be omitted
)
tunnel_view = client.devboxes.enable_tunnel(
id="id",
)
print(tunnel_view.auth_mode)curl --request POST \
--url https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"http_keep_alive": true,
"wake_on_http": true
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'http_keep_alive' => true,
'wake_on_http' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel"
payload := strings.NewReader("{\n \"http_keep_alive\": true,\n \"wake_on_http\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"http_keep_alive\": true,\n \"wake_on_http\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runloop.ai/v1/devboxes/{id}/enable_tunnel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"http_keep_alive\": true,\n \"wake_on_http\": true\n}"
response = http.request(request)
puts response.read_body{
"tunnel_key": "<string>",
"auth_mode": "open",
"create_time_ms": 123,
"http_keep_alive": true,
"wake_on_http": true,
"auth_token": "<string>"
}Authorizations
Body
Configuration for creating a V2 tunnel. When specified at Devbox creation, a tunnel will be automatically provisioned.
Response
OK
A V2 tunnel provides secure HTTP access to services running on a Devbox. Tunnels allow external clients to reach web servers, APIs, or other HTTP services running inside a Devbox without requiring direct network access. Each tunnel is uniquely identified by an encrypted tunnel_key and can be configured for either open (public) or authenticated access. Usage: https://{port}-{tunnel_key}.tunnel.runloop.ai. Authenticated tunnels should pass auth_token as X-Runloop-Tunnel-Authorization: Bearer {auth_token}.
Was this page helpful?
