The PublishQ CLI lets you publish and schedule posts, and manage your accounts, media and workspaces, from the terminal.

## Install

```bash
npm install -g @publishq/cli@latest
```

You get two commands, `publishq` and `pq`. They are the same.

## Sign in

```bash
pq login
```

It prints a link and a code and opens the link in your browser. Check the page shows the same code and click **Approve**. The login is saved on your machine and renews itself. On a server over SSH, open the link on any other device. `pq logout` signs out.

To use an API key instead, run `pq auth set --key "pq_live_..."`. See [Create an API key](/hc/help-center/articles/create-an-api-key).

## Try it

```bash
pq accounts list --pretty
```

Output is JSON by default, which suits scripts and agents. Add `--pretty` to read it yourself.

## In CI

Set `PUBLISHQ_API_KEY` in the job's environment. The CLI reads it directly, so nothing is written to disk.

## Learn more

Every command is in the [CLI docs](https://publishq.com/docs/cli). Your CLI logins are listed under **API Keys > Connected apps** as "PublishQ CLI", where you can disconnect them.

![Connected apps with a PublishQ CLI login framed](/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBZdz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--43661c66651012499b4ce78314b5d4a37fc6f811/50-cli-connected-desktop.png)
