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 ls

Node 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 file

The 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

CodeMeaning
0Success
1Error
2Usage — bad flag or missing argument
4Not authenticated, or the key is invalid
5Rate limited
tl links ls > /dev/null 2>&1 || case $? in
  4) echo "log in first" ;;
  5) echo "back off" ;;
esac

Plans

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

VariablePurpose
TRACKLINK_API_KEYKey; overrides the config file
TRACKLINK_API_URLAPI base URL
TRACKLINK_CONFIG_DIRWhere the config lives
NO_COLORDisable colour
FORCE_COLOR=1Keep colour when not a TTY (CI logs)

Related