A cross-platform CLI tool for managing Namecheap DNS records.
cargo install --path .cargo install namecheap-clinamecheap auth loginexport NAMECHEAP_API_USER="your-api-user"
export NAMECHEAP_API_KEY="your-api-key"
export NAMECHEAP_USERNAME="your-username" # Optional, defaults to API user
export NAMECHEAP_CLIENT_IP="your-ip" # Optional, auto-detected
export NAMECHEAP_SANDBOX="true" # Optional, use sandbox APIConfiguration is stored in ~/.config/namecheap-cli/config.toml:
default_profile = "default"
[profiles.default]
api_user = "your-api-user"
api_key = "${NAMECHEAP_API_KEY}" # Environment variable expansion
username = "your-username"
sandbox = false
[profiles.sandbox]
api_user = "your-api-user"
api_key = "${NAMECHEAP_SANDBOX_API_KEY}"
sandbox = true# Configure credentials interactively
namecheap auth login
# Check authentication status
namecheap auth status
# Show current user info and balance
namecheap auth whoami# List all domains
namecheap domains list
# Get domain info
namecheap domains info example.com
# Check domain availability
namecheap domains check example.com example.org# List DNS records
namecheap dns list example.com
# Filter by type
namecheap dns list example.com -t A
# Add a record
namecheap dns add example.com A @ 1.2.3.4
# Add MX record with priority
namecheap dns add example.com MX @ mail.example.com --priority 10
# Set (replace) a record
namecheap dns set example.com A @ 5.6.7.8
# Remove a record
namecheap dns rm example.com A @
# Remove specific value
namecheap dns rm example.com A @ 1.2.3.4
# Export records
namecheap dns export example.com --format json
namecheap dns export example.com --format zone
# Show diff between current and desired
namecheap dns diff example.com records.json
# Sync records from file
namecheap dns sync example.com records.json
namecheap dns sync example.com records.json --delete # Remove records not in file# List available presets
namecheap preset list
# Show preset details
namecheap preset show github-pages
# Apply a preset
namecheap preset apply github-pages example.com -V username=myuser
# Remove preset records
namecheap preset remove github-pages example.comAvailable presets:
github-pages- GitHub Pages hostinggoogle-workspace- Google Workspace emailfastmail- Fastmail emailprotonmail- ProtonMail emailmicrosoft-365- Microsoft 365 emailcloudflare- Cloudflare DNS proxynetlify- Netlify hostingvercel- Vercel hostingsendgrid- SendGrid email sending
# List nameservers
namecheap ns list example.com
# Set custom nameservers
namecheap ns set example.com ns1.cloudflare.com ns2.cloudflare.com
# Reset to Namecheap defaults
namecheap ns reset example.com# List redirects
namecheap redirect list example.com
# Add redirect
namecheap redirect add example.com @ https://www.example.com
# Add permanent (301) redirect
namecheap redirect add example.com old https://new.example.com --permanent
# Add frame/masked redirect
namecheap redirect add example.com masked https://example.com --frame
# Remove redirect
namecheap redirect rm example.com @# Verify DNS records are propagated
namecheap verify example.com
# Verify specific record type
namecheap verify example.com -t A
# Wait for propagation
namecheap verify example.com --wait --timeout 300# Bash
namecheap completions bash > ~/.local/share/bash-completion/completions/namecheap
# Zsh
namecheap completions zsh > ~/.zfunc/_namecheap
# Fish
namecheap completions fish > ~/.config/fish/completions/namecheap.fish
# PowerShell
namecheap completions powershell > namecheap.ps1| Option | Description |
|---|---|
--config <path> |
Path to config file |
-p, --profile <name> |
Profile to use |
--json |
Output as JSON |
--dry-run |
Don't make any changes |
-q, --quiet |
Minimal output |
-v, --verbose |
Verbose output |
-y, --yes |
Skip confirmation prompts |
| Code | Description |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Authentication error |
| 3 | Domain not found |
| 4 | Record not found |
| 5 | Validation error |
| 6 | Network error |
| 7 | Verification failed |
To use this tool, you need API access enabled on your Namecheap account:
- Go to Profile > Tools > Namecheap API Access
- Enable API Access
- Add your IP address to the whitelist
- Copy your API Key
For testing, you can use the sandbox API by setting sandbox = true in your profile.
MIT