# Routes ## List tunnel routes `zero_trust.networks.routes.list(RouteListParams**kwargs) -> SyncV4PagePaginationArray[Teamnet]` **get** `/accounts/{account_id}/teamnet/routes` Lists and filters private network routes in an account. ### Parameters - `account_id: str` Cloudflare account ID - `comment: Optional[str]` Optional remark describing the route. - `existed_at: Optional[str]` If provided, include only resources that were created (and not deleted) before this time. URL encoded. - `is_deleted: Optional[bool]` If `true`, only include deleted routes. If `false`, exclude deleted routes. If empty, all routes will be included. - `network_subset: Optional[str]` If set, only list routes that are contained within this IP range. - `network_superset: Optional[str]` If set, only list routes that contain this IP range. - `page: Optional[float]` Page number of paginated results. - `per_page: Optional[float]` Number of results to display. - `route_id: Optional[str]` UUID of the route. - `tun_types: Optional[List[Literal["cfd_tunnel", "warp_connector", "warp", 4 more]]]` The types of tunnels to filter by, separated by commas. - `"cfd_tunnel"` - `"warp_connector"` - `"warp"` - `"magic"` - `"ip_sec"` - `"gre"` - `"cni"` - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Returns - `class Teamnet: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tun_type: Optional[Literal["cfd_tunnel", "warp_connector", "warp", 4 more]]` The type of tunnel. - `"cfd_tunnel"` - `"warp_connector"` - `"warp"` - `"magic"` - `"ip_sec"` - `"gre"` - `"cni"` - `tunnel_id: Optional[str]` UUID of the tunnel. - `tunnel_name: Optional[str]` A user-friendly name for a tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. - `virtual_network_name: Optional[str]` A user-friendly name for the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.zero_trust.networks.routes.list( account_id="699d98642c564d2e855e9661899b7252", ) page = page.result[0] print(page.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tun_type": "cfd_tunnel", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "blog", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_name": "us-east-1-vpc" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get tunnel route `zero_trust.networks.routes.get(strroute_id, RouteGetParams**kwargs) -> Route` **get** `/accounts/{account_id}/teamnet/routes/{route_id}` Get a private network route in an account. ### Parameters - `account_id: str` Cloudflare account ID - `route_id: str` UUID of the route. ### Returns - `class Route: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) route = client.zero_trust.networks.routes.get( route_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) print(route.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Create a tunnel route `zero_trust.networks.routes.create(RouteCreateParams**kwargs) -> Route` **post** `/accounts/{account_id}/teamnet/routes` Routes a private network through a Cloudflare Tunnel. ### Parameters - `account_id: str` Cloudflare account ID - `network: str` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: str` UUID of the tunnel. - `comment: Optional[str]` Optional remark describing the route. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Returns - `class Route: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) route = client.zero_trust.networks.routes.create( account_id="699d98642c564d2e855e9661899b7252", network="172.16.0.0/16", tunnel_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", ) print(route.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Update a tunnel route `zero_trust.networks.routes.edit(strroute_id, RouteEditParams**kwargs) -> Route` **patch** `/accounts/{account_id}/teamnet/routes/{route_id}` Updates an existing private network route in an account. The fields that are meant to be updated should be provided in the body of the request. ### Parameters - `account_id: str` Cloudflare account ID - `route_id: str` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Returns - `class Route: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) route = client.zero_trust.networks.routes.edit( route_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) print(route.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Delete a tunnel route `zero_trust.networks.routes.delete(strroute_id, RouteDeleteParams**kwargs) -> Route` **delete** `/accounts/{account_id}/teamnet/routes/{route_id}` Deletes a private network route from an account. ### Parameters - `account_id: str` Cloudflare account ID - `route_id: str` UUID of the route. ### Returns - `class Route: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) route = client.zero_trust.networks.routes.delete( route_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", account_id="699d98642c564d2e855e9661899b7252", ) print(route.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Domain Types ### Network Route - `class NetworkRoute: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Route - `class Route: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Teamnet - `class Teamnet: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tun_type: Optional[Literal["cfd_tunnel", "warp_connector", "warp", 4 more]]` The type of tunnel. - `"cfd_tunnel"` - `"warp_connector"` - `"warp"` - `"magic"` - `"ip_sec"` - `"gre"` - `"cni"` - `tunnel_id: Optional[str]` UUID of the tunnel. - `tunnel_name: Optional[str]` A user-friendly name for a tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. - `virtual_network_name: Optional[str]` A user-friendly name for the virtual network. # IPs ## Get tunnel route by IP `zero_trust.networks.routes.ips.get(strip, IPGetParams**kwargs) -> Teamnet` **get** `/accounts/{account_id}/teamnet/routes/ip/{ip}` Fetches routes that contain the given IP address. ### Parameters - `account_id: str` Cloudflare account ID - `ip: str` - `default_virtual_network_fallback: Optional[bool]` When the virtual_network_id parameter is not provided the request filter will default search routes that are in the default virtual network for the account. If this parameter is set to false, the search will include routes that do not have a virtual network. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Returns - `class Teamnet: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tun_type: Optional[Literal["cfd_tunnel", "warp_connector", "warp", 4 more]]` The type of tunnel. - `"cfd_tunnel"` - `"warp_connector"` - `"warp"` - `"magic"` - `"ip_sec"` - `"gre"` - `"cni"` - `tunnel_id: Optional[str]` UUID of the tunnel. - `tunnel_name: Optional[str]` A user-friendly name for a tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. - `virtual_network_name: Optional[str]` A user-friendly name for the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) teamnet = client.zero_trust.networks.routes.ips.get( ip="10.1.0.137", account_id="699d98642c564d2e855e9661899b7252", ) print(teamnet.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tun_type": "cfd_tunnel", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "tunnel_name": "blog", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_name": "us-east-1-vpc" }, "success": true } ``` # Networks ## Create a tunnel route (CIDR Endpoint) `zero_trust.networks.routes.networks.create(strip_network_encoded, NetworkCreateParams**kwargs) -> Route` **post** `/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}` Routes a private network through a Cloudflare Tunnel. The CIDR in `ip_network_encoded` must be written in URL-encoded format. ### Parameters - `account_id: str` Cloudflare account ID - `ip_network_encoded: str` IP/CIDR range in URL-encoded format - `tunnel_id: str` UUID of the tunnel. - `comment: Optional[str]` Optional remark describing the route. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Returns - `class Route: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) route = client.zero_trust.networks.routes.networks.create( ip_network_encoded="172.16.0.0%2F16", account_id="699d98642c564d2e855e9661899b7252", tunnel_id="f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", ) print(route.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Update a tunnel route (CIDR Endpoint) `zero_trust.networks.routes.networks.edit(strip_network_encoded, NetworkEditParams**kwargs) -> Route` **patch** `/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}` Updates an existing private network route in an account. The CIDR in `ip_network_encoded` must be written in URL-encoded format. ### Parameters - `account_id: str` Cloudflare account ID - `ip_network_encoded: str` IP/CIDR range in URL-encoded format ### Returns - `class Route: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) route = client.zero_trust.networks.routes.networks.edit( ip_network_encoded="172.16.0.0%2F16", account_id="699d98642c564d2e855e9661899b7252", ) print(route.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ``` ## Delete a tunnel route (CIDR Endpoint) `zero_trust.networks.routes.networks.delete(strip_network_encoded, NetworkDeleteParams**kwargs) -> Route` **delete** `/accounts/{account_id}/teamnet/routes/network/{ip_network_encoded}` Deletes a private network route from an account. The CIDR in `ip_network_encoded` must be written in URL-encoded format. If no virtual_network_id is provided it will delete the route from the default vnet. If no tun_type is provided it will fetch the type from the tunnel_id or if that is missing it will assume Cloudflare Tunnel as default. If tunnel_id is provided it will delete the route from that tunnel, otherwise it will delete the route based on the vnet and tun_type. ### Parameters - `account_id: str` Cloudflare account ID - `ip_network_encoded: str` IP/CIDR range in URL-encoded format - `tun_type: Optional[Literal["cfd_tunnel", "warp_connector", "warp", 4 more]]` The type of tunnel. - `"cfd_tunnel"` - `"warp_connector"` - `"warp"` - `"magic"` - `"ip_sec"` - `"gre"` - `"cni"` - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Returns - `class Route: …` - `id: Optional[str]` UUID of the route. - `comment: Optional[str]` Optional remark describing the route. - `created_at: Optional[datetime]` Timestamp of when the resource was created. - `deleted_at: Optional[datetime]` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `network: Optional[str]` The private IPv4 or IPv6 range connected by the route, in CIDR notation. - `tunnel_id: Optional[str]` UUID of the tunnel. - `virtual_network_id: Optional[str]` UUID of the virtual network. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) route = client.zero_trust.networks.routes.networks.delete( ip_network_encoded="172.16.0.0%2F16", account_id="699d98642c564d2e855e9661899b7252", ) print(route.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "comment": "Example comment for this route.", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "network": "172.16.0.0/16", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "virtual_network_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415" }, "success": true } ```