npm i -g @linktwin/cli

LinkTwin CLI: shorten and manage links from the command line.

The LinkTwin CLI brings short links and deep links to your terminal. Create, edit and analyze links, manage QR codes, collections, domains and pixels, and automate all of it with simple commands and JSON output. Built for developers, scripts and CI.

npm install -g @linktwin/cli
See all commands
  • Node.js 18 or newer
  • MIT licensed, on npm
  • Scriptable with --json
maya@studio: ~/links

Example session with real commands and output formats.

Built for developers

Stop context-switching to shorten a link.

You live in the terminal. Opening a dashboard to create a link, or hand-rolling API calls for a quick script, slows you down. The LinkTwin CLI puts link creation, deep linking and analytics one command away.

Steps to get it done

  • Dashboard
  • LinkTwin CLI
Shorten a link with an alias
List your most clicked links
Counted for someone already signed in, with a terminal open. Each block is one action.
The job The old way With the LinkTwin CLI
Creating a link Leave the terminal for the dashboard linktwin links create <url>
Signing in Write curl + auth for every script One login, then just commands
Bulk work No easy bulk operations Bulk create & delete with ease
Automation Hard to wire into CI --json + env var = CI-ready

Get started

Up and running in two commands

Requires Node.js 18+. Your API key is saved locally to ~/.linktwin/config.json.

Terminal
# 1. Install (Node.js 18 or newer)
npm install -g @linktwin/cli

# 2. Authenticate (paste your API key)
linktwin login

# 3. Create your first link
linktwin links create https://example.com --custom hello

Using AI? Try the MCP server. Writing your own integration? Read the API docs.

Where your API key comes from

The CLI looks for credentials in this order and uses the first one it finds, so a CI job can override your saved login without touching it.

  1. Flags--api-key --base-url
  2. Environment variablesLINKTWIN_API_KEY LINKTWIN_BASE_URL
  3. Saved login~/.linktwin/config.json, written by linktwin login and readable only by you (mode 0600).
  4. Default base URLhttps://linktw.in

Commands

Everything, from one command

A focused command for every part of your link workflow. Every command also takes the global options --json, --api-key, --base-url.

linktwin stats

Per-link and account analytics: clicks, countries, referrers, devices and trends.

  • linktwin stats link <id>

    Analytics for a single link (id or short URL)

    • --timezone
  • linktwin stats dashboard

    Aggregated account KPIs and click trend

    • -p, --period 1d|1w|1m|1y|max
    • --timezone
  • linktwin stats detailed

    Detailed account analytics with breakdowns

    • -r, --range 1d|7d|30d|max|custom
    • --start
    • --end
    • --collections
    • --timezone
  • linktwin stats trend

    Hourly/daily click distribution (day trend)

    • -p, --period
    • --timezone
Example output
$ linktwin stats dashboard --period 1m
Dashboard
Total clicks:  4370
Unique clicks: 3915
Top country:   United States
Top referrer:  https://l.instagram.com
Total links:   9
Growth %:      64.22

linktwin collections

Organize links into collections and assign links in bulk.

  • linktwin collections list

    List collections

    • -l, --limit
    • --page
  • linktwin collections get <id>

    List items inside a collection

    • -l, --limit
    • --page
  • linktwin collections create <name>

    Create a collection

    • --description
    • --color <hex>
    • --slug
    • --public
    • --starred
  • linktwin collections update <id>

    Update a collection

    • --name
    • --description
    • --color
    • --public <bool>
    • --starred <bool>
  • linktwin collections assign <collectionId> <linkIds>

    Add/remove links in a collection (comma-separated link IDs)

    • --remove
  • linktwin collections delete <id>

    Delete a collection (items are unassigned, not deleted)

    • -y, --yes
Example output
$ linktwin collections assign 4 1221,1222,1223
✓ Added 3, removed 0 link(s).

linktwin domains

