Create a Network Route
Adds a route to a Network. Traffic on the Network to an address in cidr goes via next_hop. With a tunnel as the next hop, functions on the Network reach the CIDR through the tunnel without a redeploy. A Network holds each CIDR once.
curl --request POST \
--url https://api.telnyx.com/v2/network_routes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"network_id": "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
"cidr": "10.20.0.0/16",
"next_hop": {
"type": "tunnel",
"id": "62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39"
}
}
'import requests
url = "https://api.telnyx.com/v2/network_routes"
payload = {
"network_id": "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
"cidr": "10.20.0.0/16",
"next_hop": {
"type": "tunnel",
"id": "62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
network_id: '91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24',
cidr: '10.20.0.0/16',
next_hop: {type: 'tunnel', id: '62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39'}
})
};
fetch('https://api.telnyx.com/v2/network_routes', 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/network_routes",
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([
'network_id' => '91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24',
'cidr' => '10.20.0.0/16',
'next_hop' => [
'type' => 'tunnel',
'id' => '62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39'
]
]),
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.telnyx.com/v2/network_routes"
payload := strings.NewReader("{\n \"network_id\": \"91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24\",\n \"cidr\": \"10.20.0.0/16\",\n \"next_hop\": {\n \"type\": \"tunnel\",\n \"id\": \"62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39\"\n }\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.telnyx.com/v2/network_routes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"network_id\": \"91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24\",\n \"cidr\": \"10.20.0.0/16\",\n \"next_hop\": {\n \"type\": \"tunnel\",\n \"id\": \"62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/network_routes")
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 \"network_id\": \"91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24\",\n \"cidr\": \"10.20.0.0/16\",\n \"next_hop\": {\n \"type\": \"tunnel\",\n \"id\": \"62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "e8a2c5d0-3f7b-4a19-b6d2-9c1e0f8a7b53",
"record_type": "network_route",
"network_id": "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
"cidr": "10.20.0.0/16",
"next_hop": {
"type": "tunnel",
"id": "62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39"
},
"origin": "static",
"status": "pending",
"created_at": "2026-10-21T15:04:05.123456Z"
}
}{
"errors": [
{
"code": "10020",
"title": "Resource not found",
"detail": "tunnel 62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39 not found"
}
]
}{
"errors": [
{
"code": "10021",
"title": "Resource conflict",
"detail": "create route: resource already exists"
}
]
}{
"errors": [
{
"code": "10022",
"title": "Unprocessable Entity",
"detail": "cidr must be a valid CIDR range (e.g. 10.20.0.0/16)",
"source": {
"pointer": "/cidr"
}
}
]
}{
"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.
Body
The id of the Network to add the route to.
"91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24"
The IPv4 subnet to route, such as a subnet behind the tunnel. It must be a canonical CIDR. Default, loopback, link-local, multicast, and shared address space (100.64.0.0/10) ranges are rejected. So are ranges that overlap the Tailscale Subnet Router ranges, 172.27.254.0/24 and 198.18.0.0/20, or a subnet already on the Network.
"10.20.0.0/16"
Where the Network sends traffic for cidr.
Show child attributes
Show child attributes
Response
Created.
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://api.telnyx.com/v2/network_routes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"network_id": "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
"cidr": "10.20.0.0/16",
"next_hop": {
"type": "tunnel",
"id": "62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39"
}
}
'import requests
url = "https://api.telnyx.com/v2/network_routes"
payload = {
"network_id": "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
"cidr": "10.20.0.0/16",
"next_hop": {
"type": "tunnel",
"id": "62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
network_id: '91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24',
cidr: '10.20.0.0/16',
next_hop: {type: 'tunnel', id: '62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39'}
})
};
fetch('https://api.telnyx.com/v2/network_routes', 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/network_routes",
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([
'network_id' => '91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24',
'cidr' => '10.20.0.0/16',
'next_hop' => [
'type' => 'tunnel',
'id' => '62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39'
]
]),
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.telnyx.com/v2/network_routes"
payload := strings.NewReader("{\n \"network_id\": \"91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24\",\n \"cidr\": \"10.20.0.0/16\",\n \"next_hop\": {\n \"type\": \"tunnel\",\n \"id\": \"62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39\"\n }\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.telnyx.com/v2/network_routes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"network_id\": \"91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24\",\n \"cidr\": \"10.20.0.0/16\",\n \"next_hop\": {\n \"type\": \"tunnel\",\n \"id\": \"62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/network_routes")
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 \"network_id\": \"91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24\",\n \"cidr\": \"10.20.0.0/16\",\n \"next_hop\": {\n \"type\": \"tunnel\",\n \"id\": \"62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "e8a2c5d0-3f7b-4a19-b6d2-9c1e0f8a7b53",
"record_type": "network_route",
"network_id": "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
"cidr": "10.20.0.0/16",
"next_hop": {
"type": "tunnel",
"id": "62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39"
},
"origin": "static",
"status": "pending",
"created_at": "2026-10-21T15:04:05.123456Z"
}
}{
"errors": [
{
"code": "10020",
"title": "Resource not found",
"detail": "tunnel 62d438d2-8a51-4c5e-9d0c-1f6b2a7e4c39 not found"
}
]
}{
"errors": [
{
"code": "10021",
"title": "Resource conflict",
"detail": "create route: resource already exists"
}
]
}{
"errors": [
{
"code": "10022",
"title": "Unprocessable Entity",
"detail": "cidr must be a valid CIDR range (e.g. 10.20.0.0/16)",
"source": {
"pointer": "/cidr"
}
}
]
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}