Description
Currently, there's no way to create Cloudflare API tokens from the CLI. When setting up CI/CD pipelines (e.g., GitHub Actions), users must manually navigate to the dashboard at https://dash.cloudflare.com/profile/api-tokens to create tokens with the right permission scopes.
This is a friction point, especially when you know exactly which permissions you need (Workers Scripts, D1, KV, etc.) and just want to generate a token quickly.
Proposed Solution
Add a wrangler tokens create command that:
- Opens the browser to a pre-filled "Create Custom Token" page (similar to how
wrangler login opens the OAuth consent screen)
- Accepts permission flags so the token page is pre-configured:
# Example: create a token scoped for Workers + D1 deployment
wrangler tokens create \
--name "my-ci-token" \
--permissions "Workers Scripts:Edit" "D1:Edit" "Account Settings:Read"
- After the user confirms in the browser, the token value is returned to the CLI via a localhost callback (same pattern as
wrangler login)
Alternative / Simpler Approach
Even just a redirect to the dashboard with query parameters pre-filling the token creation form would be a huge improvement:
wrangler tokens create --name "ci-deploy"
# Opens: https://dash.cloudflare.com/profile/api-tokens/create?name=ci-deploy&...
# User confirms in browser, copies token back
Use Case
Setting up CI/CD for Cloudflare Workers deployments (GitHub Actions, GitLab CI, etc.) requires an API token. Today this means:
- Open dashboard
- Navigate to API tokens
- Click create
- Manually select permissions
- Copy the token
- Paste into CI secrets
With this feature, it becomes:
- Run
wrangler tokens create with the right flags
- Confirm in browser
- Token is printed / copied to clipboard
Context
wrangler login already implements the browser OAuth redirect pattern, so the infra for browser-based CLI flows exists
- The Cloudflare API has a
POST /user/tokens endpoint, but it requires existing token management permissions that OAuth tokens from wrangler login don't have — making it inaccessible programmatically for most users
Description
Currently, there's no way to create Cloudflare API tokens from the CLI. When setting up CI/CD pipelines (e.g., GitHub Actions), users must manually navigate to the dashboard at
https://dash.cloudflare.com/profile/api-tokensto create tokens with the right permission scopes.This is a friction point, especially when you know exactly which permissions you need (Workers Scripts, D1, KV, etc.) and just want to generate a token quickly.
Proposed Solution
Add a
wrangler tokens createcommand that:wrangler loginopens the OAuth consent screen)wrangler login)Alternative / Simpler Approach
Even just a redirect to the dashboard with query parameters pre-filling the token creation form would be a huge improvement:
Use Case
Setting up CI/CD for Cloudflare Workers deployments (GitHub Actions, GitLab CI, etc.) requires an API token. Today this means:
With this feature, it becomes:
wrangler tokens createwith the right flagsContext
wrangler loginalready implements the browser OAuth redirect pattern, so the infra for browser-based CLI flows existsPOST /user/tokensendpoint, but it requires existing token management permissions that OAuth tokens fromwrangler logindon't have — making it inaccessible programmatically for most users