TrimLynk CLI
The official command-line interface for TrimLynk.
Architecture
The CLI is packaged with the official Python SDK and uses it as its sole API client:
TrimLynk CLI (`trimlynk`)
↓
Python SDK (`trimlynk`)
↓
Developer API v1
↓
TrimLynk BackendNo second HTTP client, custom curl wrappers, or duplicated API logic exist in the CLI. Authentication, retries, pagination, error parsing, and idempotency are provided directly by the SDK.
Quick Start
Installation
pip install trimlynkAuthentication
Log in with your TrimLynk API key:
trimlynk auth loginCredentials are saved automatically to your operating system's native secure keyring (Windows Credential Locker, macOS Keychain, or Linux Secret Service via FreeDesktop DBus) with a hardened 0600 file fallback.
Alternatively, provide the key via environment variable:
export TRIMLYNK_API_KEY="tl_live_xxxxxxxxxxxxxxxxxxxxxxxx"Verify authentication status:
trimlynk auth statusEssential Commands
# Create a link
trimlynk links create https://example.com --title "Homepage" --custom-slug home
# List links
trimlynk links list
# List in JSON format for scripting and jq
trimlynk links list --json
# Quiet mode (captures just the short URL for bash/zsh variables)
URL=$(trimlynk --quiet links create https://example.com)
# Workspace analytics summary
trimlynk analytics summary
# Manage campaigns
trimlynk campaigns list
trimlynk campaigns create --name "Launch 2026"
# Manage webhooks
trimlynk webhooks list
trimlynk webhooks deliveries <webhook-id>Documentation
For full command documentation, arguments, CI/CD recipes, and exit codes, see TrimLynk CLI Reference.
TrimLynk Official CLI Reference
The official production-ready command-line interface for the TrimLynk developer platform. Built on the TrimLynk Python SDK, the CLI provides complete control over short links, analytics, conversions, marketing campaigns, and webhooks for developers and CI/CD pipelines.
1. Architecture
TrimLynk CLI (trimlynk)
↓
Python SDK (trimlynk)
↓
Developer API v1 (/api/v1/...)
↓
TrimLynk Backend Platform- Sole API Client: The CLI directly invokes the official
trimlynkPython SDK (TrimLynkclient). No second HTTP client or duplicate network layer exists inside the CLI. - Unified Engine: Retries, exponential backoff, rate limiting, HMAC verification, pagination iterators, and standardized error mappings are managed entirely through the SDK.
2. Installation
Install via pip:
pip install trimlynkVerify installation and entry point:
trimlynk --version
# Output: trimlynk 1.0.0
trimlynk --help3. Global Options
Global options can be placed at the root level, after the resource group, or after the leaf command:
| Option | Shorthand | Description | Default |
|---|---|---|---|
--json | Output raw, unadorned JSON for scripting and jq | false | |
--quiet | -q | Suppress tables; output only the primary resource ID/URL | false |
--api-key | Explicitly supply or override API key for this command | None | |
--environment | Environment: live or test | live | |
--base-url | Override API endpoint base URL | https://api.trimlynk.com | |
--version | Show CLI version and exit | ||
--help | -h | Display detailed command help and examples |
Environment Variables
Environment variables are automatically recognized when CLI arguments are not provided:
| Variable | Description |
|---|---|
TRIMLYNK_API_KEY | TrimLynk Developer API key |
TRIMLYNK_ENVIRONMENT | Default environment (live or test) |
TRIMLYNK_BASE_URL | API base URL override |
NO_COLOR / CI | Disables terminal color output |
Precedence Order: CLI Arguments (
--api-key) > Environment Variables (TRIMLYNK_API_KEY) > OS Keyring > Fallback File (~/.trimlynk/credentials.json).
4. Authentication & Credential Storage
Security Guarantees
- No Plaintext by Default: Credentials stored with
trimlynk auth loginuse the operating system's native secure keyring (Windows Credential Locker, macOS Keychain, or Linux Secret Service via FreeDesktop DBus). - Hardened File Fallback: If an OS keyring is unavailable (e.g. headless containers), credentials fall back to
~/.trimlynk/credentials.jsonwith user-only read/write permissions (chmod 600). - Never Leaked: Secrets are never echoed on typing, never printed to stdout/stderr in full, masked as
tl_live_••••••••••••3456, never included in--jsonoutput, and excluded from exception diagnostics.
auth login
Prompts securely for an API key without echoing input, validates it against the live API, and securely saves it:
trimlynk auth loginOr pass directly for script setups:
trimlynk auth login --api-key tl_live_xxxxxxxxxxxxxxxxxxxxxxxxauth status
Displays the current local authentication state:
trimlynk auth statusOutput:
Authenticated: yes
Environment: live
API Key: tl_live_••••••••••••3456
Source: system keyring (service=trimlynk)
Remote Status: not checked
API Version: 1Perform an active remote validation against the API:
trimlynk auth status --checkauth logout
Removes stored credentials from the keyring and local fallback storage:
trimlynk auth logout5. Command Reference
Links (trimlynk links)
Manage short links, custom aliases, and UTM campaign tags.
links create
Shorten a destination URL:
trimlynk links create https://example.com/products/summer \
--title "Summer Campaign Landing" \
--custom-slug summer26 \
--tag marketing \
--tag promo \
--utm-source newsletter \
--utm-medium email \
--utm-campaign summer_sale \
--idempotency-key idem_link_create_001links list
List links with pagination and filtering:
trimlynk links list --page 1 --limit 25 --sort clicks --tag marketingStream all links across all pages safely:
trimlynk links list --alllinks get
Retrieve complete details and telemetry for a single link:
trimlynk links get clk_xyz123links update
Update link destination, title, slug, or activation state:
trimlynk links update clk_xyz123 \
--title "Updated Summer Landing" \
--inactivelinks delete
Delete a short link:
# Interactive prompt (requires typing y/N)
trimlynk links delete clk_xyz123
# Automation / non-interactive (bypasses prompt)
trimlynk links delete clk_xyz123 --yesAnalytics (trimlynk analytics)
Retrieve aggregated telemetry and link performance data directly from the server.
analytics summary
Workspace-wide analytics overview:
trimlynk analytics summary \
--start-date 2026-09-01T00:00:00Z \
--end-date 2026-09-24T23:59:59Zanalytics link
Telemetry for a specific link:
trimlynk analytics link clk_xyz123 \
--start-date 2026-09-01T00:00:00Z \
--end-date 2026-09-24T23:59:59ZConversions (trimlynk conversions)
Record and query conversion events and attribution funnels.
conversions create
Record a new conversion event:
trimlynk conversions create \
--url-id lnk_abc123 \
--event-name purchase \
--event-value 49.99 \
--currency USD \
--order-id ord_98765 \
--customer-email user@example.comconversions list
List conversion events:
trimlynk conversions list --page 1 --limit 50 --event-name purchaseconversions get
Inspect conversion event details:
trimlynk conversions get cnv_abc789Campaigns (trimlynk campaigns)
Organize links and attribution into marketing campaigns.
campaigns create
trimlynk campaigns create \
--name "Q4 Global Launch" \
--description "Worldwide Q4 promotional drive" \
--utm-source google \
--utm-medium cpc \
--utm-campaign q4_launch \
--idempotency-key idem_camp_q4campaigns list
trimlynk campaigns list --page 1 --limit 20campaigns get
trimlynk campaigns get cmp_001campaigns update
trimlynk campaigns update cmp_001 --name "Q4 Global Launch (Extended)"campaigns delete
trimlynk campaigns delete cmp_001 --yesWebhooks (trimlynk webhooks)
Register and manage webhook endpoints for real-time notifications.
webhooks create
Register a webhook endpoint:
trimlynk webhooks create \
--url https://api.mycompany.com/webhooks/trimlynk \
--event link.created \
--event click.created \
--description "Production event ingestion" \
--idempotency-key idem_whk_01Security Notice: If the server generates a signing secret, the CLI displays it once upon creation. It is never exposed or re-displayed afterwards.
webhooks list
trimlynk webhooks listwebhooks get
trimlynk webhooks get whk_999webhooks update
trimlynk webhooks update whk_999 --url https://new-api.mycompany.com/webhook --activewebhooks delete
trimlynk webhooks delete whk_999 --yeswebhooks test
Dispatch a ping test event to the endpoint:
trimlynk webhooks test whk_999webhooks deliveries
Inspect delivery logs for troubleshooting:
trimlynk webhooks deliveries whk_999 --page 1 --limit 20webhooks retry
Re-dispatch a failed webhook delivery:
trimlynk webhooks retry whk_999 del_888Configuration (trimlynk config)
Manage local CLI defaults stored in ~/.trimlynk/config.json.
# View configuration
trimlynk config get
# Inspect specific setting
trimlynk config get environment
# Update setting
trimlynk config set environment test
trimlynk config set base_url https://api.trimlynk.com6. Output Modes & Scripting
JSON Mode (--json)
Every command supports --json. Output is strictly valid JSON without ANSI color codes or decorative text.
trimlynk links list --json | jq '.data[].short_url'Quiet Mode (-q / --quiet)
Quiet mode extracts only the essential identifier (e.g. URL or ID), ideal for shell variables:
# Create a link and capture short URL directly into a shell variable
SHORT_URL=$(trimlynk -q links create https://example.com/docs --title "Docs")
echo "Generated URL: $SHORT_URL"7. Exit Codes
The CLI strictly maps all outcomes and SDK exceptions into standardized POSIX exit codes:
| Exit Code | Meaning | Typical Cause |
|---|---|---|
0 | Success | Command executed successfully |
1 | General Error | Unhandled exception or unexpected failure |
2 | Invalid Arguments / Request | Missing argument, invalid syntax, or API 400 validation error |
3 | Authentication Error | Missing API key, invalid key, or expired credentials (401) |
4 | Permission Error | Insufficient API key scope or workspace permission (403) |
5 | Not Found | Specified resource ID or custom slug does not exist (404) |
6 | Rate Limited | Request quota or velocity threshold exceeded (429) |
7 | API / Server Error | Conflict (409), idempotency collision, or server error (500) |
8 | Network / Timeout Error | Connection refused, DNS failure, or socket timeout |
8. CI/CD & Automation Examples
GitHub Actions
name: Deploy & Generate Short Links
on:
push:
branches: [main]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install TrimLynk CLI
run: pip install trimlynk
- name: Create Release Link
env:
TRIMLYNK_API_KEY: ${{ secrets.TRIMLYNK_API_KEY }}
run: |
RELEASE_URL=$(trimlynk --quiet links create \
"https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}" \
--title "Release ${{ github.ref_name }}" \
--custom-slug "v-${{ github.ref_name }}")
echo "Public release link: $RELEASE_URL"Shell Automation with jq
#!/usr/bin/env bash
set -euo pipefail
# Ensure credentials exist
export TRIMLYNK_API_KEY="${TRIMLYNK_PROD_KEY}"
# Export all link IDs with > 100 clicks
trimlynk links list --all --json | \
jq -r '.data[] | select(.clicks > 100) | "\(.id)\t\(.short_url)\t\(.clicks)"'9. Shell Completion
To generate command completions for your shell using argcomplete (optional extension):
# Bash
eval "$(register-python-argcomplete trimlynk)"
# Zsh
autoload -U +X bashcompinit && bashcompinit
eval "$(register-python-argcomplete trimlynk)"