Create a Tailscale Subnet Router
Creates a Tailscale Subnet Router on a Network and enrolls it in the user’s tailnet with the auth key. The response returns the router with status provisioning. Poll GET /tailscale_subnet_routers/{id} until it is provisioned. Then approve its routes in the tailnet, unless an auto-approver covers them.
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.tailscaleSubnetRouters.create({
advertised_routes: ["172.27.0.0/24"],
auth_key: 'tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv',
name: 'tailnet-ashburn',
network_id: '0de011ae-ee53-4df4-ba96-754728eb5aad',
region_code: 'ashburn-va',
});
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.tailscale_subnet_routers.create(
advertised_routes=["172.27.0.0/24"],
auth_key="tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv",
name="tailnet-ashburn",
network_id="0de011ae-ee53-4df4-ba96-754728eb5aad",
region_code="ashburn-va",
)
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"),
)
tailscaleSubnetRouter, err := client.TailscaleSubnetRouters.New(
context.TODO(),
telnyx.TailscaleSubnetRouterNewParams{
AdvertisedRoutes: "['172.27.0.0/24']",
AuthKey: "tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv",
Name: "tailnet-ashburn",
NetworkID: "0de011ae-ee53-4df4-ba96-754728eb5aad",
RegionCode: "ashburn-va",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", tailscaleSubnetRouter.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.tailscaleSubnetRouters.TailscaleSubnetRouterCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
TailscaleSubnetRouterCreateParams params = TailscaleSubnetRouterCreateParams.builder()
.advertisedRoutes(["172.27.0.0/24"])
.authKey("tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv")
.name("tailnet-ashburn")
.networkId("0de011ae-ee53-4df4-ba96-754728eb5aad")
.regionCode("ashburn-va")
.build();
var response = client.tailscaleSubnetRouters().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.tailscale_subnet_routers.create(
advertised_routes: ["172.27.0.0/24"],
auth_key: "tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv",
name: "tailnet-ashburn",
network_id: "0de011ae-ee53-4df4-ba96-754728eb5aad",
region_code: "ashburn-va"
)
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->tailscaleSubnetRouters->create(
advertised_routes: ["172.27.0.0/24"],
auth_key: 'tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv',
name: 'tailnet-ashburn',
network_id: '0de011ae-ee53-4df4-ba96-754728eb5aad',
region_code: 'ashburn-va',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx tailscale-subnet-routers create \
--api-key 'My API Key' \
--name tailnet-ashburn \
--network-id 0de011ae-ee53-4df4-ba96-754728eb5aad \
--region-code ashburn-va \
--advertised-routes 172.27.0.0/24 \
--auth-key tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUvcurl --request POST \
--url https://api.telnyx.com/v2/tailscale_subnet_routers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "tailnet-ashburn",
"network_id": "0de011ae-ee53-4df4-ba96-754728eb5aad",
"region_code": "ashburn-va",
"advertised_routes": [
"172.27.0.0/24"
],
"auth_key": "tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv"
}
'{
"data": {
"id": "5c6f0a7e-6c7b-4d7f-9f2e-3b1e4e9a8c21",
"record_type": "tailscale_subnet_router",
"name": "tailnet-ashburn",
"network_id": "0de011ae-ee53-4df4-ba96-754728eb5aad",
"region_code": "ashburn-va",
"advertised_routes": [
"172.27.0.0/24"
],
"status": "provisioning",
"customer_address": "172.27.254.1",
"device_id": null,
"tailnet_name": null,
"tailscale_ips": [],
"created_at": "2026-10-13T15:04:05.123456Z",
"updated_at": "2026-10-13T15:04:05.123456Z"
}
}{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "Routes must exclude default, local, and Tailscale ranges.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10015"
}
}
]
}{
"errors": [
{
"code": "10027",
"title": "Unprocessable Entity",
"detail": "The server understood the syntax of the request but was unable to process the instructions."
}
]
}{
"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
A user specified name for the router.
1 - 128"tailnet-ashburn"
The id of the Network to attach the router to.
"0de011ae-ee53-4df4-ba96-754728eb5aad"
The code of the region to create the router in. GET /network_coverage lists the regions whose available_services include tailscale_subnet_router.
"ashburn-va"
IPv4 subnets of the Network that the router advertises to the tailnet. Each entry is a canonical CIDR that the Network routes. Default, loopback, link-local, multicast, and Tailscale (100.64.0.0/10) ranges are rejected. So are ranges that overlap the router's own, 172.27.254.0/24 and 198.18.0.0/20.
1 - 64 elements["172.27.0.0/24"]
A Tailscale auth key that enrolls the router in the user's tailnet: reusable, pre-approved, tagged, and not ephemeral. Telnyx stores it encrypted until enrollment succeeds, then discards it. It is never returned.
^tskey-auth-[A-Za-z0-9_-]{10,250}$"tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv"
Response
Successful response. The router is created and provisioning has started.
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.tailscaleSubnetRouters.create({
advertised_routes: ["172.27.0.0/24"],
auth_key: 'tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv',
name: 'tailnet-ashburn',
network_id: '0de011ae-ee53-4df4-ba96-754728eb5aad',
region_code: 'ashburn-va',
});
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.tailscale_subnet_routers.create(
advertised_routes=["172.27.0.0/24"],
auth_key="tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv",
name="tailnet-ashburn",
network_id="0de011ae-ee53-4df4-ba96-754728eb5aad",
region_code="ashburn-va",
)
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"),
)
tailscaleSubnetRouter, err := client.TailscaleSubnetRouters.New(
context.TODO(),
telnyx.TailscaleSubnetRouterNewParams{
AdvertisedRoutes: "['172.27.0.0/24']",
AuthKey: "tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv",
Name: "tailnet-ashburn",
NetworkID: "0de011ae-ee53-4df4-ba96-754728eb5aad",
RegionCode: "ashburn-va",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", tailscaleSubnetRouter.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.tailscaleSubnetRouters.TailscaleSubnetRouterCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
TailscaleSubnetRouterCreateParams params = TailscaleSubnetRouterCreateParams.builder()
.advertisedRoutes(["172.27.0.0/24"])
.authKey("tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv")
.name("tailnet-ashburn")
.networkId("0de011ae-ee53-4df4-ba96-754728eb5aad")
.regionCode("ashburn-va")
.build();
var response = client.tailscaleSubnetRouters().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.tailscale_subnet_routers.create(
advertised_routes: ["172.27.0.0/24"],
auth_key: "tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv",
name: "tailnet-ashburn",
network_id: "0de011ae-ee53-4df4-ba96-754728eb5aad",
region_code: "ashburn-va"
)
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->tailscaleSubnetRouters->create(
advertised_routes: ["172.27.0.0/24"],
auth_key: 'tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv',
name: 'tailnet-ashburn',
network_id: '0de011ae-ee53-4df4-ba96-754728eb5aad',
region_code: 'ashburn-va',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx tailscale-subnet-routers create \
--api-key 'My API Key' \
--name tailnet-ashburn \
--network-id 0de011ae-ee53-4df4-ba96-754728eb5aad \
--region-code ashburn-va \
--advertised-routes 172.27.0.0/24 \
--auth-key tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUvcurl --request POST \
--url https://api.telnyx.com/v2/tailscale_subnet_routers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "tailnet-ashburn",
"network_id": "0de011ae-ee53-4df4-ba96-754728eb5aad",
"region_code": "ashburn-va",
"advertised_routes": [
"172.27.0.0/24"
],
"auth_key": "tskey-auth-k1AbCdEfGh2IjKlMnOpQrStUv"
}
'{
"data": {
"id": "5c6f0a7e-6c7b-4d7f-9f2e-3b1e4e9a8c21",
"record_type": "tailscale_subnet_router",
"name": "tailnet-ashburn",
"network_id": "0de011ae-ee53-4df4-ba96-754728eb5aad",
"region_code": "ashburn-va",
"advertised_routes": [
"172.27.0.0/24"
],
"status": "provisioning",
"customer_address": "172.27.254.1",
"device_id": null,
"tailnet_name": null,
"tailscale_ips": [],
"created_at": "2026-10-13T15:04:05.123456Z",
"updated_at": "2026-10-13T15:04:05.123456Z"
}
}{
"errors": [
{
"code": "10015",
"title": "Bad Request",
"detail": "Routes must exclude default, local, and Tailscale ranges.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10015"
}
}
]
}{
"errors": [
{
"code": "10027",
"title": "Unprocessable Entity",
"detail": "The server understood the syntax of the request but was unable to process the instructions."
}
]
}{
"errors": [
{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}
]
}