The Cloudflare CLI is Wrangler, an npm package that manages Workers, Pages, KV, R2 and D1. DNS records, zone settings and cache purge live in the REST API, so you need both surfaces. That split is easy to script around, whether you call the API from a shell script or from a workflow tool like Activepieces.

The Cloudflare CLI refers to the set of command-line tools used to manage a Cloudflare account, chiefly Wrangler for Workers and the developer platform, alongside the REST API, authenticated with scoped API tokens, for zone-level tasks such as DNS and cache purge.
There's a reason Wrangler's the default. It pulls 50,992,990 downloads a week on npm, against 5,526,446 for Vercel's CLI, 5,177,365 for Firebase tools and 437,632 for the Netlify CLI.
That's roughly nine times Vercel, so the answers you find in issues and Q&A threads are overwhelmingly Wrangler answers.
Before you trust a snippet, check your version. A tutorial written for v3 may use flags that v4 changed. Keelbench counts 21 releases for v2, 114 for v3 and 169 for v4, so Wrangler moves fast.
Cloudflare CLI is Wrangler, and what it covers
Decide before you write the script which surface owns each resource; the table shows it. Anything marked "no" for Wrangler needs a scoped API token and a REST call.
| Resource | Managed by Wrangler | Managed by REST API | Example command or endpoint |
|---|---|---|---|
| Workers | Yes | Yes | wrangler deploy |
| Pages | Yes | Yes | wrangler pages deploy |
| KV | Yes | Yes | wrangler kv namespace list |
| R2 | Yes | Yes | wrangler r2 bucket list |
| D1 | Yes | Yes | wrangler d1 list |
| DNS records | No | Yes | GET /zones/{zone_id}/dns_records |
| Zone settings | No | Yes | GET /zones/{zone_id}/settings |
| Cache purge | No | Yes | POST /zones/{zone_id}/purge_cache |
On macOS, Linux and Windows the command's the same, because Wrangler's a Node package: npm install -D wrangler inside a project. Installing per project pins the version, so a teammate's machine and your CI run the same release.