Add and manage your branded custom domains.

  • linktwin domains list

    List all available domains (standard + branded)

    • -l, --limit
    • --page
  • linktwin domains add <domain>

    Add a branded domain (include http:// or https://)

    • --redirect-root
    • --redirect-404
  • linktwin domains update <id>

    Update a branded domain

    • --redirect-root
    • --redirect-404
  • linktwin domains delete <id>

    Delete a branded domain

    • -y, --yes
Example output
$ linktwin domains add https://go.mayamakes.shop --redirect-root https://mayamakes.shop
✓ Added domain https://go.mayamakes.shop (id 12).

linktwin pixels

Create retargeting pixels and attach them to links.

  • linktwin pixels list

    List retargeting pixels

    • -l, --limit
    • --page
  • linktwin pixels get <id>

    Show a pixel and its assigned links

    • -l, --limit
    • --page
  • linktwin pixels create

    Create a retargeting pixel

    • -t, --type fbpixel|gtmpixel|…
    • -n, --name
    • --tag
    • --event
  • linktwin pixels update <id>

    Update a pixel

    • --tag
    • -n, --name
    • --event
  • linktwin pixels assign <pixelId> <linkIds>

    Add/remove a pixel on links (comma-separated link IDs)

    • --remove
  • linktwin pixels delete <id>

    Delete a pixel

    • -y, --yes
Example output
$ linktwin pixels create --type fbpixel --name "Meta pixel" --tag 1234567890
✓ Created pixel Meta pixel (id 4).

linktwin qr

Generate and manage QR codes for any link.

  • linktwin qr list

    List QR codes

    • -l, --limit
    • --page
  • linktwin qr get <id>

    Show a QR code and its scan analytics

  • linktwin qr create

    Create a QR code

    • -t, --type text|vcard|link|email|phone|sms|wifi
    • -d, --data
    • --background
    • --foreground
    • --logo
  • linktwin qr update <id>

    Update a QR code

    • -d, --data
    • --background
    • --foreground
    • --logo
  • linktwin qr delete <id>

    Delete a QR code

    • -y, --yes
Example output
$ linktwin qr create --type link --data https://linktw.in/desk-tour
✓ Created QR code https://linktw.in/qr/a58f79 (id 3).

Account

Save your key once, check which account you are using, and see where your credentials come from.

  • linktwin login

    Save your LinkTwin API key and base URL

    • -k, --key
    • -u, --url
    • --no-verify
  • linktwin logout

    Remove saved credentials

  • linktwin whoami

    Show the current account, plan and usage

  • linktwin config

    Show where credentials are read from

Example output
$ linktwin whoami
Account
Email:      [email protected]
Plan:       Large
User ID:    57842
Links used: 9
Clicks:     4370
Base URL:   https://linktw.in

Built for scripts, cron jobs and CI.

The same commands work in a shell script, a scheduled job or a build pipeline. Add --json for output you can parse, and pass your key as an environment variable.

  • --json on any command prints the raw API response, ready for jq.
  • LINKTWIN_API_KEY and LINKTWIN_BASE_URL override the saved login, so CI never needs linktwin login.
  • Delete commands refuse to run without --yes, so a script never removes links by accident.
  • Any error exits with code 1 and prints the reason on stderr, so a failing step stops your pipeline.
jq
# Your 5 most clicked links, as clicks and short URL
linktwin links list --order clicks_desc --limit 5 --json \
  | jq -r '.data.urls[] | "\(.clicks)\t\(.shorturl)"'
Bulk create
# One short link for each URL in urls.txt
while read -r url; do
  linktwin links create "$url" --json | jq -r '.shorturl'
done < urls.txt
Targeting
# Geo targeting and UTM parameters, passed as JSON
linktwin links create https://example.com --custom promo \
  --data '{"geotarget":[{"location":"Canada","link":"https://example.ca"}],
           "parameters":[{"name":"utm_source","value":"newsletter"}]}'
GitHub Actions
# A workflow step: a short link for each release
- name: Short link for the release notes
  env:
    LINKTWIN_API_KEY: ${{ secrets.LINKTWIN_API_KEY }}
  run: |
    npm install -g @linktwin/cli
    linktwin links create "https://example.com/releases/${{ github.ref_name }}" --json

CLI Questions

Everything about the LinkTwin command-line tool. Still have questions? Contact us.

What is the LinkTwin CLI?

The LinkTwin CLI is a command-line tool, the linktwin command, for shortening and managing links from your terminal. You can create short links and deep links, manage collections, branded domains, retargeting pixels and QR codes, and pull click analytics without opening the dashboard. Every command supports --json output for scripting and automation.

How do I install the LinkTwin CLI?

Install it from npm with npm install -g @linktwin/cli. It needs Node.js 18 or newer. Then run linktwin login, paste your API key, and you are ready to create links from the command line.

Is the URL shortener CLI free?

The CLI itself is free and MIT licensed. It works through the LinkTwin API, and API access comes on every plan. You can create a free account first and upgrade when you need the API.

Can I use the CLI in scripts and CI?

Yes. Pass --json to any command for machine-readable output you can pipe into jq, and authenticate without a prompt by setting the LINKTWIN_API_KEY environment variable. That makes the CLI a good fit for build pipelines, cron jobs and bulk link creation.

Can the CLI create deep links, not just short links?

Yes. Every link you create opens in the right app on a phone, such as YouTube, Amazon or Spotify. The CLI also sets geo, device and language targeting, A/B testing, UTM parameters and branded domains. Pass advanced targeting as JSON with the --data flag.

Where do I get my API key?

Sign in to LinkTwin and open Settings, or Tools & Integrations and then CLI Tool, in your dashboard. Copy your API key and run linktwin login, or set it as the LINKTWIN_API_KEY environment variable. The key is shown once your plan includes API access.

Which commands does the LinkTwin CLI have?

login, logout, whoami and config for your credentials, plus six command groups: links, stats, collections, domains, pixels and qr. Run linktwin followed by any command and --help to see all of its options.

How do I refer to a link in a command?

Use its numeric ID or its short URL, for example linktwin stats link linktw.in/desk-tour. The short URL works with or without https://. You can find both in the output of linktwin links list.

One API key, three ways to build

The REST API, the MCP server and the CLI all use the same API key and manage the same links.

API documentation

Every endpoint, with examples

Read the API docs

Shorten your next link without leaving the terminal

Install the LinkTwin CLI and start managing links from your shell.

npm install -g @linktwin/cli

API access comes on every plan. See plans