Getting Started
This guide walks you through installing goGenerateCFToken, configuring your credentials, and generating your first Cloudflare API token.
Prerequisites
- A Cloudflare account with at least one zone
- A Cloudflare API token with the necessary permissions
- Go 1.27+ (if installing from source)
Installation
Install script
tmp=$(mktemp)
curl -sSfL https://raw.githubusercontent.com/nicholas-fedor/goGenerateCFToken/main/scripts/install.sh -o "$tmp" && sh "$tmp"
rm -f "$tmp"On Linux this prefers a native .deb / .rpm / .apk / Arch package when sudo is available, otherwise it installs the release archive into $HOME/go/bin.
From Source
go install github.com/nicholas-fedor/gogeneratecftoken/v2@latestPre-built Binary
Download the latest archive or distro package from the GitHub releases page.
Initial Setup
1. Initialize Configuration
Initialize the configuration file with your Cloudflare zone:
gogeneratecftoken config initThis prompts for the Cloudflare zone name (e.g., example.com) and writes
$XDG_CONFIG_HOME/gogeneratecftoken/config.yaml (typically ~/.config/gogeneratecftoken/config.yaml).
Then store your Cloudflare API key. Interactive input is not echoed. On systems without an OS keyring, the key is stored in a 0600 file next to the config:
gogeneratecftoken credentials setNon-interactive alternatives:
export CF_API_TOKEN="your-master-api-token"
gogeneratecftoken credentials set --from-env
# Docker secrets / file-based credentials
gogeneratecftoken credentials set --from-file /run/secrets/cf_api_token2. Verify Credentials
Test that your credentials are valid:
gogeneratecftoken credentials validateConfiguration
Configuration is loaded from an XDG-compliant path:
~/.config/gogeneratecftoken/config.yamlOverride the path with --config:
gogeneratecftoken --config ./custom-config.yaml token generate myappBasic Usage
Managing Credentials
Store a New API Key
gogeneratecftoken credentials setRemove Stored Credentials
gogeneratecftoken credentials removeGenerating a Token
Generate a Cloudflare API token for a service:
gogeneratecftoken token generate myappThis creates a token named myapp.example.com with:
- Zone read permissions
- DNS write permissions
The token is printed to stdout by default. Use --output to write it to a file:
gogeneratecftoken token generate myapp --output ./token.txtCustom Token Name
Override the default naming convention:
gogeneratecftoken token generate myapp --name ci-deployToken Expiration
Set an expiration date for the token:
gogeneratecftoken token generate myapp --expires-on 2027-01-01T00:00:00ZJSON Output
Output the token in JSON format for use in scripts:
gogeneratecftoken token generate myapp --jsonManaging Tokens
List Tokens
View all tokens associated with your Cloudflare account:
gogeneratecftoken token listRevoke a Token
Revoke a token by its ID:
gogeneratecftoken token revoke abc123 --yesUpdating
Update using the installation script:
tmp=$(mktemp)
curl -sSfL https://raw.githubusercontent.com/nicholas-fedor/goGenerateCFToken/main/scripts/install.sh -o "$tmp" && sh "$tmp" update
rm -f "$tmp"Uninstalling
Uninstall using the installation script:
tmp=$(mktemp)
curl -sSfL https://raw.githubusercontent.com/nicholas-fedor/goGenerateCFToken/main/scripts/install.sh -o "$tmp" && sh "$tmp" uninstall
rm -f "$tmp"Next Steps
See the full CLI reference for all commands, flags, and advanced usage.