Rotate a Tunnel Token
Issues a new tunnel_token and invalidates the previous one. Tunnel processes already connected stay connected until they reconnect, and are then refused until they use the new token.
POST
/
tunnels
/
{id}
/
actions
/
rotate_token
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.tunnels.actions.rotateToken('id');
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.tunnels.actions.rotate_token(
"id",
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Tunnels.Actions.RotateToken(
context.TODO(),
"id",
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
var response = client.tunnels().actions().rotateToken("id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.tunnels.actions.rotate_token("id")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->tunnels->actions->rotateToken(
'id',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx tunnels:actions rotate-token \
--api-key 'My API Key' \
--id 62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39curl --request POST \
--url https://api.telnyx.com/v2/tunnels/{id}/actions/rotate_token \
--header 'Authorization: Bearer <token>'{
"data": {
"id": "62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39",
"record_type": "tunnel",
"name": "chicago-dc",
"status": "healthy",
"connection_count": 2,
"connections": [
{
"hostname": "dc1-tunnel-a",
"version": "0.6.0",
"region_code": "chicago-il",
"connected_at": "2026-10-21T15:04:05.123456Z"
},
{
"hostname": "dc1-tunnel-b",
"version": "0.6.0",
"region_code": "chicago-il",
"connected_at": "2026-10-21T15:04:05.123456Z"
}
],
"created_at": "2026-10-21T15:04:05.123456Z",
"tunnel_token": "tnl_example-new-token-shown-once"
}
}{
"errors": [
{
"code": "10020",
"title": "Resource not found",
"detail": "get tunnel: not found"
}
]
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The id of the tunnel.
Example:
"62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39"
Response
Successful response. The response carries the new tunnel token, once.
Show child attributes
Show child attributes
Was this page helpful?
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.tunnels.actions.rotateToken('id');
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.tunnels.actions.rotate_token(
"id",
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Tunnels.Actions.RotateToken(
context.TODO(),
"id",
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
var response = client.tunnels().actions().rotateToken("id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.tunnels.actions.rotate_token("id")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->tunnels->actions->rotateToken(
'id',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx tunnels:actions rotate-token \
--api-key 'My API Key' \
--id 62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39curl --request POST \
--url https://api.telnyx.com/v2/tunnels/{id}/actions/rotate_token \
--header 'Authorization: Bearer <token>'{
"data": {
"id": "62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39",
"record_type": "tunnel",
"name": "chicago-dc",
"status": "healthy",
"connection_count": 2,
"connections": [
{
"hostname": "dc1-tunnel-a",
"version": "0.6.0",
"region_code": "chicago-il",
"connected_at": "2026-10-21T15:04:05.123456Z"
},
{
"hostname": "dc1-tunnel-b",
"version": "0.6.0",
"region_code": "chicago-il",
"connected_at": "2026-10-21T15:04:05.123456Z"
}
],
"created_at": "2026-10-21T15:04:05.123456Z",
"tunnel_token": "tnl_example-new-token-shown-once"
}
}{
"errors": [
{
"code": "10020",
"title": "Resource not found",
"detail": "get tunnel: not found"
}
]
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}