CLI
Track Link from a terminal or a CI job. Built to be scripted, not just typed.
Install
npm i -g @tracklink/cli
tl auth login
# or without installing
npx @tracklink/cli links lsNode 18 or newer. Installs as tl with tracklink as an alias.
Authenticate
tl auth login # prompts, input is masked
TRACKLINK_API_KEY=tl_live_... tl links ls # env wins over the config fileThe key is checked against the API before it is saved, so a bad paste fails at login rather than turning every later command into a confusing 401. It is stored 0600 in ~/.config/tracklink/. For CI, use the environment variable — a key on the command line lands in shell history and is visible in ps.
Commands
tl links ls [--search X] [--limit N] [--offset N]
tl links get <id>
tl links create <url> [--name X] [--slug X] [--type redirect|pixel|geo]
tl links update <id> [--name X] [--destination X] [--active|--inactive]
tl links rm <id> [--yes]
tl clicks [--link ID] [--from 7d] [--to DATE] [--limit N]
tl stats [id] [--from 7d] [--to DATE]
tl usage
tl webhooks ls
tl whoami
tl completion bash|zsh|fish--from and --to take ISO dates or relative shorthand: 7d, 24h, 2w.
Piping
Output follows where it is going: aligned columns in a terminal, tab-separated when piped, JSON on demand.
tl links ls # columns, colour
tl links ls | cut -f2 # TSV — no header, no colour
tl links ls --json | jq -r '.data[].slug'
# create prints ONLY the short URL on stdout
tl links create https://example.com/promo --slug promo | pbcopy
URL=$(tl links create https://example.com/x)Ticks, hints and pagination notes go to stderr, so stdout stays clean for pipes.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Usage — bad flag or missing argument |
| 4 | Not authenticated, or the key is invalid |
| 5 | Rate limited |
tl links ls > /dev/null 2>&1 || case $? in
4) echo "log in first" ;;
5) echo "back off" ;;
esacPlans
Read commands work on every plan. links create, update and rm need a write-scoped key on Agency or Business. tl auth status shows which you have, and a 403 tells you which of the two is missing rather than just failing.
Environment
| Variable | Purpose |
|---|---|
| TRACKLINK_API_KEY | Key; overrides the config file |
| TRACKLINK_API_URL | API base URL |
| TRACKLINK_CONFIG_DIR | Where the config lives |
| NO_COLOR | Disable colour |
| FORCE_COLOR=1 | Keep colour when not a TTY (CI logs) |
Related
- Authentication
- MCP server — the same data, for AI agents