Skip to content

CLI Examples

Real-world recipes for the lnkify CLI. All commands support --json for scripting.

Scripting with --json and jq

In --json mode, structured data goes to stdout and everything else (logs, spinners, the banner) goes to stderr, so pipes stay clean:

bash
# Print every slug
lnkify links list --json | jq -r '.items[].lnkify'

# Total clicks across all links
lnkify analytics --json | jq '.totalClicks'

# Find the id of a slug, then open its target
id=$(lnkify links list --search launch --json | jq -r '.items[0].id')
lnkify links get "$id" --json | jq -r '.target'
bash
lnkify links create https://example.com/launch --slug launch --track
lnkify resolve launch
# → https://example.com/launch

Bulk import

Create many links from a JSON array of CreateLnkifyInput objects:

json
// links.json
[
  { "target": "https://example.com/a", "lnkify": "promo-a", "title": "Promo A" },
  { "target": "https://example.com/b", "lnkify": "promo-b", "enableTracking": true }
]
bash
lnkify links bulk create --file links.json --dry-run   # preview first
lnkify links bulk create --file links.json             # send

CSV works too — the header row maps to input fields:

csv
target,lnkify,enableTracking
https://example.com/a,promo-a,true
https://example.com/b,promo-b,false

Delete in bulk from a file of ids (JSON array of strings, or a CSV with an id column):

bash
lnkify links bulk delete --file ids.json --yes

Work with multiple servers

Save a local and a production profile, then target either one:

bash
lnkify --profile prod config set url https://links.acme.com
lnkify --profile prod config set api-key lf_live_PROD_KEY

lnkify --profile prod analytics   # production
lnkify analytics                  # local default

Use in CI

Pass the key via the environment so nothing is written to disk:

bash
export LNKIFY_API_URL=https://links.acme.com
export LNKIFY_API_KEY=lf_live_YOUR_KEY

lnkify links create "$DEPLOY_URL" --slug "build-$CI_COMMIT_SHORT_SHA" --json

Connect an AI agent

bash
lnkify mcp install --write   # add the CLI to Claude Desktop, then restart it

See CLI + MCP for the available tools.

Next: GraphQL Examples

Released under the MIT License.