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}
Delete a Tunnel
curl --request DELETE \
--url https://api.telnyx.com/v2/tunnels/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/tunnels/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.telnyx.com/v2/tunnels/{id}', 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 => "https://api.telnyx.com/v2/tunnels/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
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 := "https://api.telnyx.com/v2/tunnels/{id}"
req, _ := http.NewRequest("DELETE", 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.delete("https://api.telnyx.com/v2/tunnels/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/tunnels/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"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?
Delete a Tunnel
curl --request DELETE \
--url https://api.telnyx.com/v2/tunnels/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telnyx.com/v2/tunnels/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.telnyx.com/v2/tunnels/{id}', 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 => "https://api.telnyx.com/v2/tunnels/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
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 := "https://api.telnyx.com/v2/tunnels/{id}"
req, _ := http.NewRequest("DELETE", 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.delete("https://api.telnyx.com/v2/tunnels/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/tunnels/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"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": {}
}
]
}