CLI Authentication
The CLI talks to your lnkify server's GraphQL API, so it uses the same credentials documented in Developer · Authentication: an API key or a JWT from logging in. This page covers how the CLI resolves and stores them.
Choosing a server
The CLI is local-first — it defaults to http://localhost:4000. Point it at any instance with the url setting:
lnkify config set url https://lnkify.example.comYou can also override per command with --url, or with the LNKIFY_API_URL environment variable.
Option 1 — Log in (JWT)
lnkify login exchanges your email and password for a session token and stores it in the active profile:
lnkify login
# or non-interactively
lnkify login --email you@example.com --password '••••••••'Confirm who you're authenticated as:
lnkify whoamiClear the stored token with lnkify logout.
Option 2 — API key
Create a key in the dashboard (see the API Keys guide) or with the CLI itself, then save it:
lnkify apikeys create "my-laptop"
lnkify config set api-key lf_live_YOUR_KEYAPI keys use the x-api-key header and are ideal for scripts and CI. You can also pass a key per command with --api-key, or via the LNKIFY_API_KEY environment variable — handy for CI where you don't want it written to disk:
LNKIFY_API_KEY=lf_live_YOUR_KEY lnkify links listSave your key immediately
When you create a key, the full secret is shown once. Copy it and store it securely — it cannot be retrieved later. If you lose it, revoke it and create a new one.
Resolution precedence
When more than one source provides a value, the CLI resolves it in this order (highest wins):
- Flags —
--url,--api-key - Environment —
LNKIFY_API_URL,LNKIFY_API_KEY - Active profile — selected with
--profile(else the default profile) - Built-in default —
http://localhost:4000
An API key takes precedence over a stored login token. Run lnkify config list to see the effective values and the source of each.
Profiles (multiple servers)
Profiles let you save several named servers — typically a local instance plus one or more remotes — and switch between them with --profile:
lnkify --profile prod config set url https://links.acme.com
lnkify --profile prod config set api-key lf_live_PROD_KEY
lnkify --profile prod links list # hits prod
lnkify links list # hits the local defaultSet a different default with:
lnkify config set default-profile prodWhere credentials are stored
Config lives at ~/.config/lnkify/config.json (honoring $XDG_CONFIG_HOME) and is written with 0600 permissions because it holds secrets. Inspect the resolved configuration any time:
lnkify config listNext: Commands