Delete a Tunnel
Deletes a tunnel. A tunnel that a route names as its next hop cannot be deleted; delete those routes first. Connected tunnel processes are disconnected and cannot reconnect with the tunnel’s token.
DELETE
/
tunnels
/
{id}
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
await client.tunnels.delete('id');import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
client.tunnels.delete(
"id",
)
package main
import (
"context"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Tunnels.Delete(
context.TODO(),
"id",
)
if err != nil {
panic(err.Error())
}
}
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();
client.tunnels().delete("id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.tunnels.delete("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->delete(
'id',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx tunnels delete \
--api-key 'My API Key' \
--id 62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39curl --request DELETE \
--url https://api.telnyx.com/v2/tunnels/{id} \
--header 'Authorization: Bearer <token>'{
"errors": [
{
"code": "10020",
"title": "Resource not found",
"detail": "get tunnel: not found"
}
]
}{
"errors": [
{
"code": "10021",
"title": "Resource conflict",
"detail": "tunnel 62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39 is the next hop of 1 route; delete it first: e8a2c5d0-3f7b-4a19-b6d2-9c1e0f8a7b53",
"meta": {
"route_ids": [
"e8a2c5d0-3f7b-4a19-b6d2-9c1e0f8a7b53"
]
}
}
]
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}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
});
await client.tunnels.delete('id');import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
client.tunnels.delete(
"id",
)
package main
import (
"context"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Tunnels.Delete(
context.TODO(),
"id",
)
if err != nil {
panic(err.Error())
}
}
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();
client.tunnels().delete("id");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.tunnels.delete("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->delete(
'id',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx tunnels delete \
--api-key 'My API Key' \
--id 62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39curl --request DELETE \
--url https://api.telnyx.com/v2/tunnels/{id} \
--header 'Authorization: Bearer <token>'{
"errors": [
{
"code": "10020",
"title": "Resource not found",
"detail": "get tunnel: not found"
}
]
}{
"errors": [
{
"code": "10021",
"title": "Resource conflict",
"detail": "tunnel 62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39 is the next hop of 1 route; delete it first: e8a2c5d0-3f7b-4a19-b6d2-9c1e0f8a7b53",
"meta": {
"route_ids": [
"e8a2c5d0-3f7b-4a19-b6d2-9c1e0f8a7b53"
]
}
}
]
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}