CLI Reference
The Trelay CLI lets you create links, list them, view stats, generate QR codes, manage folders, and configure the client from the terminal. It supports multiple output formats (table, JSON, CSV) and shell completion.
Setup
Build the CLI (from the trelay repo) and configure the API URL and API key:
make build-cli
./bin/trelay config set api-url http://localhost:8080
./bin/trelay config set api-key YOUR_API_KEY Replace http://localhost:8080 with your server URL and YOUR_API_KEY with the value of API_KEY from your server .env.
Commands
trelay create <url>
Create a short link. The long URL is required; all other options are optional.
| Flag / option | Description |
|---|---|
--slug | Custom slug (e.g. my-link) |
--expires | Expiration (e.g. 30d, 24h) |
--password | Prompt for a password to protect the link |
--one-time | Link works only once, then is invalidated |
--folder-id | ID of folder to put the link in |
trelay create https://example.com/page --slug docs
trelay create https://example.com/secret --password --expires 7d trelay list
List all links. Supports search and filters via flags (e.g. --search, --folder-id). Output format: --format table (default), --format json, or --format csv.
trelay list
trelay list --format json
trelay list --search "docs" trelay get <slug>
Get details for a single link by slug.
trelay get my-link trelay delete <slug>
Delete a link (soft-delete by default; use --permanent for hard delete).
trelay delete my-link
trelay delete my-link --permanent trelay stats <slug>
View click statistics for a link. Output: --format table, --format json, or --format csv.
trelay stats my-link
trelay stats my-link --format json trelay qr <slug>
Generate a QR code for the short link. Options: --open to open in browser or system viewer, or copy to clipboard (implementation may vary).
trelay qr my-link
trelay qr my-link --open trelay folder create <name>
Create a folder. Optional --parent-id <id> for a nested folder.
trelay folder create "Marketing"
trelay folder create "Blog" --parent-id 1 trelay folder list
List all folders. Output: --format table, --format json, or --format csv.
trelay folder list trelay config set <key> <value>
Set CLI configuration. Keys: api-url, api-key.
trelay config set api-url https://links.example.com
trelay config set api-key your-api-key trelay completion <shell>
Generate shell completion. Supported shells: bash, zsh, fish (if supported by the CLI).
trelay completion bash # then source or add to .bashrc
trelay completion zsh # then source or add to .zshrc Output formats
Commands that list or return structured data support --format:
table— Human-readable table (default)json— JSON (e.g. for piping tojq)csv— CSV for spreadsheets
trelay list --format json | jq '.[0]'
trelay stats my-link --format csv > stats.csv Help
Run trelay --help for a summary of commands. Use trelay <command> --help for command-specific help.