An AI agent for Cloudflare: DNS records, zone settings and Workers within your token's permissions
Marketing teams touch Cloudflare more than they expect: a verification record for a new ad platform, a redirect for a campaign landing page, a cache purge after a site change, a Worker that adds tracking parameters. An AI agent connected with your own Cloudflare API token reads zones, DNS records, settings, rules, traffic and Workers, and makes the changes you approve. This post covers the token permissions that matter, what the agent changes, what always waits for a person, and goals to start with.
Why Cloudflare suits an agent — with limits
Most Cloudflare requests from a marketing team are small and exact: add this TXT record, point this subdomain there, purge these pages. They are also the kind of change that can take a site or its email offline when it is wrong. An agent is useful when it reads first, shows the record before and after, and stays inside the access you gave it.
In Agent Planners, Cloudflare connects with an API token you create in your Cloudflare profile. The token's permissions are the limit: every call is made with it, and what it may not do is answered with the exact permission to add — never worked around.
The token permissions that matter
- DNS Settings, DNS Views and DNS Firewall are not DNS. They are account permissions and do not reach a zone's records. A token holding all three was refused records on every zone in our test.
- A token with zone permissions only (Cloudflare's "Edit zone DNS" template) lists no account. It still connects, through its zones, and its account areas — Workers, Pages, R2, KV, D1 — are reported as a missing permission rather than "0 Workers".
| Area | Permission |
|---|---|
| DNS records | The ZONE permission named just "DNS" — Read, or Edit to change records |
| Zone settings | Zone · Zone Settings · Read / Edit |
| Cache purge | Zone · Cache Purge · Purge |
| Traffic | Zone · Analytics · Read |
| Workers code | Account · Workers Scripts · Read / Edit |
| Workers routes | Zone · Workers Routes · Read / Edit |
What the agent reads
- Zones with their status, plan and name servers; DNS records and the BIND export.
- Zone settings and rulesets: WAF, redirects, transforms and cache rules.
- Traffic by day: requests, cached requests, bandwidth, threats, page views and unique visitors (unique visitors are per day and never added up).
- Workers with their settings and source, Worker routes, Pages projects, R2 buckets, KV namespaces, D1 databases and registered domains.
What it changes
| Change | Tool | Who decides |
|---|---|---|
| Add or edit a DNS record | create_dns_record / update_dns_record | Your approval setting (read first, shown before and after) |
| Take a record off the proxy | update_dns_record | Always a person — it exposes the origin's address |
| Delete a DNS record | delete_dns_record | Always a person |
| Change a zone setting | set_zone_setting | Your approval setting; TLS and security settings, HSTS included, always a person |
| Purge the cache | purge_cache | Your approval setting for files, prefixes, hosts or tags; purging everything always a person |
| Add a Worker route | create_worker_route | Your approval setting |
| Remove a Worker route / deploy Worker code | delete_worker_route / deploy_worker | Always a person |
| Anything else in the account | mutate | Your approval setting; a DELETE, code, Pages deployments, registrar changes, DNS batches and pausing a zone or changing its plan always a person |
Keeping the agent to some domains
A token can be limited to some zones in Cloudflare — the strongest limit. Agent Planners adds a second one: a Forbidden Rule that allows changes only on the domains you name, written in plain words ("MCP can only manage example.com on Cloudflare") and checked before every call, including raw API requests. How it works: Limit an AI agent to specific domains.
What we measured with live tokens
- An account-level token reached one account and its 196 zones; zones, settings, rulesets, Workers, routes, D1 and registered domains answered, and every area it lacked was named with its permission.
- A zone-only token connected through its zones (two accounts), read DNS records and changed them: two throwaway TXT records were created and deleted again on the allowed domain.
- The domain lock refused a record, a zone setting, a Worker deploy and a raw request outside the allowed domain.
Goals to start with
| Goal | What the agent does |
|---|---|
| "Add the TXT record TikTok gave us for example.com." | Reads the zone's records, then proposes the new record for your approval. |
| "Which DNS records on example.com point outside Cloudflare's proxy?" | Lists records with proxied off and what each points to. |
| "Purge the cache for the three landing pages we just changed." | Proposes a purge of those URLs only. |
| "How much traffic did the campaign subdomain get last week, and how much was cached?" | Reads zone analytics by day. |
| "Which Workers run on our shop's routes?" | Lists routes and the Worker each one serves. |
Setting it up
- 1In Cloudflare open My Profile → API Tokens → Create Token and give it only what the agent should do — for DNS records the zone permission DNS, Edit to change them — on the zones it may touch.
- 2On Integrations press Connect with an API token on the Cloudflare card, paste the token and press Check and save. It is checked with Cloudflare before it is stored, encrypted.
- 3Pick the account for a task and write the goal — or call the same tools from Claude, Codex or Cursor over MCP.
Frequently asked questions
- Can an AI agent manage Cloudflare DNS?
- Yes, with your own API token holding the zone permission DNS (Edit to change records). It reads first and shows each record before and after; by default a change waits for your approval, and deleting a record always waits for a person.
- Why does my token see no DNS records?
- DNS Settings, DNS Views and DNS Firewall are account permissions. Records need the zone permission named just DNS; add it to the token in Cloudflare and press Refresh accounts.
- Can the agent deploy a Cloudflare Worker?
- It can prepare the deploy, but Worker code runs on your traffic, so deploying always waits for a person.
- Does the agent get more access than my token?
- No. Every call uses your token, and Cloudflare decides what it may do. Agent Planners adds approvals and refusals on top, never permissions.