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.
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.networkRoutes.create({
cidr: '10.20.0.0/16',
network_id: '91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24',
next_hop: {},
});
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.network_routes.create(
cidr="10.20.0.0/16",
network_id="91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
next_hop={},
)
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"),
)
networkRoute, err := client.NetworkRoutes.New(
context.TODO(),
telnyx.NetworkRouteNewParams{
Cidr: "10.20.0.0/16",
NetworkID: "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
NextHop: "next_hop",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", networkRoute.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.networkRoutes.NetworkRouteCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
NetworkRouteCreateParams params = NetworkRouteCreateParams.builder()
.cidr("10.20.0.0/16")
.networkId("91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24")
.nextHop(null)
.build();
var response = client.networkRoutes().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.network_routes.create(cidr: "10.20.0.0/16", network_id: "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24", next_hop: {})
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->networkRoutes->create(
cidr: '10.20.0.0/16',
network_id: '91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24',
next_hop: [],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx network-routes create \
--api-key 'My API Key' \
--network-id 91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24 \
--cidr 10.20.0.0/16 \
--next-hop '{}'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"
}
}
'{
"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?
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.networkRoutes.create({
cidr: '10.20.0.0/16',
network_id: '91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24',
next_hop: {},
});
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.network_routes.create(
cidr="10.20.0.0/16",
network_id="91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
next_hop={},
)
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"),
)
networkRoute, err := client.NetworkRoutes.New(
context.TODO(),
telnyx.NetworkRouteNewParams{
Cidr: "10.20.0.0/16",
NetworkID: "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24",
NextHop: "next_hop",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", networkRoute.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.networkRoutes.NetworkRouteCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
NetworkRouteCreateParams params = NetworkRouteCreateParams.builder()
.cidr("10.20.0.0/16")
.networkId("91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24")
.nextHop(null)
.build();
var response = client.networkRoutes().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.network_routes.create(cidr: "10.20.0.0/16", network_id: "91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24", next_hop: {})
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->networkRoutes->create(
cidr: '10.20.0.0/16',
network_id: '91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24',
next_hop: [],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx network-routes create \
--api-key 'My API Key' \
--network-id 91446ee3-5b1c-4f0e-8d2a-6c7e9b0a1f24 \
--cidr 10.20.0.0/16 \
--next-hop '{}'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"
}
}
'{
"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": {}
}
]
}