ztnet-0.1.13 is not a library.
ztnet-cli
A fast, ergonomic command-line interface for managing ZeroTier networks through ZTNet.
$ ztnet network list --json
[
{ "nwid": "abcdef1234567890", "name": "my-network", "private": true }
]
Features
- Full REST API coverage — networks, members, orgs, stats, planet files
- Named profiles — switch between multiple ZTNet instances with
auth profiles use - Host-bound credentials — stored tokens/sessions are only used for their configured host
- Smart name resolution — reference networks and orgs by name, not just ID
- Flexible output — table, JSON, YAML, or raw for scripting
- Hosts file export — generate
/etc/hostsentries from network members - Raw API escape hatch — call any endpoint with
api get /api/v1/... - Dry-run mode — preview HTTP requests without sending them
- Automatic retries — exponential backoff on transient errors and rate limits
- Shell completions — bash, zsh, fish, PowerShell, elvish
Quickstart
Install
# Binary: target/release/ztnet (target/release/ztnet.exe on Windows)
Authenticate
# Point to your ZTNet instance (validated automatically)
# Save your API token (grab it from ZTNet web UI -> Account -> API tokens)
# Or read from stdin to keep it out of shell history
|
# Verify it works
Core commands
# List all your networks
# Create a new network
# List members of a network (by name!)
# Authorize a member
# Export hosts file for DNS
# Get output as JSON for scripting
Command overview
| Command | Description |
|---|---|
auth |
Manage API tokens, profiles, and test connectivity |
config |
View and edit configuration, set defaults |
user |
Create platform users (admin/bootstrap) |
org |
List and inspect organizations |
network |
Create, list, get, and update networks |
member |
List, authorize, deauthorize, and manage members |
stats |
Fetch admin statistics |
planet |
Download custom planet files |
export |
Generate hosts files, CSV, or JSON from members |
api |
Raw HTTP requests to any endpoint |
trpc |
Call tRPC procedures (experimental) |
completion |
Generate shell completion scripts |
Global flags
-H, --host <URL> ZTNet base URL
-t, --token <TOKEN> API token
--profile <NAME> Config profile to use (default: "default")
--org <ORG> Organization scope (ID or name)
--network <NETWORK> Default network (ID or name)
-o, --output <FMT> Output format: table, json, yaml, raw
--json Shortcut for --output json
--dry-run Print the HTTP request without sending it
--timeout <DURATION> HTTP timeout (default: 30s)
--retries <N> Retry count for transient errors (default: 3)
-y, --yes Skip confirmation prompts
-v, --verbose Increase log verbosity
--no-color Disable ANSI colors
--quiet Suppress interactive output
Configuration
Config lives in a TOML file with named profiles:
| Platform | Path |
|---|---|
| Linux | ~/.config/ztnet/config.toml |
| macOS | ~/Library/Application Support/ztnet/config.toml |
| Windows | %APPDATA%\ztnet\config.toml |
= "default"
[]
= "https://ztnet.example.com"
= "your-api-token"
= "table"
[]
= "https://staging.ztnet.example.com"
= "staging-token"
Precedence: CLI flags > environment variables > config file > defaults.
See docs/configuration.md for the full reference.
Documentation
| Document | Description |
|---|---|
| Configuration | Profiles, environment variables, config file format, precedence rules |
| Command Reference | Every command, subcommand, flag, and option |
| API Reference | Endpoint mapping, authentication, HTTP client behavior, exit codes |
| Development | Building from source, Docker setup, smoke tests, architecture |
Shell completions
# Bash
# Zsh
# Fish
# PowerShell
Examples
Multi-profile workflow
# Set up profiles for different environments
# Optionally set defaults per host (used when you pass --host without --profile)
# Switch between them
Organization-scoped operations
# Set a default org so you don't have to pass --org every time
# Now all commands use that org
Scripting with JSON
# Get all network IDs
# Pipe member data into jq
|
# Authorize all unauthorized members
for; do
done
Export hosts file
# Generate /etc/hosts entries
# Or as JSON for further processing
Dry-run and debugging
# See exactly what HTTP request would be made
# GET http://localhost:3000/api/v1/network
# x-ztnet-auth: sk_1…abcd
License
AGPL-3.0-only (see LICENSE)