In Cloudflare’s system, you have a User that can have multiple Accounts and Zones. As a result, your User is configured globally on your machine via a single Cloudflare Token. Your Account(s) and Zone(s) will be configured per project, but will use your Cloudflare Token to authenticate all API calls. A configuration file is created in a
.wrangler directory in your computer’s home directory.
To set up
wrangler to work with your Cloudflare user, use the following commands:
login: a command that opens a Cloudflare account login page to authorize Wrangler.
config: an alternative to
loginthat prompts you to enter your
whoami: run this command to confirm that your configuration is appropriately set up. When successful, this command will print out your account email and your
account_idneeded for your project's
Using environment variables
You can also configure your global user with environment variables. This is the preferred method for using Wrangler in CI (continuous integration) environments.
To customize the authentication tokens that Wrangler uses, you may provide the
CF_API_TOKEN environment variables when running any
wrangler command. The account ID may be obtained from the Cloudflare dashboard in Overview and you may .
$ CF_ACCOUNT_ID=accountID CF_API_TOKEN=veryLongAPIToken wrangler publish
Alternatively, you may use the
CF_API_KEY environment variable combination instead:
$ CF_EMAIL=cloudflareEmail CF_API_KEY=veryLongAPI wrangler publish
You can also specify or override the target Zone ID by defining the
CF_ZONE_ID environment variable.
Defining environment variables inline will override the default credentials stored in
wrangler config or in your
- In Overview, select .
- After being taken to the Profile page, select Create token.
- Under the API token templates section, find the Edit Cloudflare Workers template and select Use template.
- Fill out the rest of the fields and then select Continue to summary, where you can select Create Token and issue your token for use.
Global API Key
- In Overview, select Get your API token.
- After being taken to the Profile page, scroll to API Keys.
- Select View to copy your Global API Key.*
After getting your token or key, you can set up your default credentials on your local machine by running
$ wrangler configEnter API token:superlongapitoken
--api-key flag to instead configure with email and global API key:
$ wrangler config --api-keyEnter email:email@example.comEnter global API key:superlongapikey