REST API
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
- Node.js 18 or newer
- MIT licensed, on npm
- Scriptable with --json
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
linktwin links create <url>
Get started
Up and running in two commands
Requires Node.js 18+. Your API key is saved locally to ~/.linktwin/config.json.
# 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.
- Flags
--api-key--base-url - Environment variables
LINKTWIN_API_KEYLINKTWIN_BASE_URL - Saved login~/.linktwin/config.json, written by linktwin login and readable only by you (mode 0600).
- Default base URL
https://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 links
Create, list, get, update, delete and bulk-delete short links and deep links.
-
linktwin links create <url>Create a short link or deep link
- -c, --custom <alias>
- -p, --password
- -d, --domain
- --expiry
- --clicklimit
- --expiration-redirect
- --note
- --display-title
- --metatitle
- --metadescription
- --metaimage
- --collections
- --pixels
- --data <json>
-
linktwin links listList your links
- -l, --limit
- --page
- -o, --order
- -s, --search
- --from
- --to
- --collections
-
linktwin links get <id>Show full details for a link (id or short URL)
- --timezone
-
linktwin links update <id>Update a link (id or short URL). Only changed fields are sent.
- --url
- and every create option
-
linktwin links delete <id>Delete a link (id or short URL)
- -y, --yes
-
linktwin links bulk-delete <ids>Delete multiple links by comma-separated IDs
- -y, --yes
$ linktwin links list --order clicks_desc --limit 3
ID Short URL Clicks Title Created
──── ───────────────────────────── ────── ──────────────────────────────── ───────────────────
1221 https://linktw.in/desk-tour 1764 My $200 desk setup (full tour) 2026-08-06 21:41:00
1222 https://linktw.in/new-camera 1098 Unboxing my new camera 2026-09-21 18:52:00
1224 https://linktw.in/my-keyboard 570 Amazon: Low profile mechanical … 2026-08-07 10:30:00
Page 1/3 · 9 total
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 dashboardAggregated account KPIs and click trend
- -p, --period 1d|1w|1m|1y|max
- --timezone
-
linktwin stats detailedDetailed account analytics with breakdowns
- -r, --range 1d|7d|30d|max|custom
- --start
- --end
- --collections
- --timezone
-
linktwin stats trendHourly/daily click distribution (day trend)
- -p, --period
- --timezone
$ 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 listList 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
$ linktwin collections assign 4 1221,1222,1223
✓ Added 3, removed 0 link(s).
linktwin domains
Add and manage your branded custom domains.
-
linktwin domains listList 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
$ 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 listList retargeting pixels
- -l, --limit
- --page
-
linktwin pixels get <id>Show a pixel and its assigned links
- -l, --limit
- --page
-
linktwin pixels createCreate 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
$ 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 listList QR codes
- -l, --limit
- --page
-
linktwin qr get <id>Show a QR code and its scan analytics
-
linktwin qr createCreate 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
$ 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 loginSave your LinkTwin API key and base URL
- -k, --key
- -u, --url
- --no-verify
-
linktwin logoutRemove saved credentials
-
linktwin whoamiShow the current account, plan and usage
-
linktwin configShow where credentials are read from
$ 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.
# 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)"'
# 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
# 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"}]}'
# 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.
MCP server
Let your AI agent make the links
See the MCP serverAPI documentation
Every endpoint, with examples
Read the API docsShorten 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