Tunnel tokens
A remotely-managed tunnel only requires a token to run. Anyone with the token can run the tunnel.
To get the token for a remotely-managed tunnel:
-
In the Cloudflare dashboard ↗, go to Networking > Tunnels.
Go to Tunnels -
Select your tunnel.
-
Select Add a replica.
-
Copy the
cloudflaredinstallation command into a text editor (do not run the command). The token is theeyJ...string.
Required API token permissions
At least one of the following token permissions
is required:
Cloudflare One Connectors WriteCloudflare One Connector: cloudflared WriteCloudflare Tunnel Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/cfd_tunnel/$TUNNEL_ID/token" \ --request GET \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"Rotate tokens regularly to reduce the risk of compromise. For tunnels with multiple replicas, rotate outside working hours and update replicas in batches.
-
In the Cloudflare dashboard ↗, go to Networking > Tunnels.
Go to Tunnels -
Select your tunnel.
-
Select Rotate token. After rotating the token,
cloudflaredcannot establish new connections with the old token. Existing connectors remain active until restarted. -
Select Add replica and copy the new
cloudflaredinstallation command. -
On each replica, reinstall the
cloudflaredservice using the new token:Terminal window sudo cloudflared service uninstallsudo cloudflared service install <NEW_TOKEN>
Rotate a compromised token
If your tunnel token is compromised, immediately rotate the token, then force-disconnect all existing connections:
Required API token permissions
At least one of the following token permissions
is required:
Cloudflare One Connectors WriteCloudflare One Connector: cloudflared WriteCloudflare Tunnel Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/cfd_tunnel/$TUNNEL_ID/connections" \ --request DELETE \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"Then reinstall the cloudflared service on all replicas using the new token.