Skip to content
Getting Started

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@latest

Pre-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 init

This 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 set

Non-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_token

2. Verify Credentials

Test that your credentials are valid:

gogeneratecftoken credentials validate

Configuration

Configuration is loaded from an XDG-compliant path:

~/.config/gogeneratecftoken/config.yaml

Override the path with --config:

gogeneratecftoken --config ./custom-config.yaml token generate myapp

Basic Usage

Managing Credentials

Store a New API Key

gogeneratecftoken credentials set

Remove Stored Credentials

gogeneratecftoken credentials remove

Generating a Token

Generate a Cloudflare API token for a service:

gogeneratecftoken token generate myapp

This 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.txt

Custom Token Name

Override the default naming convention:

gogeneratecftoken token generate myapp --name ci-deploy

Token Expiration

Set an expiration date for the token:

gogeneratecftoken token generate myapp --expires-on 2027-01-01T00:00:00Z

JSON Output

Output the token in JSON format for use in scripts:

gogeneratecftoken token generate myapp --json

Managing Tokens

List Tokens

View all tokens associated with your Cloudflare account:

gogeneratecftoken token list

Revoke a Token

Revoke a token by its ID:

gogeneratecftoken token revoke abc123 --yes

Updating

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.