---
url: https://docs.sunlicense.com/cli.md
description: >-
  Install the sunlicense CLI on macOS, Linux or Windows, sign in, and manage
  your organization from a terminal.
---

# SunLicense CLI

`sunlicense` puts your organization in your terminal. Run it on its own for a full-screen app
where every task is one key away, or use its commands in scripts and CI.

![The sunlicense app: an overview of Acme Tools with products, active licenses, machines and today's checks](/images/cli/overview.png)

* **Sign in once** with your SunLicense account, and stay signed in to several organizations.
* **Issue, revoke, suspend and inspect licenses**, create policies and API keys, without opening the dashboard.
* **Script it**: every action is also a command with `--json` output and `--yes` for no prompts.

## Install

Pick whichever suits your system. Each one installs the same single binary, checked against the
release's [`checksums.txt`](https://sunlicense.com/download/checksums.txt), and none of them goes
through a web browser, so macOS and Windows run it straight away, without a security warning.

### macOS and Linux

```bash
curl -fsSL https://sunlicense.com/install.sh | sh
```

![Installing with the install script](/images/cli/cmd-install.png)

The script picks the build for your system (Intel or ARM), checks it, and installs it to
`/usr/local/bin`, or to `~/.local/bin` when that folder isn't writable. It never uses `sudo`.
It also works in WSL, containers (with `curl` or `wget`) and Git Bash on Windows, where it installs
to `~/bin`. Run the same command again to update.

| Variable | Default | |
|---|---|---|
| `SUNLICENSE_INSTALL_DIR` | `/usr/local/bin` | Where to put `sunlicense` |

### Windows

In PowerShell:

```powershell
irm https://sunlicense.com/install.ps1 | iex
```

The script picks the build for your PC (x64 or ARM), checks it, installs it to
`%LOCALAPPDATA%\Programs\sunlicense` and adds that folder to your user `PATH`. It needs no
administrator rights. `SUNLICENSE_INSTALL_DIR` chooses another folder.

Use Windows Terminal (or any terminal with 24-bit colour) for the full-screen app.

### npm

Anywhere Node.js 16 or later runs, including most AI coding assistants:

```bash
npx -y @sunlicense/cli@latest login     # run it without installing
npm install -g @sunlicense/cli          # or install the sunlicense command
```

npm downloads only the build for your system. `pnpm dlx @sunlicense/cli` and `bunx @sunlicense/cli`
work the same way. Update a global install with `npm install -g @sunlicense/cli@latest`.

::: tip The CLI is @sunlicense/cli
The npm package called `sunlicense` is the [JavaScript SDK](/guide/sdks), for checking licenses
in your own app. The command line is `@sunlicense/cli`.
:::

### Homebrew

On macOS or Linux:

```bash
brew install sunlicense-com/tap/sunlicense
```

Update with `brew upgrade sunlicense`.

### Scoop

On Windows:

```powershell
scoop bucket add sunlicense https://github.com/sunlicense-com/scoop-bucket
scoop install sunlicense/sunlicense
```

Update with `scoop update sunlicense`.

### Updating

In a terminal, `sunlicense` looks for a new version once a day while a command runs, and asks
afterwards: *"sunlicense 0.4.0 is available (you have 0.3.0). Update now?"*. **Yes** downloads the new
version and replaces this one; **Not now** keeps it quiet for a day. Run `sunlicense update` to update
any time, or `sunlicense update --check` to only look.

Every update is verified before anything changes: `checksums.txt` must carry a valid signature from
SunLicense's release key (built into the CLI), and the download must match its checksum. If any check
fails, the CLI keeps the version you have and says why.

It never checks or asks in scripts and CI (no terminal, `CI` set or `--json`), in `sunlicense mcp`, under
`npx`, or when turned off: `sunlicense update --auto-check off` (or `SUNLICENSE_NO_UPDATE_CHECK=1`). The
check sends only the CLI's version and platform (`sunlicense-cli/0.3.0 (darwin/arm64)`), no account details.

Installed with npm, Homebrew or Scoop? Then that package manager updates `sunlicense`: the CLI only tells
you a new version is out and the command to run (`npm install -g @sunlicense/cli@latest`,
`brew upgrade sunlicense` or `scoop update sunlicense`).

If `sunlicense` sits in a folder you can't write to (installed with `sudo`), it shows the install command
to run instead, e.g. `curl -fsSL https://sunlicense.com/install.sh | sudo SUNLICENSE_INSTALL_DIR=/usr/local/bin sh`.
Builds from before 0.4.0 can't update themselves: reinstall once with the commands above.

**Uninstall:** delete the file (`rm "$(command -v sunlicense)"`), or `npm uninstall -g @sunlicense/cli`,
`brew uninstall sunlicense`, `scoop uninstall sunlicense`. To forget your sessions, also delete the config
file shown in [Where sessions are stored](#where-sessions-are-stored).

### Manual download {#all-downloads}

Prefer one of the commands above. If you do download a file yourself, every build is a single file with
no dependencies. Current version: [`VERSION`](https://sunlicense.com/download/VERSION).

| | Intel / AMD (x86-64) | ARM |
|---|---|---|
| **macOS** | [sunlicense_darwin_amd64](https://sunlicense.com/download/sunlicense_darwin_amd64) | [sunlicense_darwin_arm64](https://sunlicense.com/download/sunlicense_darwin_arm64) (Apple silicon) |
| **Linux** | [sunlicense_linux_amd64](https://sunlicense.com/download/sunlicense_linux_amd64) | [sunlicense_linux_arm64](https://sunlicense.com/download/sunlicense_linux_arm64) |
| **Windows** | [sunlicense_windows_amd64.exe](https://sunlicense.com/download/sunlicense_windows_amd64.exe) | [sunlicense_windows_arm64.exe](https://sunlicense.com/download/sunlicense_windows_arm64.exe) |

Check a download against [`checksums.txt`](https://sunlicense.com/download/checksums.txt):

```bash
curl -fsSL https://sunlicense.com/download/checksums.txt | grep darwin_arm64
shasum -a 256 sunlicense_darwin_arm64        # Linux: sha256sum
```

A file downloaded **with a web browser** is marked as coming from the internet, and because the CLI isn't
signed with a paid Apple or Microsoft certificate, the system warns before running it. Unblock it once:

**macOS** ("cannot be opened because Apple cannot check it for malicious software"): clear the quarantine
flag in Terminal, then move the file to a folder on your `PATH`:

```bash
chmod +x sunlicense_darwin_arm64
xattr -d com.apple.quarantine sunlicense_darwin_arm64
sudo mv sunlicense_darwin_arm64 /usr/local/bin/sunlicense
```

Or, after the warning, open **System Settings → Privacy & Security**, scroll to *Security*, choose
**Open Anyway** next to the message about `sunlicense`, and confirm.

**Windows** ("Windows protected your PC"): choose **More info**, then **Run anyway**. Or before running it,
right-click the file → **Properties** → tick **Unblock** at the bottom of the *General* tab → **OK**, or in
PowerShell:

```powershell
Unblock-File .\sunlicense_windows_amd64.exe
```

Then rename it to `sunlicense.exe` and move it to a folder on your `PATH`, for example:

```powershell
mkdir $HOME\bin -Force
Move-Item .\sunlicense_windows_amd64.exe $HOME\bin\sunlicense.exe
[Environment]::SetEnvironmentVariable("Path", "$env:Path;$HOME\bin", "User")   # then open a new terminal
```

## Sign in

Use the same email and password as the [dashboard](https://app.sunlicense.com).

```bash
sunlicense login
```

Or run `sunlicense` and sign in on the first screen. Press `ctrl+n` there to create a new
organization instead (you become its Owner), and `ctrl+s` to point the CLI at another server.

![The sign-in screen](/images/cli/sign-in.png)

`sunlicense whoami` shows who you are, your role and plan, and how long the session lasts:

![sunlicense whoami](/images/cli/cmd-whoami.png)

A session lasts 12 hours, like the dashboard. When it ends, the app asks for your password again
with your email filled in; a command says so and exits with `sunlicense login` as the fix.

### With a personal access token

For a computer you don't want to sign in to every 12 hours (a build server, an AI assistant's
machine), create a **personal access token** in the dashboard under **Settings → Personal access
tokens**, with only the scopes it needs, and sign in with it:

```bash
sunlicense login --with-token            # paste the token (slp_…)
echo "$TOKEN" | sunlicense login --with-token
```

It's saved like any other account and works until it expires or you revoke it in the dashboard.
It can only do what its scopes allow ([details](/api/overview#personal-access-tokens)).

### Several organizations

Sign in again with another account and both stay saved. Switch with `sunlicense switch` (or
`a` then `enter` in the app), or run one command as another account with `--account`:

```bash
sunlicense switch                         # pick from a list
sunlicense switch "Bolt Labs"             # by organization or email
sunlicense licenses --account ops@boltlabs.dev
```

The same email can be saved for production and a local stack (`sunlicense login --local` signs in
to `http://localhost`); each account remembers its server.

### Sign out

```bash
sunlicense logout                 # the current account
sunlicense logout jane@acme.com   # another saved account
sunlicense logout --all           # every account on this computer
```

Signing out forgets the session on this computer. A session that was copied elsewhere stays valid
until it expires (at most 12 hours). To stop a personal access token everywhere, revoke it in the
dashboard under **Settings**.

### Where sessions are stored

| System | File |
|---|---|
| macOS | `~/Library/Application Support/sunlicense/config.json` |
| Linux | `~/.config/sunlicense/config.json` |
| Windows | `%AppData%\sunlicense\config.json` |

The file is readable only by you (mode `0600`). Set `SUNLICENSE_CONFIG` to use another file.

## Next

* [The app](/cli/app): every screen and key.
* [Commands and scripting](/cli/commands): one-shot commands, `--json`, CI, and testing an integration.
