Skip to content

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:

bash
lnkify config set url https://lnkify.example.com

You 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:

bash
lnkify login
# or non-interactively
lnkify login --email you@example.com --password '••••••••'

Confirm who you're authenticated as:

bash
lnkify whoami

Clear 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:

bash
lnkify apikeys create "my-laptop"
lnkify config set api-key lf_live_YOUR_KEY

API 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:

bash
LNKIFY_API_KEY=lf_live_YOUR_KEY lnkify links list

Save 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):

  1. Flags--url, --api-key
  2. EnvironmentLNKIFY_API_URL, LNKIFY_API_KEY
  3. Active profile — selected with --profile (else the default profile)
  4. Built-in defaulthttp://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:

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 links list   # hits prod
lnkify links list                  # hits the local default

Set a different default with:

bash
lnkify config set default-profile prod

Where 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:

bash
lnkify config list

Next: Commands

Released under the MIT License.