Use npx wrangler to run it. Windows needs Node installed first.
Run npx wrangler --version. A version number starting with 4 means you're on the current major line. A 3 or 2 means older docs and flags may not match, so upgrade before debugging anything else.
The fastest way to settle a shortlist is to try one. Activepieces is free to try, no credit card.
Cloudflare sign-in with OAuth and API tokens
Use wrangler login on your laptop and a scoped API token in CI; skip the legacy Global API Key unless something old forces it.
| Method | How created | Scope | Laptop fit | CI fit |
|---|---|---|---|---|
wrangler login (OAuth) |
Browser consent flow run from the terminal | Permissions granted at consent, tied to your user | Good, nothing to copy or store | Poor, it needs a browser |
| Scoped API token | Created in the dashboard with chosen permissions and resources | Only what you select, on the accounts or zones you pick | Fine, but you must store it | Good, set as an environment variable |
| Legacy Global API Key | Viewed in the dashboard profile | Everything your user can do | Works, but over-privileged | Works, but a leak's a full account leak |
Wrangler login for a laptop
Run wrangler login, approve the consent screen in the browser, and Wrangler stores the credential locally. You never paste a secret, so there's nothing to leak into shell history.
Creating a scoped API token for CI
Create the token in the dashboard and limit it to the one account or zone. Grant only the permissions the job needs (a Workers deploy job doesn't need DNS edit rights). Then export it:

export CLOUDFLARE_API_TOKEN=<your token>
export CLOUDFLARE_ACCOUNT_ID=<your account id>
When the token can see more than one account, setting CLOUDFLARE_ACCOUNT_ID matters, because otherwise Wrangler can't tell which one to deploy to and a non-interactive run fails instead of prompting. Store both as CI secrets, not in the repository.
Run wrangler whoami before debugging anything else. It shows which account Wrangler's acting as and how it logged in.
If an environment token is set, expect it to take precedence over the OAuth login, which explains many "works on my machine" mismatches.
Wrangler commands developers use most, with examples
Once you know which credential is winning, the daily Wrangler work's a short loop: create, run locally, set secrets, deploy, tail, delete, plus subcommands for KV, R2 and D1.
npm create cloudflare@latest my-workerscaffolds a project (wrangler init's the older entry point).wrangler devruns it locally so you can hit it before anything's public.wrangler secret put API_KEYstores a secret, prompting for the value.wrangler deploypublishes it to your account.wrangler tailstreams live logs from the deployed Worker.wrangler deleteremoves the Worker when you're done.
Skip step 3 and you ship a Worker that returns undefined for its own API key, so set secrets before the first deploy.
Wrangler secrets, KV, R2 and D1 commands
For values that must never sit in your repo, use wrangler secret put. Storage has its own subcommands: wrangler kv namespace create, wrangler r2 bucket create and wrangler d1 create.
Each creates a resource that does nothing for your code until you bind it in config. For D1, wrangler d1 execute runs SQL against the database.
The wrangler config file and environment variables
In your project's wrangler.toml (or wrangler.jsonc) sit the Worker name, entry point, compatibility date and bindings. A binding's the name your code uses to reach a KV namespace, R2 bucket or D1 database.
If creating a resource worked but env.MY_KV is undefined at runtime, this file lacks the binding.
Put plain variables under vars. For local-only secrets, use a .dev.vars file, which wrangler dev reads and which stays out of git. Use --env to deploy a named environment such as staging.

Reading live logs with wrangler tail
Once the Worker's deployed, wrangler tail attaches to it and prints each request and any console.log output as it happens. Add --status error to show only failing requests, which cuts the noise when you're chasing one bad route.
When you reach cleanup, wrangler delete removes the Worker, but any KV, R2 or D1 resources you created stay until you delete them separately.
Reading a table only gets you so far. Build the same workflow in Activepieces and compare it yourself.
Cloudflare pricing and rate limits, checked December 2026
Domain plans are one ladder; Workers usage's a separate meter.
On its plans page, Cloudflare lists Free at $0 per month, Pro at $20 per month and Business at $200 per month on annual billing, which means users can get started at zero cost. Those prices cover a domain (a zone).
A $0 Free zone can still run Workers, and a $200 Business zone gets no extra Workers quota from that fee, so there's no Workers-quota premium for paying $200.
Workers Free versus Workers Paid
Here's what each tier gives you and what happens when you hit the ceiling. Cells marked "unconfirmed" are figures I couldn't verify against Cloudflare's docs for this article. Check them before you plan capacity around them.
| Requests quota | CPU time per invocation | Price per unit | Behavior at limit | |
|---|---|---|---|---|
| Workers Free | Unconfirmed | Unconfirmed | $0 | Unconfirmed |
| Workers Paid | Unconfirmed | Unconfirmed | Unconfirmed | Unconfirmed |
| Cloudflare API global rate limit | Unconfirmed | Not applicable | Not applicable | HTTP 429 |
The one cell I'll commit to's the last: the REST API answers an over-limit call with a 429, not a silent drop.
I have no confirmed per-unit prices for KV, R2 or D1 here, so I won't quote any. Cloudflare meters each separately from Workers requests, so a cleanup that removes the Worker but leaves a bucket or database keeps accruing storage charges.
List your resources with Wrangler after every teardown and delete what's left.
API rate limits and the 429 response
When the API refuses you, the status line is:
HTTP/1.1 429 Too Many Requests
That means you're over the global limit for your token or account, so avoid retrying in a tight loop. Back off, spread calls out, and batch where an endpoint allows it.
Common Wrangler and API errors and fixes
When a deploy or request fails, it's usually one of five errors, the 429 among them, and each has a short, specific fix.
- A token missing a scope, or an account ID that belongs to a different account, returns an authentication error. Recreate the token with the permission the call needs and set
CLOUDFLARE_ACCOUNT_IDto the right account. - A 429 means you're sending too fast. Retry with exponential backoff and a little jitter.
- A Worker over its script size or CPU limit fails at deploy or at runtime. Trim dependencies or move heavy work elsewhere.
- A name in your config that differs from the name in your code leaves a binding undefined. Make them match exactly.
- An old Node version breaks Wrangler before it does anything. Upgrade Node.
Wrangler deployment and limit errors and fixes
Remove unused packages, and check that your bundle isn't pulling in a whole library for one function.
For binding errors, compare the binding name in wrangler.toml or wrangler.jsonc against the name your code reads from env; a typo gives you undefined, not a helpful message. If Wrangler won't start, run node --version and upgrade.
curl -s https://api.cloudflare.com/client/v4/user/tokens/verify \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
If the response has "success": true and a status of active, the token's valid, so any later failure's about scope or account ID. Account-owned tokens are verified at an account-level path instead.
Run Cloudflare commands in CI and scheduled jobs
Run wrangler deploy in CI with its own scoped API token stored as a repository secret. Recurring work belongs in a Cron Trigger declared in your Wrangler config.
Deploy from GitHub Actions
- Store
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDas repository secrets. Wrangler reads both from the environment, so the job never runs an interactive login. - Check out the code.
- Install dependencies.
- Run
wrangler deploy, passing the two secrets as environment variables on that step. - Add a Cron Trigger in the config if the Worker should also run on a schedule.
Create the token for deploys only, with Workers edit permission and nothing else.
Scheduled work with Cron Triggers
You don't need a server or a CI schedule just to run a nightly job, because a Cron Trigger fires a Worker on a schedule.
Add a crons list under [triggers] in wrangler.toml, export a scheduled handler in the Worker, and the next wrangler deploy registers the schedule.
The handler's a separate entry point from fetch. A Worker with only a fetch handler deploys cleanly and then does nothing when the schedule fires.
Run Cloudflare API jobs without code
Some jobs aren't Worker code at all: purging the cache after a release, or posting a deploy alert to Slack. An Activepieces flow can run these, and the Cloudflare token it needs doesn't have to sit in our database.
Aim the flow at the zone's purge_cache endpoint and add a further step for the alert. Credentials live in central connections.
Give that flow its own token limited to cache purge on the one zone. The flow then can't touch your Workers, and the deploy token can't purge your cache.
What Activepieces does about this
The mistake this article keeps returning to is reaching for Wrangler when the job belongs to the REST API, and then holding a token that is too broad for either. Activepieces covers the second half of that split.
The mistake this article keeps returning to is reaching for Wrangler when the job belongs to the REST API, and then holding a token that is too broad for either.
It is where you put the REST-shaped jobs, such as cache purges after a release or a deploy alert, so they stop living as ad hoc curl calls in a CI script.
The core is MIT-licensed and ships 751 integrations, which means most common third-party platforms are likely already integrated. If a Cloudflare action you need isn't among them, you can generate one with AI and add it privately to your own instance.
Either way the flow calls the same endpoints this article lists, such as POST /zones/{zone_id}/purge_cache, with the same token you would have used from the terminal.
Scoping stays in your hands. Create a token limited to cache purge on one zone, store it as a connection, and the flow can do that one thing.
On a self-hosted instance or the enterprise cloud tier, where secret managers are supported, you can route connection secrets to your own secret manager, so the token never sits in our database. MoneyGram, Moneypenny, Alan and FundingSocieties run Activepieces in production.

Keep Wrangler for what it owns: wrangler deploy, wrangler tail, bindings and Cron Triggers. Use a flow for the zone-level work Wrangler can't touch, and give each side its own token.
A failed deploy then points at the deploy token, and a failed purge points at the purge token.
Frequently asked questions
Once the surface and token are chosen, these are the questions that come up. Each answer follows from the same split: Wrangler for Workers, the REST API for the rest.
Is there a separate Cloudflare CLI besides Wrangler?
No separate general-purpose command line is covered here: Wrangler's the CLI Cloudflare documents for Workers and the developer platform. Anything outside that, such as DNS, firewall rules or cache purges, goes through the REST API with a scoped token.
If a tutorial tells you to run a cloudflare command for zone settings, check it against Cloudflare's docs before you paste it into a terminal.
Is the Cloudflare CLI free to use?
Installing and running Wrangler costs nothing. What you pay for's the platform behind the commands. Workers has a free plan with usage limits, and paid plans lift those limits.
So the failure you'll hit first is a plan limit on a deploy or a feature, not a licence check in the tool. Read the limits for the product you are deploying to before you build a pipeline around it.
Can Wrangler manage DNS records?
Not as a general record editor. Wrangler has no command for creating, listing or deleting arbitrary DNS records in a zone. It does touch DNS indirectly: routes and custom domains declared in your Worker's config attach the Worker to a hostname.
For everything else, call the DNS endpoints of the REST API with a token that has only DNS edit permission on that one zone. A leaked token then can change records on that zone and nothing more.
How do I update Wrangler to the latest version?
Update it the way you installed it. For a project-local install, run npm install --save-dev wrangler@latest, then confirm with npx wrangler --version.
What worked as "latest" last quarter may have changed flags or defaults, because Wrangler releases often and major versions arrive regularly.
Pin the version in your project and bump it deliberately. Read the release notes on a major bump before CI picks it up, because an unpinned install will take the new major without asking.
Related reading
References
Still comparing
The fastest way to settle it is to build something.
Open source under MIT, so you can self-host the same thing later.
Start free Talk to sales


