Authentication
Clanker uses the Cloudflare API for most operations. You’ll need an API token with appropriate permissions.API token configuration
Configure your Cloudflare API token in one of the following ways:.clanker.yaml
Clanker resolves credentials in this order:
- Configuration file (
cloudflare.api_tokenandcloudflare.account_id) CLOUDFLARE_API_TOKEN/CLOUDFLARE_ACCOUNT_IDenvironment variablesCF_API_TOKEN/CF_ACCOUNT_IDenvironment variables
Creating an API token
- Go to Cloudflare Dashboard
- Click “Create Token”
- Use the “Edit zone DNS” template or create a custom token
- Grant appropriate permissions for the resources you want to manage
Cloudflare features
Clanker supports the following Cloudflare services:DNS Management
Create, update, and delete DNS records with natural language
Workers & Pages
Deploy and manage Cloudflare Workers, KV, D1, R2, and Pages
Security (WAF)
Configure firewall rules, rate limiting, and WAF policies
Zero Trust
Manage Cloudflare Tunnels and Access applications
DNS management
Manage DNS records using natural language or direct commands.Natural language DNS queries
Direct DNS commands
DNS record types supported
- A (IPv4 address)
- AAAA (IPv6 address)
- CNAME (canonical name)
- MX (mail exchange)
- TXT (text record)
- NS (nameserver)
- SRV (service record)
- CAA (certificate authority authorization)
- PTR (pointer record)
DNS record features
Proxied vs DNS-only
Proxied vs DNS-only
Control whether records are proxied through Cloudflare’s CDN:
TTL configuration
TTL configuration
Set custom TTL values for records:
Record management
Record management
Update or delete existing records:
Workers & Pages
Manage Cloudflare Workers, KV namespaces, D1 databases, R2 buckets, and Pages projects.Workers
Workers KV
D1 Databases
R2 Storage
Pages
Security & WAF
Manage firewall rules, rate limiting, and WAF configurations.Firewall rules
Rate limiting
Security levels
essentially_off- Lowest securitylow- Low securitymedium- Medium security (default)high- High securityunder_attack- I’m Under Attack mode
Page rules
Zero Trust
Manage Cloudflare Tunnels and Access applications.Cloudflare Tunnels
Access applications
Error handling
Clanker provides helpful error hints for Cloudflare operations:Retry mechanism
Clanker automatically retries failed API calls with exponential backoff for:- Rate limiting errors
- Timeout errors
- Temporarily unavailable services
- Connection errors
Implementation details
Client initialization
Frominternal/cloudflare/client.go:52:
API calls
All Cloudflare API operations use curl with retry logic: Frominternal/cloudflare/client.go:104:
CLI tools
Clanker integrates with three CLI tools:- curl - For API operations (required)
- wrangler - For Workers, KV, D1, R2, and Pages (optional)
- cloudflared - For Tunnel operations (optional)
internal/cloudflare/client.go:172:
Sub-agents
Clanker uses specialized sub-agents for different Cloudflare services:- DNS sub-agent (
internal/cloudflare/dns/) - Manages DNS records - Workers sub-agent (
internal/cloudflare/workers/) - Manages Workers, KV, D1, R2, Pages - WAF sub-agent (
internal/cloudflare/waf/) - Manages firewall rules and security - Zero Trust sub-agent (
internal/cloudflare/zerotrust/) - Manages Tunnels and Access
Best practices
Use scoped API tokens
Create API tokens with minimal required permissions instead of using Global API Keys.
Configure account ID
Set your account ID in
.clanker.yaml for faster operations and better error messages.Zone-specific queries
Include the zone name in your queries for faster DNS operations.
Install CLI tools
Install
wrangler and cloudflared for full Workers and Tunnel support.Examples
List all zones
Create an A record
List Workers
Deploy to Pages
Cloudflare integration requires a valid API token. Create one at https://dash.cloudflare.com/profile/api-tokens