# Tunnels ## List All Tunnels `client.ZeroTrust.Tunnels.List(ctx, params) (*V4PagePaginationArray[TunnelListResponse], error)` **get** `/accounts/{account_id}/tunnels` Lists and filters all types of Tunnels in an account. ### Parameters - `params TunnelListParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `ExcludePrefix param.Field[string]` Query param - `ExistedAt param.Field[string]` Query param: If provided, include only resources that were created (and not deleted) before this time. URL encoded. - `IncludePrefix param.Field[string]` Query param - `IsDeleted param.Field[bool]` Query param: If `true`, only include deleted tunnels. If `false`, exclude deleted tunnels. If empty, all tunnels will be included. - `Name param.Field[string]` Query param: A user-friendly name for the tunnel. - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Number of results to display. - `Status param.Field[TunnelListParamsStatus]` Query param: The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelListParamsStatusInactive TunnelListParamsStatus = "inactive"` - `const TunnelListParamsStatusDegraded TunnelListParamsStatus = "degraded"` - `const TunnelListParamsStatusHealthy TunnelListParamsStatus = "healthy"` - `const TunnelListParamsStatusDown TunnelListParamsStatus = "down"` - `TunTypes param.Field[[]TunnelListParamsTunType]` Query param: The types of tunnels to filter by, separated by commas. - `const TunnelListParamsTunTypeCfdTunnel TunnelListParamsTunType = "cfd_tunnel"` - `const TunnelListParamsTunTypeWARPConnector TunnelListParamsTunType = "warp_connector"` - `const TunnelListParamsTunTypeWARP TunnelListParamsTunType = "warp"` - `const TunnelListParamsTunTypeMagic TunnelListParamsTunType = "magic"` - `const TunnelListParamsTunTypeIPSec TunnelListParamsTunType = "ip_sec"` - `const TunnelListParamsTunTypeGRE TunnelListParamsTunType = "gre"` - `const TunnelListParamsTunTypeCNI TunnelListParamsTunType = "cni"` - `UUID param.Field[string]` Query param: UUID of the tunnel. - `WasActiveAt param.Field[Time]` Query param - `WasInactiveAt param.Field[Time]` Query param ### Returns - `type TunnelListResponse interface{…}` A Cloudflare Tunnel that connects your origin to Cloudflare's edge. - `type CloudflareTunnel struct{…}` A Cloudflare Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `ConfigSrc CloudflareTunnelConfigSrc` Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard. - `const CloudflareTunnelConfigSrcLocal CloudflareTunnelConfigSrc = "local"` - `const CloudflareTunnelConfigSrcCloudflare CloudflareTunnelConfigSrc = "cloudflare"` - `Connections []CloudflareTunnelConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `RemoteConfig bool` If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. If `false`, the tunnel must be configured locally on the origin machine. - `Status CloudflareTunnelStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const CloudflareTunnelStatusInactive CloudflareTunnelStatus = "inactive"` - `const CloudflareTunnelStatusDegraded CloudflareTunnelStatus = "degraded"` - `const CloudflareTunnelStatusHealthy CloudflareTunnelStatus = "healthy"` - `const CloudflareTunnelStatusDown CloudflareTunnelStatus = "down"` - `TunType CloudflareTunnelTunType` The type of tunnel. - `const CloudflareTunnelTunTypeCfdTunnel CloudflareTunnelTunType = "cfd_tunnel"` - `const CloudflareTunnelTunTypeWARPConnector CloudflareTunnelTunType = "warp_connector"` - `const CloudflareTunnelTunTypeWARP CloudflareTunnelTunType = "warp"` - `const CloudflareTunnelTunTypeMagic CloudflareTunnelTunType = "magic"` - `const CloudflareTunnelTunTypeIPSec CloudflareTunnelTunType = "ip_sec"` - `const CloudflareTunnelTunTypeGRE CloudflareTunnelTunType = "gre"` - `const CloudflareTunnelTunTypeCNI CloudflareTunnelTunType = "cni"` - `type TunnelListResponseTunnelWARPConnectorTunnel struct{…}` A Warp Connector Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `Connections []TunnelListResponseTunnelWARPConnectorTunnelConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `Status TunnelListResponseTunnelWARPConnectorTunnelStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelListResponseTunnelWARPConnectorTunnelStatusInactive TunnelListResponseTunnelWARPConnectorTunnelStatus = "inactive"` - `const TunnelListResponseTunnelWARPConnectorTunnelStatusDegraded TunnelListResponseTunnelWARPConnectorTunnelStatus = "degraded"` - `const TunnelListResponseTunnelWARPConnectorTunnelStatusHealthy TunnelListResponseTunnelWARPConnectorTunnelStatus = "healthy"` - `const TunnelListResponseTunnelWARPConnectorTunnelStatusDown TunnelListResponseTunnelWARPConnectorTunnelStatus = "down"` - `TunType TunnelListResponseTunnelWARPConnectorTunnelTunType` The type of tunnel. - `const TunnelListResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel TunnelListResponseTunnelWARPConnectorTunnelTunType = "cfd_tunnel"` - `const TunnelListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector TunnelListResponseTunnelWARPConnectorTunnelTunType = "warp_connector"` - `const TunnelListResponseTunnelWARPConnectorTunnelTunTypeWARP TunnelListResponseTunnelWARPConnectorTunnelTunType = "warp"` - `const TunnelListResponseTunnelWARPConnectorTunnelTunTypeMagic TunnelListResponseTunnelWARPConnectorTunnelTunType = "magic"` - `const TunnelListResponseTunnelWARPConnectorTunnelTunTypeIPSec TunnelListResponseTunnelWARPConnectorTunnelTunType = "ip_sec"` - `const TunnelListResponseTunnelWARPConnectorTunnelTunTypeGRE TunnelListResponseTunnelWARPConnectorTunnelTunType = "gre"` - `const TunnelListResponseTunnelWARPConnectorTunnelTunTypeCNI TunnelListResponseTunnelWARPConnectorTunnelTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Tunnels.List(context.TODO(), zero_trust.TunnelListParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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", "account_tag": "699d98642c564d2e855e9661899b7252", "config_src": "cloudflare", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "remote_config": true, "status": "healthy", "tun_type": "cfd_tunnel" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Domain Types ### Connection - `type Connection struct{…}` - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `UUID string` UUID of the Cloudflare Tunnel connection. # Cloudflared ## List Cloudflare Tunnels `client.ZeroTrust.Tunnels.Cloudflared.List(ctx, params) (*V4PagePaginationArray[CloudflareTunnel], error)` **get** `/accounts/{account_id}/cfd_tunnel` Lists and filters Cloudflare Tunnels in an account. ### Parameters - `params TunnelCloudflaredListParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `ExcludePrefix param.Field[string]` Query param - `ExistedAt param.Field[string]` Query param: If provided, include only resources that were created (and not deleted) before this time. URL encoded. - `IncludePrefix param.Field[string]` Query param - `IsDeleted param.Field[bool]` Query param: If `true`, only include deleted tunnels. If `false`, exclude deleted tunnels. If empty, all tunnels will be included. - `Name param.Field[string]` Query param: A user-friendly name for a tunnel. - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Number of results to display. - `Status param.Field[TunnelCloudflaredListParamsStatus]` Query param: The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelCloudflaredListParamsStatusInactive TunnelCloudflaredListParamsStatus = "inactive"` - `const TunnelCloudflaredListParamsStatusDegraded TunnelCloudflaredListParamsStatus = "degraded"` - `const TunnelCloudflaredListParamsStatusHealthy TunnelCloudflaredListParamsStatus = "healthy"` - `const TunnelCloudflaredListParamsStatusDown TunnelCloudflaredListParamsStatus = "down"` - `UUID param.Field[string]` Query param: UUID of the tunnel. - `WasActiveAt param.Field[Time]` Query param - `WasInactiveAt param.Field[Time]` Query param ### Returns - `type CloudflareTunnel struct{…}` A Cloudflare Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `ConfigSrc CloudflareTunnelConfigSrc` Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard. - `const CloudflareTunnelConfigSrcLocal CloudflareTunnelConfigSrc = "local"` - `const CloudflareTunnelConfigSrcCloudflare CloudflareTunnelConfigSrc = "cloudflare"` - `Connections []CloudflareTunnelConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `RemoteConfig bool` If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. If `false`, the tunnel must be configured locally on the origin machine. - `Status CloudflareTunnelStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const CloudflareTunnelStatusInactive CloudflareTunnelStatus = "inactive"` - `const CloudflareTunnelStatusDegraded CloudflareTunnelStatus = "degraded"` - `const CloudflareTunnelStatusHealthy CloudflareTunnelStatus = "healthy"` - `const CloudflareTunnelStatusDown CloudflareTunnelStatus = "down"` - `TunType CloudflareTunnelTunType` The type of tunnel. - `const CloudflareTunnelTunTypeCfdTunnel CloudflareTunnelTunType = "cfd_tunnel"` - `const CloudflareTunnelTunTypeWARPConnector CloudflareTunnelTunType = "warp_connector"` - `const CloudflareTunnelTunTypeWARP CloudflareTunnelTunType = "warp"` - `const CloudflareTunnelTunTypeMagic CloudflareTunnelTunType = "magic"` - `const CloudflareTunnelTunTypeIPSec CloudflareTunnelTunType = "ip_sec"` - `const CloudflareTunnelTunTypeGRE CloudflareTunnelTunType = "gre"` - `const CloudflareTunnelTunTypeCNI CloudflareTunnelTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Tunnels.Cloudflared.List(context.TODO(), zero_trust.TunnelCloudflaredListParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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", "account_tag": "699d98642c564d2e855e9661899b7252", "config_src": "cloudflare", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "remote_config": true, "status": "healthy", "tun_type": "cfd_tunnel" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get a Cloudflare Tunnel `client.ZeroTrust.Tunnels.Cloudflared.Get(ctx, tunnelID, query) (*CloudflareTunnel, error)` **get** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}` Fetches a single Cloudflare Tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `query TunnelCloudflaredGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type CloudflareTunnel struct{…}` A Cloudflare Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `ConfigSrc CloudflareTunnelConfigSrc` Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard. - `const CloudflareTunnelConfigSrcLocal CloudflareTunnelConfigSrc = "local"` - `const CloudflareTunnelConfigSrcCloudflare CloudflareTunnelConfigSrc = "cloudflare"` - `Connections []CloudflareTunnelConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `RemoteConfig bool` If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. If `false`, the tunnel must be configured locally on the origin machine. - `Status CloudflareTunnelStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const CloudflareTunnelStatusInactive CloudflareTunnelStatus = "inactive"` - `const CloudflareTunnelStatusDegraded CloudflareTunnelStatus = "degraded"` - `const CloudflareTunnelStatusHealthy CloudflareTunnelStatus = "healthy"` - `const CloudflareTunnelStatusDown CloudflareTunnelStatus = "down"` - `TunType CloudflareTunnelTunType` The type of tunnel. - `const CloudflareTunnelTunTypeCfdTunnel CloudflareTunnelTunType = "cfd_tunnel"` - `const CloudflareTunnelTunTypeWARPConnector CloudflareTunnelTunType = "warp_connector"` - `const CloudflareTunnelTunTypeWARP CloudflareTunnelTunType = "warp"` - `const CloudflareTunnelTunTypeMagic CloudflareTunnelTunType = "magic"` - `const CloudflareTunnelTunTypeIPSec CloudflareTunnelTunType = "ip_sec"` - `const CloudflareTunnelTunTypeGRE CloudflareTunnelTunType = "gre"` - `const CloudflareTunnelTunTypeCNI CloudflareTunnelTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cloudflareTunnel, err := client.ZeroTrust.Tunnels.Cloudflared.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cloudflareTunnel.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", "account_tag": "699d98642c564d2e855e9661899b7252", "config_src": "cloudflare", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "remote_config": true, "status": "healthy", "tun_type": "cfd_tunnel" }, "success": true } ``` ## Create a Cloudflare Tunnel `client.ZeroTrust.Tunnels.Cloudflared.New(ctx, params) (*CloudflareTunnel, error)` **post** `/accounts/{account_id}/cfd_tunnel` Creates a new Cloudflare Tunnel in an account. ### Parameters - `params TunnelCloudflaredNewParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Name param.Field[string]` Body param: A user-friendly name for a tunnel. - `ConfigSrc param.Field[TunnelCloudflaredNewParamsConfigSrc]` Body param: Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard. - `const TunnelCloudflaredNewParamsConfigSrcLocal TunnelCloudflaredNewParamsConfigSrc = "local"` - `const TunnelCloudflaredNewParamsConfigSrcCloudflare TunnelCloudflaredNewParamsConfigSrc = "cloudflare"` - `TunnelSecret param.Field[string]` Body param: Sets the password required to run a locally-managed tunnel. Must be at least 32 bytes and encoded as a base64 string. ### Returns - `type CloudflareTunnel struct{…}` A Cloudflare Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `ConfigSrc CloudflareTunnelConfigSrc` Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard. - `const CloudflareTunnelConfigSrcLocal CloudflareTunnelConfigSrc = "local"` - `const CloudflareTunnelConfigSrcCloudflare CloudflareTunnelConfigSrc = "cloudflare"` - `Connections []CloudflareTunnelConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `RemoteConfig bool` If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. If `false`, the tunnel must be configured locally on the origin machine. - `Status CloudflareTunnelStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const CloudflareTunnelStatusInactive CloudflareTunnelStatus = "inactive"` - `const CloudflareTunnelStatusDegraded CloudflareTunnelStatus = "degraded"` - `const CloudflareTunnelStatusHealthy CloudflareTunnelStatus = "healthy"` - `const CloudflareTunnelStatusDown CloudflareTunnelStatus = "down"` - `TunType CloudflareTunnelTunType` The type of tunnel. - `const CloudflareTunnelTunTypeCfdTunnel CloudflareTunnelTunType = "cfd_tunnel"` - `const CloudflareTunnelTunTypeWARPConnector CloudflareTunnelTunType = "warp_connector"` - `const CloudflareTunnelTunTypeWARP CloudflareTunnelTunType = "warp"` - `const CloudflareTunnelTunTypeMagic CloudflareTunnelTunType = "magic"` - `const CloudflareTunnelTunTypeIPSec CloudflareTunnelTunType = "ip_sec"` - `const CloudflareTunnelTunTypeGRE CloudflareTunnelTunType = "gre"` - `const CloudflareTunnelTunTypeCNI CloudflareTunnelTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cloudflareTunnel, err := client.ZeroTrust.Tunnels.Cloudflared.New(context.TODO(), zero_trust.TunnelCloudflaredNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Name: cloudflare.F("blog"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cloudflareTunnel.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", "account_tag": "699d98642c564d2e855e9661899b7252", "config_src": "cloudflare", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "remote_config": true, "status": "healthy", "tun_type": "cfd_tunnel" }, "success": true } ``` ## Update a Cloudflare Tunnel `client.ZeroTrust.Tunnels.Cloudflared.Edit(ctx, tunnelID, params) (*CloudflareTunnel, error)` **patch** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}` Updates an existing Cloudflare Tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `params TunnelCloudflaredEditParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Name param.Field[string]` Body param: A user-friendly name for a tunnel. - `TunnelSecret param.Field[string]` Body param: Sets the password required to run a locally-managed tunnel. Must be at least 32 bytes and encoded as a base64 string. ### Returns - `type CloudflareTunnel struct{…}` A Cloudflare Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `ConfigSrc CloudflareTunnelConfigSrc` Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard. - `const CloudflareTunnelConfigSrcLocal CloudflareTunnelConfigSrc = "local"` - `const CloudflareTunnelConfigSrcCloudflare CloudflareTunnelConfigSrc = "cloudflare"` - `Connections []CloudflareTunnelConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `RemoteConfig bool` If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. If `false`, the tunnel must be configured locally on the origin machine. - `Status CloudflareTunnelStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const CloudflareTunnelStatusInactive CloudflareTunnelStatus = "inactive"` - `const CloudflareTunnelStatusDegraded CloudflareTunnelStatus = "degraded"` - `const CloudflareTunnelStatusHealthy CloudflareTunnelStatus = "healthy"` - `const CloudflareTunnelStatusDown CloudflareTunnelStatus = "down"` - `TunType CloudflareTunnelTunType` The type of tunnel. - `const CloudflareTunnelTunTypeCfdTunnel CloudflareTunnelTunType = "cfd_tunnel"` - `const CloudflareTunnelTunTypeWARPConnector CloudflareTunnelTunType = "warp_connector"` - `const CloudflareTunnelTunTypeWARP CloudflareTunnelTunType = "warp"` - `const CloudflareTunnelTunTypeMagic CloudflareTunnelTunType = "magic"` - `const CloudflareTunnelTunTypeIPSec CloudflareTunnelTunType = "ip_sec"` - `const CloudflareTunnelTunTypeGRE CloudflareTunnelTunType = "gre"` - `const CloudflareTunnelTunTypeCNI CloudflareTunnelTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cloudflareTunnel, err := client.ZeroTrust.Tunnels.Cloudflared.Edit( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cloudflareTunnel.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", "account_tag": "699d98642c564d2e855e9661899b7252", "config_src": "cloudflare", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "remote_config": true, "status": "healthy", "tun_type": "cfd_tunnel" }, "success": true } ``` ## Delete a Cloudflare Tunnel `client.ZeroTrust.Tunnels.Cloudflared.Delete(ctx, tunnelID, body) (*CloudflareTunnel, error)` **delete** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}` Deletes a Cloudflare Tunnel from an account. ### Parameters - `tunnelID string` UUID of the tunnel. - `body TunnelCloudflaredDeleteParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type CloudflareTunnel struct{…}` A Cloudflare Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `ConfigSrc CloudflareTunnelConfigSrc` Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard. - `const CloudflareTunnelConfigSrcLocal CloudflareTunnelConfigSrc = "local"` - `const CloudflareTunnelConfigSrcCloudflare CloudflareTunnelConfigSrc = "cloudflare"` - `Connections []CloudflareTunnelConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `RemoteConfig bool` If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. If `false`, the tunnel must be configured locally on the origin machine. - `Status CloudflareTunnelStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const CloudflareTunnelStatusInactive CloudflareTunnelStatus = "inactive"` - `const CloudflareTunnelStatusDegraded CloudflareTunnelStatus = "degraded"` - `const CloudflareTunnelStatusHealthy CloudflareTunnelStatus = "healthy"` - `const CloudflareTunnelStatusDown CloudflareTunnelStatus = "down"` - `TunType CloudflareTunnelTunType` The type of tunnel. - `const CloudflareTunnelTunTypeCfdTunnel CloudflareTunnelTunType = "cfd_tunnel"` - `const CloudflareTunnelTunTypeWARPConnector CloudflareTunnelTunType = "warp_connector"` - `const CloudflareTunnelTunTypeWARP CloudflareTunnelTunType = "warp"` - `const CloudflareTunnelTunTypeMagic CloudflareTunnelTunType = "magic"` - `const CloudflareTunnelTunTypeIPSec CloudflareTunnelTunType = "ip_sec"` - `const CloudflareTunnelTunTypeGRE CloudflareTunnelTunType = "gre"` - `const CloudflareTunnelTunTypeCNI CloudflareTunnelTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) cloudflareTunnel, err := client.ZeroTrust.Tunnels.Cloudflared.Delete( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", cloudflareTunnel.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", "account_tag": "699d98642c564d2e855e9661899b7252", "config_src": "cloudflare", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "remote_config": true, "status": "healthy", "tun_type": "cfd_tunnel" }, "success": true } ``` # Configurations ## Get configuration `client.ZeroTrust.Tunnels.Cloudflared.Configurations.Get(ctx, tunnelID, query) (*TunnelCloudflaredConfigurationGetResponse, error)` **get** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations` Gets the configuration for a remotely-managed tunnel ### Parameters - `tunnelID string` UUID of the tunnel. - `query TunnelCloudflaredConfigurationGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type TunnelCloudflaredConfigurationGetResponse struct{…}` Cloudflare Tunnel configuration - `AccountID string` Identifier. - `Config TunnelCloudflaredConfigurationGetResponseConfig` The tunnel configuration and ingress rules. - `Ingress []TunnelCloudflaredConfigurationGetResponseConfigIngress` List of public hostname definitions. At least one ingress rule needs to be defined for the tunnel. - `Hostname string` Public hostname for this service. - `Service string` Protocol and address of destination server. Supported protocols: http://, https://, unix://, tcp://, ssh://, rdp://, unix+tls://, smb://. Alternatively can return a HTTP status code http_status:[code] e.g. 'http_status:404'. - `OriginRequest TunnelCloudflaredConfigurationGetResponseConfigIngressOriginRequest` Configuration parameters for the public hostname specific connection settings between cloudflared and origin server. - `Access TunnelCloudflaredConfigurationGetResponseConfigIngressOriginRequestAccess` For all L7 requests to this hostname, cloudflared will validate each request's Cf-Access-Jwt-Assertion request header. - `AUDTag []string` Access applications that are allowed to reach this hostname for this Tunnel. Audience tags can be identified in the dashboard or via the List Access policies API. - `TeamName string` - `Required bool` Deny traffic that has not fulfilled Access authorization. - `CAPool string` Path to the certificate authority (CA) for the certificate of your origin. This option should be used only if your certificate is not signed by Cloudflare. - `ConnectTimeout int64` Timeout for establishing a new TCP connection to your origin server. This excludes the time taken to establish TLS, which is controlled by tlsTimeout. - `DisableChunkedEncoding bool` Disables chunked transfer encoding. Useful if you are running a WSGI server. - `HTTP2Origin bool` Attempt to connect to origin using HTTP2. Origin must be configured as https. - `HTTPHostHeader string` Sets the HTTP Host header on requests sent to the local service. - `KeepAliveConnections int64` Maximum number of idle keepalive connections between Tunnel and your origin. This does not restrict the total number of concurrent connections. - `KeepAliveTimeout int64` Timeout after which an idle keepalive connection can be discarded. - `MatchSnItoHost bool` Auto configure the Hostname on the origin server certificate. - `NoHappyEyeballs bool` Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local network has misconfigured one of the protocols. - `NoTLSVerify bool` Disables TLS verification of the certificate presented by your origin. Will allow any certificate from the origin to be accepted. - `OriginServerName string` Hostname that cloudflared should expect from your origin server certificate. - `ProxyType string` cloudflared starts a proxy server to translate HTTP traffic into TCP when proxying, for example, SSH or RDP. This configures what type of proxy will be started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 proxy. - `TCPKeepAlive int64` The timeout after which a TCP keepalive packet is sent on a connection between Tunnel and the origin server. - `TLSTimeout int64` Timeout for completing a TLS handshake to your origin server, if you have chosen to connect Tunnel to an HTTPS server. - `Path string` Requests with this path route to this public hostname. - `OriginRequest TunnelCloudflaredConfigurationGetResponseConfigOriginRequest` Configuration parameters for the public hostname specific connection settings between cloudflared and origin server. - `Access TunnelCloudflaredConfigurationGetResponseConfigOriginRequestAccess` For all L7 requests to this hostname, cloudflared will validate each request's Cf-Access-Jwt-Assertion request header. - `AUDTag []string` Access applications that are allowed to reach this hostname for this Tunnel. Audience tags can be identified in the dashboard or via the List Access policies API. - `TeamName string` - `Required bool` Deny traffic that has not fulfilled Access authorization. - `CAPool string` Path to the certificate authority (CA) for the certificate of your origin. This option should be used only if your certificate is not signed by Cloudflare. - `ConnectTimeout int64` Timeout for establishing a new TCP connection to your origin server. This excludes the time taken to establish TLS, which is controlled by tlsTimeout. - `DisableChunkedEncoding bool` Disables chunked transfer encoding. Useful if you are running a WSGI server. - `HTTP2Origin bool` Attempt to connect to origin using HTTP2. Origin must be configured as https. - `HTTPHostHeader string` Sets the HTTP Host header on requests sent to the local service. - `KeepAliveConnections int64` Maximum number of idle keepalive connections between Tunnel and your origin. This does not restrict the total number of concurrent connections. - `KeepAliveTimeout int64` Timeout after which an idle keepalive connection can be discarded. - `MatchSnItoHost bool` Auto configure the Hostname on the origin server certificate. - `NoHappyEyeballs bool` Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local network has misconfigured one of the protocols. - `NoTLSVerify bool` Disables TLS verification of the certificate presented by your origin. Will allow any certificate from the origin to be accepted. - `OriginServerName string` Hostname that cloudflared should expect from your origin server certificate. - `ProxyType string` cloudflared starts a proxy server to translate HTTP traffic into TCP when proxying, for example, SSH or RDP. This configures what type of proxy will be started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 proxy. - `TCPKeepAlive int64` The timeout after which a TCP keepalive packet is sent on a connection between Tunnel and the origin server. - `TLSTimeout int64` Timeout for completing a TLS handshake to your origin server, if you have chosen to connect Tunnel to an HTTPS server. - `CreatedAt Time` - `Source TunnelCloudflaredConfigurationGetResponseSource` Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel's configuration on the Zero Trust dashboard. - `const TunnelCloudflaredConfigurationGetResponseSourceLocal TunnelCloudflaredConfigurationGetResponseSource = "local"` - `const TunnelCloudflaredConfigurationGetResponseSourceCloudflare TunnelCloudflaredConfigurationGetResponseSource = "cloudflare"` - `TunnelID string` UUID of the tunnel. - `Version int64` The version of the Tunnel Configuration. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) configuration, err := client.ZeroTrust.Tunnels.Cloudflared.Configurations.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredConfigurationGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", configuration.AccountID) } ``` #### 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" } } ], "success": true, "result": { "account_id": "023e105f4ecef8ad9ca31a8372d0c353", "config": { "ingress": [ { "hostname": "tunnel.example.com", "service": "https://localhost:8001", "originRequest": { "access": { "audTag": [ "string" ], "teamName": "zero-trust-organization-name", "required": false }, "caPool": "caPool", "connectTimeout": 10, "disableChunkedEncoding": true, "http2Origin": true, "httpHostHeader": "httpHostHeader", "keepAliveConnections": 100, "keepAliveTimeout": 90, "matchSNItoHost": false, "noHappyEyeballs": false, "noTLSVerify": false, "originServerName": "originServerName", "proxyType": "proxyType", "tcpKeepAlive": 30, "tlsTimeout": 10 }, "path": "subpath" } ], "originRequest": { "access": { "audTag": [ "string" ], "teamName": "zero-trust-organization-name", "required": false }, "caPool": "caPool", "connectTimeout": 10, "disableChunkedEncoding": true, "http2Origin": true, "httpHostHeader": "httpHostHeader", "keepAliveConnections": 100, "keepAliveTimeout": 90, "matchSNItoHost": false, "noHappyEyeballs": false, "noTLSVerify": false, "originServerName": "originServerName", "proxyType": "proxyType", "tcpKeepAlive": 30, "tlsTimeout": 10 }, "warp-routing": { "enabled": true } }, "created_at": "2014-01-01T05:20:00.12345Z", "source": "cloudflare", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "version": 0 } } ``` ## Put configuration `client.ZeroTrust.Tunnels.Cloudflared.Configurations.Update(ctx, tunnelID, params) (*TunnelCloudflaredConfigurationUpdateResponse, error)` **put** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}/configurations` Adds or updates the configuration for a remotely-managed tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `params TunnelCloudflaredConfigurationUpdateParams` - `AccountID param.Field[string]` Path param: Identifier. - `Config param.Field[TunnelCloudflaredConfigurationUpdateParamsConfig]` Body param: The tunnel configuration and ingress rules. - `Ingress []TunnelCloudflaredConfigurationUpdateParamsConfigIngress` List of public hostname definitions. At least one ingress rule needs to be defined for the tunnel. - `Hostname string` Public hostname for this service. - `Service string` Protocol and address of destination server. Supported protocols: http://, https://, unix://, tcp://, ssh://, rdp://, unix+tls://, smb://. Alternatively can return a HTTP status code http_status:[code] e.g. 'http_status:404'. - `OriginRequest TunnelCloudflaredConfigurationUpdateParamsConfigIngressOriginRequest` Configuration parameters for the public hostname specific connection settings between cloudflared and origin server. - `Access TunnelCloudflaredConfigurationUpdateParamsConfigIngressOriginRequestAccess` For all L7 requests to this hostname, cloudflared will validate each request's Cf-Access-Jwt-Assertion request header. - `AUDTag []string` Access applications that are allowed to reach this hostname for this Tunnel. Audience tags can be identified in the dashboard or via the List Access policies API. - `TeamName string` - `Required bool` Deny traffic that has not fulfilled Access authorization. - `CAPool string` Path to the certificate authority (CA) for the certificate of your origin. This option should be used only if your certificate is not signed by Cloudflare. - `ConnectTimeout int64` Timeout for establishing a new TCP connection to your origin server. This excludes the time taken to establish TLS, which is controlled by tlsTimeout. - `DisableChunkedEncoding bool` Disables chunked transfer encoding. Useful if you are running a WSGI server. - `HTTP2Origin bool` Attempt to connect to origin using HTTP2. Origin must be configured as https. - `HTTPHostHeader string` Sets the HTTP Host header on requests sent to the local service. - `KeepAliveConnections int64` Maximum number of idle keepalive connections between Tunnel and your origin. This does not restrict the total number of concurrent connections. - `KeepAliveTimeout int64` Timeout after which an idle keepalive connection can be discarded. - `MatchSnItoHost bool` Auto configure the Hostname on the origin server certificate. - `NoHappyEyeballs bool` Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local network has misconfigured one of the protocols. - `NoTLSVerify bool` Disables TLS verification of the certificate presented by your origin. Will allow any certificate from the origin to be accepted. - `OriginServerName string` Hostname that cloudflared should expect from your origin server certificate. - `ProxyType string` cloudflared starts a proxy server to translate HTTP traffic into TCP when proxying, for example, SSH or RDP. This configures what type of proxy will be started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 proxy. - `TCPKeepAlive int64` The timeout after which a TCP keepalive packet is sent on a connection between Tunnel and the origin server. - `TLSTimeout int64` Timeout for completing a TLS handshake to your origin server, if you have chosen to connect Tunnel to an HTTPS server. - `Path string` Requests with this path route to this public hostname. - `OriginRequest TunnelCloudflaredConfigurationUpdateParamsConfigOriginRequest` Configuration parameters for the public hostname specific connection settings between cloudflared and origin server. - `Access TunnelCloudflaredConfigurationUpdateParamsConfigOriginRequestAccess` For all L7 requests to this hostname, cloudflared will validate each request's Cf-Access-Jwt-Assertion request header. - `AUDTag []string` Access applications that are allowed to reach this hostname for this Tunnel. Audience tags can be identified in the dashboard or via the List Access policies API. - `TeamName string` - `Required bool` Deny traffic that has not fulfilled Access authorization. - `CAPool string` Path to the certificate authority (CA) for the certificate of your origin. This option should be used only if your certificate is not signed by Cloudflare. - `ConnectTimeout int64` Timeout for establishing a new TCP connection to your origin server. This excludes the time taken to establish TLS, which is controlled by tlsTimeout. - `DisableChunkedEncoding bool` Disables chunked transfer encoding. Useful if you are running a WSGI server. - `HTTP2Origin bool` Attempt to connect to origin using HTTP2. Origin must be configured as https. - `HTTPHostHeader string` Sets the HTTP Host header on requests sent to the local service. - `KeepAliveConnections int64` Maximum number of idle keepalive connections between Tunnel and your origin. This does not restrict the total number of concurrent connections. - `KeepAliveTimeout int64` Timeout after which an idle keepalive connection can be discarded. - `MatchSnItoHost bool` Auto configure the Hostname on the origin server certificate. - `NoHappyEyeballs bool` Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local network has misconfigured one of the protocols. - `NoTLSVerify bool` Disables TLS verification of the certificate presented by your origin. Will allow any certificate from the origin to be accepted. - `OriginServerName string` Hostname that cloudflared should expect from your origin server certificate. - `ProxyType string` cloudflared starts a proxy server to translate HTTP traffic into TCP when proxying, for example, SSH or RDP. This configures what type of proxy will be started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 proxy. - `TCPKeepAlive int64` The timeout after which a TCP keepalive packet is sent on a connection between Tunnel and the origin server. - `TLSTimeout int64` Timeout for completing a TLS handshake to your origin server, if you have chosen to connect Tunnel to an HTTPS server. ### Returns - `type TunnelCloudflaredConfigurationUpdateResponse struct{…}` Cloudflare Tunnel configuration - `AccountID string` Identifier. - `Config TunnelCloudflaredConfigurationUpdateResponseConfig` The tunnel configuration and ingress rules. - `Ingress []TunnelCloudflaredConfigurationUpdateResponseConfigIngress` List of public hostname definitions. At least one ingress rule needs to be defined for the tunnel. - `Hostname string` Public hostname for this service. - `Service string` Protocol and address of destination server. Supported protocols: http://, https://, unix://, tcp://, ssh://, rdp://, unix+tls://, smb://. Alternatively can return a HTTP status code http_status:[code] e.g. 'http_status:404'. - `OriginRequest TunnelCloudflaredConfigurationUpdateResponseConfigIngressOriginRequest` Configuration parameters for the public hostname specific connection settings between cloudflared and origin server. - `Access TunnelCloudflaredConfigurationUpdateResponseConfigIngressOriginRequestAccess` For all L7 requests to this hostname, cloudflared will validate each request's Cf-Access-Jwt-Assertion request header. - `AUDTag []string` Access applications that are allowed to reach this hostname for this Tunnel. Audience tags can be identified in the dashboard or via the List Access policies API. - `TeamName string` - `Required bool` Deny traffic that has not fulfilled Access authorization. - `CAPool string` Path to the certificate authority (CA) for the certificate of your origin. This option should be used only if your certificate is not signed by Cloudflare. - `ConnectTimeout int64` Timeout for establishing a new TCP connection to your origin server. This excludes the time taken to establish TLS, which is controlled by tlsTimeout. - `DisableChunkedEncoding bool` Disables chunked transfer encoding. Useful if you are running a WSGI server. - `HTTP2Origin bool` Attempt to connect to origin using HTTP2. Origin must be configured as https. - `HTTPHostHeader string` Sets the HTTP Host header on requests sent to the local service. - `KeepAliveConnections int64` Maximum number of idle keepalive connections between Tunnel and your origin. This does not restrict the total number of concurrent connections. - `KeepAliveTimeout int64` Timeout after which an idle keepalive connection can be discarded. - `MatchSnItoHost bool` Auto configure the Hostname on the origin server certificate. - `NoHappyEyeballs bool` Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local network has misconfigured one of the protocols. - `NoTLSVerify bool` Disables TLS verification of the certificate presented by your origin. Will allow any certificate from the origin to be accepted. - `OriginServerName string` Hostname that cloudflared should expect from your origin server certificate. - `ProxyType string` cloudflared starts a proxy server to translate HTTP traffic into TCP when proxying, for example, SSH or RDP. This configures what type of proxy will be started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 proxy. - `TCPKeepAlive int64` The timeout after which a TCP keepalive packet is sent on a connection between Tunnel and the origin server. - `TLSTimeout int64` Timeout for completing a TLS handshake to your origin server, if you have chosen to connect Tunnel to an HTTPS server. - `Path string` Requests with this path route to this public hostname. - `OriginRequest TunnelCloudflaredConfigurationUpdateResponseConfigOriginRequest` Configuration parameters for the public hostname specific connection settings between cloudflared and origin server. - `Access TunnelCloudflaredConfigurationUpdateResponseConfigOriginRequestAccess` For all L7 requests to this hostname, cloudflared will validate each request's Cf-Access-Jwt-Assertion request header. - `AUDTag []string` Access applications that are allowed to reach this hostname for this Tunnel. Audience tags can be identified in the dashboard or via the List Access policies API. - `TeamName string` - `Required bool` Deny traffic that has not fulfilled Access authorization. - `CAPool string` Path to the certificate authority (CA) for the certificate of your origin. This option should be used only if your certificate is not signed by Cloudflare. - `ConnectTimeout int64` Timeout for establishing a new TCP connection to your origin server. This excludes the time taken to establish TLS, which is controlled by tlsTimeout. - `DisableChunkedEncoding bool` Disables chunked transfer encoding. Useful if you are running a WSGI server. - `HTTP2Origin bool` Attempt to connect to origin using HTTP2. Origin must be configured as https. - `HTTPHostHeader string` Sets the HTTP Host header on requests sent to the local service. - `KeepAliveConnections int64` Maximum number of idle keepalive connections between Tunnel and your origin. This does not restrict the total number of concurrent connections. - `KeepAliveTimeout int64` Timeout after which an idle keepalive connection can be discarded. - `MatchSnItoHost bool` Auto configure the Hostname on the origin server certificate. - `NoHappyEyeballs bool` Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local network has misconfigured one of the protocols. - `NoTLSVerify bool` Disables TLS verification of the certificate presented by your origin. Will allow any certificate from the origin to be accepted. - `OriginServerName string` Hostname that cloudflared should expect from your origin server certificate. - `ProxyType string` cloudflared starts a proxy server to translate HTTP traffic into TCP when proxying, for example, SSH or RDP. This configures what type of proxy will be started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 proxy. - `TCPKeepAlive int64` The timeout after which a TCP keepalive packet is sent on a connection between Tunnel and the origin server. - `TLSTimeout int64` Timeout for completing a TLS handshake to your origin server, if you have chosen to connect Tunnel to an HTTPS server. - `CreatedAt Time` - `Source TunnelCloudflaredConfigurationUpdateResponseSource` Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel's configuration on the Zero Trust dashboard. - `const TunnelCloudflaredConfigurationUpdateResponseSourceLocal TunnelCloudflaredConfigurationUpdateResponseSource = "local"` - `const TunnelCloudflaredConfigurationUpdateResponseSourceCloudflare TunnelCloudflaredConfigurationUpdateResponseSource = "cloudflare"` - `TunnelID string` UUID of the tunnel. - `Version int64` The version of the Tunnel Configuration. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) configuration, err := client.ZeroTrust.Tunnels.Cloudflared.Configurations.Update( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredConfigurationUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", configuration.AccountID) } ``` #### 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" } } ], "success": true, "result": { "account_id": "023e105f4ecef8ad9ca31a8372d0c353", "config": { "ingress": [ { "hostname": "tunnel.example.com", "service": "https://localhost:8001", "originRequest": { "access": { "audTag": [ "string" ], "teamName": "zero-trust-organization-name", "required": false }, "caPool": "caPool", "connectTimeout": 10, "disableChunkedEncoding": true, "http2Origin": true, "httpHostHeader": "httpHostHeader", "keepAliveConnections": 100, "keepAliveTimeout": 90, "matchSNItoHost": false, "noHappyEyeballs": false, "noTLSVerify": false, "originServerName": "originServerName", "proxyType": "proxyType", "tcpKeepAlive": 30, "tlsTimeout": 10 }, "path": "subpath" } ], "originRequest": { "access": { "audTag": [ "string" ], "teamName": "zero-trust-organization-name", "required": false }, "caPool": "caPool", "connectTimeout": 10, "disableChunkedEncoding": true, "http2Origin": true, "httpHostHeader": "httpHostHeader", "keepAliveConnections": 100, "keepAliveTimeout": 90, "matchSNItoHost": false, "noHappyEyeballs": false, "noTLSVerify": false, "originServerName": "originServerName", "proxyType": "proxyType", "tcpKeepAlive": 30, "tlsTimeout": 10 }, "warp-routing": { "enabled": true } }, "created_at": "2014-01-01T05:20:00.12345Z", "source": "cloudflare", "tunnel_id": "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "version": 0 } } ``` # Connections ## List Cloudflare Tunnel connections `client.ZeroTrust.Tunnels.Cloudflared.Connections.Get(ctx, tunnelID, query) (*SinglePage[Client], error)` **get** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections` Fetches connection details for a Cloudflare Tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `query TunnelCloudflaredConnectionGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type Client struct{…}` A client (typically cloudflared) that maintains connections to a Cloudflare data center. - `ID string` UUID of the Cloudflare Tunnel connection. - `Arch string` The cloudflared OS architecture used to establish this connection. - `ConfigVersion int64` The version of the remote tunnel configuration. Used internally to sync cloudflared with the Zero Trust dashboard. - `Conns []ClientConn` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `Features []string` Features enabled for the Cloudflare Tunnel. - `RunAt Time` Timestamp of when the tunnel connection was started. - `Version string` The cloudflared version used to establish this connection. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Tunnels.Cloudflared.Connections.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredConnectionGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "arch": "linux_amd64", "config_version": 0, "conns": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "features": [ "ha-origin" ], "run_at": "2009-11-10T23:00:00Z", "version": "2022.7.1" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Clean up Cloudflare Tunnel connections `client.ZeroTrust.Tunnels.Cloudflared.Connections.Delete(ctx, tunnelID, params) (*TunnelCloudflaredConnectionDeleteResponse, error)` **delete** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connections` Removes a connection (aka Cloudflare Tunnel Connector) from a Cloudflare Tunnel independently of its current state. If no connector id (client_id) is provided all connectors will be removed. We recommend running this command after rotating tokens. ### Parameters - `tunnelID string` UUID of the tunnel. - `params TunnelCloudflaredConnectionDeleteParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `ClientID param.Field[string]` Query param: UUID of the Cloudflare Tunnel connector. ### Returns - `type TunnelCloudflaredConnectionDeleteResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) connection, err := client.ZeroTrust.Tunnels.Cloudflared.Connections.Delete( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredConnectionDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", connection) } ``` #### 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": {}, "success": true } ``` ## Domain Types ### Client - `type Client struct{…}` A client (typically cloudflared) that maintains connections to a Cloudflare data center. - `ID string` UUID of the Cloudflare Tunnel connection. - `Arch string` The cloudflared OS architecture used to establish this connection. - `ConfigVersion int64` The version of the remote tunnel configuration. Used internally to sync cloudflared with the Zero Trust dashboard. - `Conns []ClientConn` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `Features []string` Features enabled for the Cloudflare Tunnel. - `RunAt Time` Timestamp of when the tunnel connection was started. - `Version string` The cloudflared version used to establish this connection. # Token ## Get a Cloudflare Tunnel token `client.ZeroTrust.Tunnels.Cloudflared.Token.Get(ctx, tunnelID, query) (*string, error)` **get** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}/token` Gets the token used to associate cloudflared with a specific tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `query TunnelCloudflaredTokenGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type TunnelCloudflaredTokenGetResponseEnvelopeResult string` The Tunnel Token is used as a mechanism to authenticate the operation of a tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) token, err := client.ZeroTrust.Tunnels.Cloudflared.Token.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredTokenGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", token) } ``` #### 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": "eyJhIjoiNWFiNGU5Z...", "success": true } ``` # Connectors ## Get Cloudflare Tunnel connector `client.ZeroTrust.Tunnels.Cloudflared.Connectors.Get(ctx, tunnelID, connectorID, query) (*Client, error)` **get** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}/connectors/{connector_id}` Fetches connector and connection details for a Cloudflare Tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `connectorID string` UUID of the Cloudflare Tunnel connector. - `query TunnelCloudflaredConnectorGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type Client struct{…}` A client (typically cloudflared) that maintains connections to a Cloudflare data center. - `ID string` UUID of the Cloudflare Tunnel connection. - `Arch string` The cloudflared OS architecture used to establish this connection. - `ConfigVersion int64` The version of the remote tunnel configuration. Used internally to sync cloudflared with the Zero Trust dashboard. - `Conns []ClientConn` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `Features []string` Features enabled for the Cloudflare Tunnel. - `RunAt Time` Timestamp of when the tunnel connection was started. - `Version string` The cloudflared version used to establish this connection. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) client, err := client.ZeroTrust.Tunnels.Cloudflared.Connectors.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "1bedc50d-42b3-473c-b108-ff3d10c0d925", zero_trust.TunnelCloudflaredConnectorGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", client.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": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "arch": "linux_amd64", "config_version": 0, "conns": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "features": [ "ha-origin" ], "run_at": "2009-11-10T23:00:00Z", "version": "2022.7.1" }, "success": true } ``` # Management ## Get a Cloudflare Tunnel management token `client.ZeroTrust.Tunnels.Cloudflared.Management.New(ctx, tunnelID, params) (*string, error)` **post** `/accounts/{account_id}/cfd_tunnel/{tunnel_id}/management` Gets a management token used to access the management resources (i.e. Streaming Logs) of a tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `params TunnelCloudflaredManagementNewParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Resources param.Field[[]TunnelCloudflaredManagementNewParamsResource]` Body param - `const TunnelCloudflaredManagementNewParamsResourceLogs TunnelCloudflaredManagementNewParamsResource = "logs"` ### Returns - `type TunnelCloudflaredManagementNewResponseEnvelopeResult string` The Tunnel Token is used as a mechanism to authenticate the operation of a tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) management, err := client.ZeroTrust.Tunnels.Cloudflared.Management.New( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelCloudflaredManagementNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Resources: cloudflare.F([]zero_trust.TunnelCloudflaredManagementNewParamsResource{zero_trust.TunnelCloudflaredManagementNewParamsResourceLogs}), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", management) } ``` #### 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": "eyJhIjoiNWFiNGU5Z...", "success": true } ``` # WARP Connector ## List Warp Connector Tunnels `client.ZeroTrust.Tunnels.WARPConnector.List(ctx, params) (*V4PagePaginationArray[TunnelWARPConnectorListResponse], error)` **get** `/accounts/{account_id}/warp_connector` Lists and filters Warp Connector Tunnels in an account. ### Parameters - `params TunnelWARPConnectorListParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `ExcludePrefix param.Field[string]` Query param - `ExistedAt param.Field[string]` Query param: If provided, include only resources that were created (and not deleted) before this time. URL encoded. - `IncludePrefix param.Field[string]` Query param - `IsDeleted param.Field[bool]` Query param: If `true`, only include deleted tunnels. If `false`, exclude deleted tunnels. If empty, all tunnels will be included. - `Name param.Field[string]` Query param: A user-friendly name for the tunnel. - `Page param.Field[float64]` Query param: Page number of paginated results. - `PerPage param.Field[float64]` Query param: Number of results to display. - `Status param.Field[TunnelWARPConnectorListParamsStatus]` Query param: The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelWARPConnectorListParamsStatusInactive TunnelWARPConnectorListParamsStatus = "inactive"` - `const TunnelWARPConnectorListParamsStatusDegraded TunnelWARPConnectorListParamsStatus = "degraded"` - `const TunnelWARPConnectorListParamsStatusHealthy TunnelWARPConnectorListParamsStatus = "healthy"` - `const TunnelWARPConnectorListParamsStatusDown TunnelWARPConnectorListParamsStatus = "down"` - `UUID param.Field[string]` Query param: UUID of the tunnel. - `WasActiveAt param.Field[Time]` Query param - `WasInactiveAt param.Field[Time]` Query param ### Returns - `type TunnelWARPConnectorListResponse struct{…}` A Warp Connector Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `Connections []TunnelWARPConnectorListResponseConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `Status TunnelWARPConnectorListResponseStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelWARPConnectorListResponseStatusInactive TunnelWARPConnectorListResponseStatus = "inactive"` - `const TunnelWARPConnectorListResponseStatusDegraded TunnelWARPConnectorListResponseStatus = "degraded"` - `const TunnelWARPConnectorListResponseStatusHealthy TunnelWARPConnectorListResponseStatus = "healthy"` - `const TunnelWARPConnectorListResponseStatusDown TunnelWARPConnectorListResponseStatus = "down"` - `TunType TunnelWARPConnectorListResponseTunType` The type of tunnel. - `const TunnelWARPConnectorListResponseTunTypeCfdTunnel TunnelWARPConnectorListResponseTunType = "cfd_tunnel"` - `const TunnelWARPConnectorListResponseTunTypeWARPConnector TunnelWARPConnectorListResponseTunType = "warp_connector"` - `const TunnelWARPConnectorListResponseTunTypeWARP TunnelWARPConnectorListResponseTunType = "warp"` - `const TunnelWARPConnectorListResponseTunTypeMagic TunnelWARPConnectorListResponseTunType = "magic"` - `const TunnelWARPConnectorListResponseTunTypeIPSec TunnelWARPConnectorListResponseTunType = "ip_sec"` - `const TunnelWARPConnectorListResponseTunTypeGRE TunnelWARPConnectorListResponseTunType = "gre"` - `const TunnelWARPConnectorListResponseTunTypeCNI TunnelWARPConnectorListResponseTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Tunnels.WARPConnector.List(context.TODO(), zero_trust.TunnelWARPConnectorListParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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", "account_tag": "699d98642c564d2e855e9661899b7252", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "status": "healthy", "tun_type": "cfd_tunnel" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get a Warp Connector Tunnel `client.ZeroTrust.Tunnels.WARPConnector.Get(ctx, tunnelID, query) (*TunnelWARPConnectorGetResponse, error)` **get** `/accounts/{account_id}/warp_connector/{tunnel_id}` Fetches a single Warp Connector Tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `query TunnelWARPConnectorGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type TunnelWARPConnectorGetResponse struct{…}` A Warp Connector Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `Connections []TunnelWARPConnectorGetResponseConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `Status TunnelWARPConnectorGetResponseStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelWARPConnectorGetResponseStatusInactive TunnelWARPConnectorGetResponseStatus = "inactive"` - `const TunnelWARPConnectorGetResponseStatusDegraded TunnelWARPConnectorGetResponseStatus = "degraded"` - `const TunnelWARPConnectorGetResponseStatusHealthy TunnelWARPConnectorGetResponseStatus = "healthy"` - `const TunnelWARPConnectorGetResponseStatusDown TunnelWARPConnectorGetResponseStatus = "down"` - `TunType TunnelWARPConnectorGetResponseTunType` The type of tunnel. - `const TunnelWARPConnectorGetResponseTunTypeCfdTunnel TunnelWARPConnectorGetResponseTunType = "cfd_tunnel"` - `const TunnelWARPConnectorGetResponseTunTypeWARPConnector TunnelWARPConnectorGetResponseTunType = "warp_connector"` - `const TunnelWARPConnectorGetResponseTunTypeWARP TunnelWARPConnectorGetResponseTunType = "warp"` - `const TunnelWARPConnectorGetResponseTunTypeMagic TunnelWARPConnectorGetResponseTunType = "magic"` - `const TunnelWARPConnectorGetResponseTunTypeIPSec TunnelWARPConnectorGetResponseTunType = "ip_sec"` - `const TunnelWARPConnectorGetResponseTunTypeGRE TunnelWARPConnectorGetResponseTunType = "gre"` - `const TunnelWARPConnectorGetResponseTunTypeCNI TunnelWARPConnectorGetResponseTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) warpConnector, err := client.ZeroTrust.Tunnels.WARPConnector.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelWARPConnectorGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", warpConnector.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", "account_tag": "699d98642c564d2e855e9661899b7252", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "status": "healthy", "tun_type": "cfd_tunnel" }, "success": true } ``` ## Create a Warp Connector Tunnel `client.ZeroTrust.Tunnels.WARPConnector.New(ctx, params) (*TunnelWARPConnectorNewResponse, error)` **post** `/accounts/{account_id}/warp_connector` Creates a new Warp Connector Tunnel in an account. ### Parameters - `params TunnelWARPConnectorNewParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Name param.Field[string]` Body param: A user-friendly name for a tunnel. - `Ha param.Field[bool]` Body param: Indicates that the tunnel will be created to be highly available. If omitted, defaults to false. ### Returns - `type TunnelWARPConnectorNewResponse struct{…}` A Warp Connector Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `Connections []TunnelWARPConnectorNewResponseConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `Status TunnelWARPConnectorNewResponseStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelWARPConnectorNewResponseStatusInactive TunnelWARPConnectorNewResponseStatus = "inactive"` - `const TunnelWARPConnectorNewResponseStatusDegraded TunnelWARPConnectorNewResponseStatus = "degraded"` - `const TunnelWARPConnectorNewResponseStatusHealthy TunnelWARPConnectorNewResponseStatus = "healthy"` - `const TunnelWARPConnectorNewResponseStatusDown TunnelWARPConnectorNewResponseStatus = "down"` - `TunType TunnelWARPConnectorNewResponseTunType` The type of tunnel. - `const TunnelWARPConnectorNewResponseTunTypeCfdTunnel TunnelWARPConnectorNewResponseTunType = "cfd_tunnel"` - `const TunnelWARPConnectorNewResponseTunTypeWARPConnector TunnelWARPConnectorNewResponseTunType = "warp_connector"` - `const TunnelWARPConnectorNewResponseTunTypeWARP TunnelWARPConnectorNewResponseTunType = "warp"` - `const TunnelWARPConnectorNewResponseTunTypeMagic TunnelWARPConnectorNewResponseTunType = "magic"` - `const TunnelWARPConnectorNewResponseTunTypeIPSec TunnelWARPConnectorNewResponseTunType = "ip_sec"` - `const TunnelWARPConnectorNewResponseTunTypeGRE TunnelWARPConnectorNewResponseTunType = "gre"` - `const TunnelWARPConnectorNewResponseTunTypeCNI TunnelWARPConnectorNewResponseTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) warpConnector, err := client.ZeroTrust.Tunnels.WARPConnector.New(context.TODO(), zero_trust.TunnelWARPConnectorNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Name: cloudflare.F("blog"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", warpConnector.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", "account_tag": "699d98642c564d2e855e9661899b7252", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "status": "healthy", "tun_type": "cfd_tunnel" }, "success": true } ``` ## Update a Warp Connector Tunnel `client.ZeroTrust.Tunnels.WARPConnector.Edit(ctx, tunnelID, params) (*TunnelWARPConnectorEditResponse, error)` **patch** `/accounts/{account_id}/warp_connector/{tunnel_id}` Updates an existing Warp Connector Tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `params TunnelWARPConnectorEditParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `Name param.Field[string]` Body param: A user-friendly name for a tunnel. - `TunnelSecret param.Field[string]` Body param: Sets the password required to run a locally-managed tunnel. Must be at least 32 bytes and encoded as a base64 string. ### Returns - `type TunnelWARPConnectorEditResponse struct{…}` A Warp Connector Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `Connections []TunnelWARPConnectorEditResponseConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `Status TunnelWARPConnectorEditResponseStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelWARPConnectorEditResponseStatusInactive TunnelWARPConnectorEditResponseStatus = "inactive"` - `const TunnelWARPConnectorEditResponseStatusDegraded TunnelWARPConnectorEditResponseStatus = "degraded"` - `const TunnelWARPConnectorEditResponseStatusHealthy TunnelWARPConnectorEditResponseStatus = "healthy"` - `const TunnelWARPConnectorEditResponseStatusDown TunnelWARPConnectorEditResponseStatus = "down"` - `TunType TunnelWARPConnectorEditResponseTunType` The type of tunnel. - `const TunnelWARPConnectorEditResponseTunTypeCfdTunnel TunnelWARPConnectorEditResponseTunType = "cfd_tunnel"` - `const TunnelWARPConnectorEditResponseTunTypeWARPConnector TunnelWARPConnectorEditResponseTunType = "warp_connector"` - `const TunnelWARPConnectorEditResponseTunTypeWARP TunnelWARPConnectorEditResponseTunType = "warp"` - `const TunnelWARPConnectorEditResponseTunTypeMagic TunnelWARPConnectorEditResponseTunType = "magic"` - `const TunnelWARPConnectorEditResponseTunTypeIPSec TunnelWARPConnectorEditResponseTunType = "ip_sec"` - `const TunnelWARPConnectorEditResponseTunTypeGRE TunnelWARPConnectorEditResponseTunType = "gre"` - `const TunnelWARPConnectorEditResponseTunTypeCNI TunnelWARPConnectorEditResponseTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.ZeroTrust.Tunnels.WARPConnector.Edit( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelWARPConnectorEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.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", "account_tag": "699d98642c564d2e855e9661899b7252", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "status": "healthy", "tun_type": "cfd_tunnel" }, "success": true } ``` ## Delete a Warp Connector Tunnel `client.ZeroTrust.Tunnels.WARPConnector.Delete(ctx, tunnelID, body) (*TunnelWARPConnectorDeleteResponse, error)` **delete** `/accounts/{account_id}/warp_connector/{tunnel_id}` Deletes a Warp Connector Tunnel from an account. ### Parameters - `tunnelID string` UUID of the tunnel. - `body TunnelWARPConnectorDeleteParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type TunnelWARPConnectorDeleteResponse struct{…}` A Warp Connector Tunnel that connects your origin to Cloudflare's edge. - `ID string` UUID of the tunnel. - `AccountTag string` Cloudflare account ID - `Connections []TunnelWARPConnectorDeleteResponseConnection` The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `IsPendingReconnect bool` Cloudflare continues to track connections for several minutes after they disconnect. This is an optimization to improve latency and reliability of reconnecting. If `true`, the connection has disconnected but is still being tracked. If `false`, the connection is actively serving traffic. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running cloudflared. - `UUID string` UUID of the Cloudflare Tunnel connection. - `ConnsActiveAt Time` Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If `null`, the tunnel is inactive. - `ConnsInactiveAt Time` Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If `null`, the tunnel is active. - `CreatedAt Time` Timestamp of when the resource was created. - `DeletedAt Time` Timestamp of when the resource was deleted. If `null`, the resource has not been deleted. - `Metadata unknown` Metadata associated with the tunnel. - `Name string` A user-friendly name for a tunnel. - `Status TunnelWARPConnectorDeleteResponseStatus` The status of the tunnel. Valid values are `inactive` (tunnel has never been run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy state), `healthy` (tunnel is active and able to serve traffic), or `down` (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - `const TunnelWARPConnectorDeleteResponseStatusInactive TunnelWARPConnectorDeleteResponseStatus = "inactive"` - `const TunnelWARPConnectorDeleteResponseStatusDegraded TunnelWARPConnectorDeleteResponseStatus = "degraded"` - `const TunnelWARPConnectorDeleteResponseStatusHealthy TunnelWARPConnectorDeleteResponseStatus = "healthy"` - `const TunnelWARPConnectorDeleteResponseStatusDown TunnelWARPConnectorDeleteResponseStatus = "down"` - `TunType TunnelWARPConnectorDeleteResponseTunType` The type of tunnel. - `const TunnelWARPConnectorDeleteResponseTunTypeCfdTunnel TunnelWARPConnectorDeleteResponseTunType = "cfd_tunnel"` - `const TunnelWARPConnectorDeleteResponseTunTypeWARPConnector TunnelWARPConnectorDeleteResponseTunType = "warp_connector"` - `const TunnelWARPConnectorDeleteResponseTunTypeWARP TunnelWARPConnectorDeleteResponseTunType = "warp"` - `const TunnelWARPConnectorDeleteResponseTunTypeMagic TunnelWARPConnectorDeleteResponseTunType = "magic"` - `const TunnelWARPConnectorDeleteResponseTunTypeIPSec TunnelWARPConnectorDeleteResponseTunType = "ip_sec"` - `const TunnelWARPConnectorDeleteResponseTunTypeGRE TunnelWARPConnectorDeleteResponseTunType = "gre"` - `const TunnelWARPConnectorDeleteResponseTunTypeCNI TunnelWARPConnectorDeleteResponseTunType = "cni"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) warpConnector, err := client.ZeroTrust.Tunnels.WARPConnector.Delete( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelWARPConnectorDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", warpConnector.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", "account_tag": "699d98642c564d2e855e9661899b7252", "connections": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "is_pending_reconnect": false, "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137", "uuid": "1bedc50d-42b3-473c-b108-ff3d10c0d925" } ], "conns_active_at": "2009-11-10T23:00:00Z", "conns_inactive_at": "2009-11-10T23:00:00Z", "created_at": "2021-01-25T18:22:34.317854Z", "deleted_at": "2009-11-10T23:00:00.000000Z", "metadata": {}, "name": "blog", "status": "healthy", "tun_type": "cfd_tunnel" }, "success": true } ``` # Token ## Get a Warp Connector Tunnel token `client.ZeroTrust.Tunnels.WARPConnector.Token.Get(ctx, tunnelID, query) (*string, error)` **get** `/accounts/{account_id}/warp_connector/{tunnel_id}/token` Gets the token used to associate warp device with a specific Warp Connector tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `query TunnelWARPConnectorTokenGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type TunnelWARPConnectorTokenGetResponseEnvelopeResult string` The Tunnel Token is used as a mechanism to authenticate the operation of a tunnel. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) token, err := client.ZeroTrust.Tunnels.WARPConnector.Token.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelWARPConnectorTokenGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", token) } ``` #### 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": "eyJhIjoiNWFiNGU5Z...", "success": true } ``` # Connections ## List WARP Connector Tunnel connections `client.ZeroTrust.Tunnels.WARPConnector.Connections.Get(ctx, tunnelID, query) (*SinglePage[TunnelWARPConnectorConnectionGetResponse], error)` **get** `/accounts/{account_id}/warp_connector/{tunnel_id}/connections` Fetches connection details for a WARP Connector Tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `query TunnelWARPConnectorConnectionGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type TunnelWARPConnectorConnectionGetResponse struct{…}` A WARP Connector client that maintains a connection to a Cloudflare data center. - `ID string` UUID of the Cloudflare Tunnel connector. - `Arch string` The cloudflared OS architecture used to establish this connection. - `Conns []TunnelWARPConnectorConnectionGetResponseConn` The WARP Connector Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running WARP Connector. - `Features []string` Features enabled for the Cloudflare Tunnel. - `HaStatus TunnelWARPConnectorConnectionGetResponseHaStatus` The HA status of a WARP Connector client. - `const TunnelWARPConnectorConnectionGetResponseHaStatusOffline TunnelWARPConnectorConnectionGetResponseHaStatus = "offline"` - `const TunnelWARPConnectorConnectionGetResponseHaStatusPassive TunnelWARPConnectorConnectionGetResponseHaStatus = "passive"` - `const TunnelWARPConnectorConnectionGetResponseHaStatusActive TunnelWARPConnectorConnectionGetResponseHaStatus = "active"` - `RunAt Time` Timestamp of when the tunnel connection was started. - `Version string` The cloudflared version used to establish this connection. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.ZeroTrust.Tunnels.WARPConnector.Connections.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelWARPConnectorConnectionGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "arch": "linux_amd64", "conns": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137" } ], "features": [ "ha-origin" ], "ha_status": "offline", "run_at": "2009-11-10T23:00:00Z", "version": "2022.7.1" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` # Connectors ## Get WARP Connector Tunnel connector `client.ZeroTrust.Tunnels.WARPConnector.Connectors.Get(ctx, tunnelID, connectorID, query) (*TunnelWARPConnectorConnectorGetResponse, error)` **get** `/accounts/{account_id}/warp_connector/{tunnel_id}/connectors/{connector_id}` Fetches connector and connection details for a WARP Connector Tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `connectorID string` UUID of the Cloudflare Tunnel connector. - `query TunnelWARPConnectorConnectorGetParams` - `AccountID param.Field[string]` Cloudflare account ID ### Returns - `type TunnelWARPConnectorConnectorGetResponse struct{…}` A WARP Connector client that maintains a connection to a Cloudflare data center. - `ID string` UUID of the Cloudflare Tunnel connector. - `Arch string` The cloudflared OS architecture used to establish this connection. - `Conns []TunnelWARPConnectorConnectorGetResponseConn` The WARP Connector Tunnel connections between your origin and Cloudflare's edge. - `ID string` UUID of the Cloudflare Tunnel connection. - `ClientID string` UUID of the Cloudflare Tunnel connector. - `ClientVersion string` The cloudflared version used to establish this connection. - `ColoName string` The Cloudflare data center used for this connection. - `OpenedAt Time` Timestamp of when the connection was established. - `OriginIP string` The public IP address of the host running WARP Connector. - `Features []string` Features enabled for the Cloudflare Tunnel. - `HaStatus TunnelWARPConnectorConnectorGetResponseHaStatus` The HA status of a WARP Connector client. - `const TunnelWARPConnectorConnectorGetResponseHaStatusOffline TunnelWARPConnectorConnectorGetResponseHaStatus = "offline"` - `const TunnelWARPConnectorConnectorGetResponseHaStatusPassive TunnelWARPConnectorConnectorGetResponseHaStatus = "passive"` - `const TunnelWARPConnectorConnectorGetResponseHaStatusActive TunnelWARPConnectorConnectorGetResponseHaStatus = "active"` - `RunAt Time` Timestamp of when the tunnel connection was started. - `Version string` The cloudflared version used to establish this connection. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) connector, err := client.ZeroTrust.Tunnels.WARPConnector.Connectors.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", "1bedc50d-42b3-473c-b108-ff3d10c0d925", zero_trust.TunnelWARPConnectorConnectorGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", connector.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": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "arch": "linux_amd64", "conns": [ { "id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_id": "1bedc50d-42b3-473c-b108-ff3d10c0d925", "client_version": "2022.7.1", "colo_name": "DFW", "opened_at": "2021-01-25T18:22:34.317854Z", "origin_ip": "10.1.0.137" } ], "features": [ "ha-origin" ], "ha_status": "offline", "run_at": "2009-11-10T23:00:00Z", "version": "2022.7.1" }, "success": true } ``` # Failover ## Trigger a manual failover for a WARP Connector Tunnel `client.ZeroTrust.Tunnels.WARPConnector.Failover.Update(ctx, tunnelID, params) (*TunnelWARPConnectorFailoverUpdateResponse, error)` **put** `/accounts/{account_id}/warp_connector/{tunnel_id}/failover` Triggers a manual failover for a specific WARP Connector Tunnel, setting the specified client as the active connector. The tunnel must be configured for high availability (HA) and the client must be linked to the tunnel. ### Parameters - `tunnelID string` UUID of the tunnel. - `params TunnelWARPConnectorFailoverUpdateParams` - `AccountID param.Field[string]` Path param: Cloudflare account ID - `ClientID param.Field[string]` Body param: UUID of the Cloudflare Tunnel connector. ### Returns - `type TunnelWARPConnectorFailoverUpdateResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/zero_trust" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) failover, err := client.ZeroTrust.Tunnels.WARPConnector.Failover.Update( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelWARPConnectorFailoverUpdateParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), ClientID: cloudflare.F("1bedc50d-42b3-473c-b108-ff3d10c0d925"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", failover) } ``` #### 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": {}, "success": true } ```