Cloudflare Manager
by @rexlunae
Manage Cloudflare via API — DNS zones and records, page rules, SSL/TLS settings, caching, firewall rules, Workers, and analytics. Free tier includes DNS, CDN, DDoS protection, and SSL.
clawhub install cf-manager📖 About This Skill
name: cloudflare description: Manage Cloudflare via API — DNS zones and records, page rules, SSL/TLS settings, caching, firewall rules, Workers, and analytics. Free tier includes DNS, CDN, DDoS protection, and SSL.
Cloudflare API Skill
Control Cloudflare infrastructure: DNS management, CDN, security, Workers, and more.
Authentication
API token required. Get one from: https://dash.cloudflare.com/profile/api-tokens
Recommended permissions:
Store in ~/.config/cloudflare/token:
mkdir -p ~/.config/cloudflare
echo -n "YOUR_API_TOKEN" > ~/.config/cloudflare/token
chmod 600 ~/.config/cloudflare/token
Quick Reference
Zones (Domains)
# List all zones
python3 scripts/cloudflare.py zones listGet zone details
python3 scripts/cloudflare.py zones get Add new zone
python3 scripts/cloudflare.py zones add Delete zone
python3 scripts/cloudflare.py zones delete Check zone status (pending/active)
python3 scripts/cloudflare.py zones status Purge cache
python3 scripts/cloudflare.py zones purge
python3 scripts/cloudflare.py zones purge --urls https://example.com/page
DNS Records
# List records for a zone
python3 scripts/cloudflare.py dns list Add record
python3 scripts/cloudflare.py dns add --type A --name @ --content 1.2.3.4
python3 scripts/cloudflare.py dns add --type CNAME --name www --content example.com
python3 scripts/cloudflare.py dns add --type MX --name @ --content mail.example.com --priority 10
python3 scripts/cloudflare.py dns add --type TXT --name @ --content "v=spf1 include:_spf.google.com ~all"Update record
python3 scripts/cloudflare.py dns update --content 5.6.7.8Delete record
python3 scripts/cloudflare.py dns delete Proxy toggle (orange cloud on/off)
python3 scripts/cloudflare.py dns proxy --on
python3 scripts/cloudflare.py dns proxy --off
SSL/TLS
# Get SSL mode
python3 scripts/cloudflare.py ssl get Set SSL mode (off, flexible, full, strict)
python3 scripts/cloudflare.py ssl set --mode fullAlways use HTTPS
python3 scripts/cloudflare.py ssl https --on
Page Rules
# List page rules
python3 scripts/cloudflare.py rules list Add redirect rule
python3 scripts/cloudflare.py rules add --match "example.com/*" --redirect "https://new.com/$1"Delete rule
python3 scripts/cloudflare.py rules delete
Firewall
# List firewall rules
python3 scripts/cloudflare.py firewall list Block IP
python3 scripts/cloudflare.py firewall block --ip 1.2.3.4 --note "Spammer"Block country
python3 scripts/cloudflare.py firewall block --country CN --note "Block China"Whitelist IP
python3 scripts/cloudflare.py firewall allow --ip 1.2.3.4Challenge (captcha) for IP range
python3 scripts/cloudflare.py firewall challenge --ip 1.2.3.0/24
Analytics
# Get traffic stats (last 24h)
python3 scripts/cloudflare.py analytics Get stats for date range
python3 scripts/cloudflare.py analytics --since 2024-01-01 --until 2024-01-31
Workers (Serverless)
# List workers
python3 scripts/cloudflare.py workers listDeploy worker
python3 scripts/cloudflare.py workers deploy --script worker.jsDelete worker
python3 scripts/cloudflare.py workers delete
DNS Record Types
| Type | Purpose | Example | |------|---------|---------| | A | IPv4 address | 192.0.2.1 | | AAAA | IPv6 address | 2001:db8::1 | | CNAME | Alias | www → example.com | | MX | Mail server | mail.example.com (priority 10) | | TXT | Text/verification | v=spf1 ... | | NS | Nameserver | ns1.example.com | | SRV | Service | _sip._tcp.example.com | | CAA | Certificate authority | letsencrypt.org |
Proxy Status (Orange Cloud)
# Enable proxy
python3 scripts/cloudflare.py dns add example.com --type A --name @ --content 1.2.3.4 --proxiedDisable proxy (DNS only)
python3 scripts/cloudflare.py dns add example.com --type A --name mail --content 1.2.3.4 --no-proxy
SSL Modes
| Mode | Description | |------|-------------| | off | No SSL (not recommended) | | flexible | HTTPS to Cloudflare, HTTP to origin | | full | HTTPS end-to-end, any cert on origin | | strict | HTTPS end-to-end, valid cert on origin |
Common Workflows
Add a New Domain
# 1. Add zone to Cloudflare
python3 scripts/cloudflare.py zones add example.com2. Note the nameservers (e.g., adam.ns.cloudflare.com, bella.ns.cloudflare.com)
3. Update nameservers at your registrar
4. Add DNS records
python3 scripts/cloudflare.py dns add example.com --type A --name @ --content 1.2.3.4 --proxied
python3 scripts/cloudflare.py dns add example.com --type CNAME --name www --content example.com --proxied5. Set SSL to strict
python3 scripts/cloudflare.py ssl set example.com --mode strict
Migrate DNS from Another Provider
# 1. Add zone (Cloudflare will scan existing records)
python3 scripts/cloudflare.py zones add example.com2. Verify records imported correctly
python3 scripts/cloudflare.py dns list example.com3. Add any missing records
python3 scripts/cloudflare.py dns add example.com --type MX --name @ --content mail.example.com --priority 104. Update nameservers at registrar
5. Wait for propagation, check status
python3 scripts/cloudflare.py zones status example.com
Set Up Email Records
# MX records
python3 scripts/cloudflare.py dns add example.com --type MX --name @ --content mx1.provider.com --priority 10
python3 scripts/cloudflare.py dns add example.com --type MX --name @ --content mx2.provider.com --priority 20SPF
python3 scripts/cloudflare.py dns add example.com --type TXT --name @ --content "v=spf1 include:_spf.provider.com ~all"DKIM
python3 scripts/cloudflare.py dns add example.com --type TXT --name selector._domainkey --content "v=DKIM1; k=rsa; p=..."DMARC
python3 scripts/cloudflare.py dns add example.com --type TXT --name _dmarc --content "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"
Direct API Access
TOKEN=$(cat ~/.config/cloudflare/token)
curl -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
https://api.cloudflare.com/client/v4/zones
API Documentation
Free Plan Includes
Nameservers
When you add a domain, Cloudflare assigns two nameservers like:
adam.ns.cloudflare.combella.ns.cloudflare.comUpdate these at your domain registrar. Zone stays "pending" until nameservers propagate.