---
title: Notehub CLI
description: Install the Notehub CLI, then sign in to Notehub and use it to send Notehub API requests, upload host firmware, and update the firmware on your devices.
source_url: https://dev.blues.io/tools-and-sdks/notehub-cli/
canonical_url: https://dev.blues.io/tools-and-sdks/notehub-cli/
markdown_url: https://dev.blues.io/tools-and-sdks/notehub-cli.md
---

# Notehub CLI

The Notehub CLI (`notehub`) is a command-line utility for working with [Notehub](https://dev.blues.io/notehub/notehub-walkthrough.md) from a terminal, a script, or an AI agent. It signs in to Notehub as you, sends any [Notehub API](https://dev.blues.io/api-reference/notehub-api.md) request, and manages your project's host firmware and the updates that install it on your devices.

The Notehub CLI is part of the [note-cli](https://github.com/blues/note-cli) project, and installs alongside the [Notecard CLI](https://dev.blues.io/tools-and-sdks/notecard-cli.md).

AI Tip

An AI agent that can run commands can use the Notehub CLI directly. `notehub --help-agent` prints a guide written for agents that covers signing in, finding the right Notehub API operation, and making requests. Notehub IQ repositories are queried through [Notehub MCP](https://dev.blues.io/tools-and-sdks/generative-ai-tools/notehub-mcp.md), not the CLI.

Prompt

Run `notehub --help-agent` and follow its guide to sign in to my Notehub account, then list my Notehub projects.

## Installation {#installation}

The Notehub CLI and the Notecard CLI install together, from Homebrew or from a release archive.

### Using Homebrew {#using-homebrew}

Install both CLIs with [Homebrew](https://brew.sh):

```bash
brew install --cask blues/note-cli/note-cli
```

### Using a Release Archive {#using-a-release-archive}

Visit the [releases page of the note-cli repository](https://github.com/blues/note-cli/releases) and download the archive for your operating system. Each archive contains both `notehub` and `notecard`. Extract `notehub` and place it in your `PATH`. On Debian-based Linux, you can install the `notehub` `.deb` package from the same page instead.

To build the CLIs yourself, follow the [build instructions in the note-cli README](https://github.com/blues/note-cli#build-from-source).

Once it's installed, confirm the version:

```bash
notehub --version
```

## Signing In {#signing-in}

Commands that reach your Notehub account need you to sign in first. Run:

```bash
notehub login
```

`notehub login` opens Notehub in your browser, where you approve the sign-in and choose what the CLI can access, as described in [Authorizing Apps and AI Agents](https://dev.blues.io/notehub/notehub-walkthrough.md#authorizing-apps-and-ai-agents). The CLI saves the sign-in and uses it for every command that follows. It appears on Notehub's **API Access** page as `Notehub CLI - <name>`, using your computer's name unless you give another with `--name`:

```bash
notehub login --name "Work laptop"
```

If Notehub still accepts your saved sign-in, `notehub login` exits without opening anything, so it's safe to run whenever you aren't sure. To check without signing in, run `notehub auth status`, which exits with `0` when Notehub accepts the sign-in and `1` when it doesn't.

A sign-in that isn't used for 72 hours expires, and you need to run `notehub login` again. `notehub logout` signs you out and revokes the sign-in at Notehub.

An AI agent signs in with `notehub login --name "<agent name>" --json`, which opens nothing and prints the sign-in link for you to open in your own browser. `notehub --help-agent` walks an agent through it.

### Signing In with a Personal Access Token {#signing-in-with-a-personal-access-token}

For a script or CI job that has no one to approve a browser sign-in, use a [personal access token](https://dev.blues.io/api-reference/notehub-api.md#personal-access-tokens) instead. Provide it in the `NOTEHUB_TOKEN` environment variable, for example from your CI system's secret settings. While `NOTEHUB_TOKEN` is set, every command uses that token instead of a saved sign-in, and you need to clear it before you can sign out.

You can also save a token as your sign-in. `notehub login --with-token` reads it from stdin, which keeps it out of your shell history. Here `$SECRET` holds the token:

```bash
echo "$SECRET" | notehub login --with-token
```

The CLI doesn't refresh personal access tokens. Each one expires on the date you chose when you created it.

## Making API Requests {#making-api-requests}

`notehub api` sends one request to the [Notehub API](https://dev.blues.io/api-reference/notehub-api.md) as you, and writes the response body to stdout. It adds your credentials, so you never handle a token yourself. Give the HTTP method and the path from the API reference, not a full URL:

```bash
notehub api GET /v1/projects
```

Always name the method. Without one, `notehub api` sends a `GET`, but switches to a `POST` as soon as you add a field or a body.

### Filling In Paths and Parameters {#filling-in-paths-and-parameters}

Where a path needs a ProjectUID or DeviceUID, write `{project}` or `{device}` and fill it in with `--project` or `--device`, or write the UID into the path yourself. Quote paths that contain braces or a query string.

With `GET`, each `--field key=value` becomes a query parameter. This lists the five most recently captured events in a project:

```bash
notehub api GET '/v1/projects/{project}/events' --project <projectUID> \
  --field pageSize=5 --field sortOrder=desc
```

`--field` sends numbers, `true`, `false`, and `null` as JSON values, and everything else as a string. Use `--raw-field` for a value that must stay a string, such as a cursor.

### Sending a Request Body {#sending-a-request-body}

With other methods, `--field` values form a JSON body. For nested JSON, put the whole body in a file and send it with `--input`, or use `--input -` to read it from stdin. You can't combine `--input` with `--field`.

For example, to set an environment variable on a device, save this as `vars.json`:

```json
{ "environment_variables": { "sample_interval": "60" } }
```

Then send it:

```bash
notehub api PUT '/v1/projects/{project}/devices/{device}/environment_variables' \
  --project <projectUID> --device <deviceUID> --input vars.json
```

### Reading Responses {#reading-responses}

`notehub api` exits with `0` when Notehub answers with success, and `1` when it answers with an error or can't be reached. It still writes an error response's body, so check the exit code before you use the output.

These options change what you get back:

| Option | Description |
| - | - |
| `--include` | Write the HTTP status line and headers before the body. |
| `--pretty` | Indent a JSON response. It reads the whole response first, so leave it off for streaming responses. |
| `--verbose` | Write the request and the response status to stderr. |
| `--paginate` | On a `GET` that takes a modification `cursor`, such as events or devices, follow the cursor until there are no more results, writing each page separately. It starts at `0` unless you give a `cursor`. |

`notehub api --spec` prints Notehub's OpenAPI specification, which describes every operation, without signing in. Run `notehub api --help` for every option.

## Managing Host Firmware {#managing-host-firmware}

`notehub firmware` manages the host firmware stored in a Notehub project, and asks devices to install it using [host firmware updates](https://dev.blues.io/notehub/host-firmware-updates/host-dfu-overview.md). To list a project's firmware:

```bash
notehub firmware list --project <projectUID>
```

Commands that take a firmware accept the filename Notehub stored it under, such as `app$20260324190911.bin`, or its original filename or version when only one firmware matches. Put single quotes around a stored filename so your shell doesn't treat its `$` as a variable.

### Uploading Firmware {#uploading-firmware}

```bash
notehub firmware upload ./build/app.bin --notes "Fixes the sensor timeout" \
  --project <projectUID>
```

The CLI reads the version from the `firmware::info:` metadata in the binary, if it has any. Otherwise, give the version with `--version`.

If the project already holds a firmware with the same filename and version but different contents, the upload replaces it: the CLI uploads the new file, then deletes the old one. Add `--no-replace` to stop with an error instead. If the project already holds the same bytes under that filename, the CLI skips the upload.

Add `--dry-run` to see what an upload would do without changing anything.

### Downloading Firmware {#downloading-firmware}

`notehub firmware get` downloads a firmware and checks it against the MD5 checksum Notehub stored for it:

```bash
notehub firmware get 1.2.3 ./app-1.2.3.bin --project <projectUID>
```

Give `-` as the path to write the firmware to stdout. If the local file already exists with different contents, the CLI keeps it unless you add `--force`.

### Updating Devices {#updating-devices}

`notehub firmware update` asks the devices in `--scope` to install a firmware. `--scope` takes DeviceUIDs, FleetUIDs, fleet names, or `@file` for a file that lists them, separated by commas. `--tag`, `--sn`, and `--sku` narrow the devices further. For example, to update the devices in the "Field Units" fleet:

```bash
notehub firmware update 1.2.3 --scope "Field Units" --project <projectUID>
```

To see which devices an update will reach, run `notehub firmware status` with the same `--scope` and filters first. `--dry-run` also works with `update` and `cancel`. To address every device in the project, use `--scope all` with `--force`.

Then follow the update with `status`, or call it off with `cancel`:

```bash
notehub firmware status --scope "Field Units" --project <projectUID>
notehub firmware cancel --scope "Field Units" --project <projectUID>
```

`notehub firmware --help` lists the other commands, including `show`, `edit`, `delete`, and `history`. Add `--json` to `list`, `show`, `status`, or `history` for output a program can read.

## Other Commands {#other-commands}

The Notehub CLI has shortcuts for common project and device tasks. Run `notehub` with no arguments for an overview and your saved settings, `notehub --help` for every option, and `notehub <mode> --help` for a mode such as `api` or `firmware`.

| Command | Description |
| - | - |
| `notehub --projects --pretty` | List the projects you belong to, with their products, as JSON. |
| `notehub --project <projectUID> --device <deviceUID> --explore` | List the Notefiles Notehub holds for a device, and their Notes. |
| `notehub --project <projectUID> --scope <devices> --get-vars` | Get the environment variables of devices or fleets. |
| `notehub --project <projectUID> --scope <devices> --set-vars '{"interval":"60"}'` | Set environment variables on devices or fleets. A value of `-` removes a variable. |
| `notehub --product <productUID> --scope <deviceUID> --provision --sn <serial>` | Provision devices into a product, with `--sn` as the serial number. |
| `notehub --agent-chat` | Print Notehub's conversation guide for AI agents. It needs no sign-in. |

`--scope` takes DeviceUIDs, FleetUIDs, a fleet's name, `@` followed by a fleet's name for each device in that fleet, `@file` for a file that lists them, or `devices` or `fleets` for all of them. Separate multiple values with commas.

## Additional Resources {#additional-resources}

- [Notehub API Reference](https://dev.blues.io/api-reference/notehub-api.md)
- [Authorizing Apps and AI Agents](https://dev.blues.io/notehub/notehub-walkthrough.md#authorizing-apps-and-ai-agents)
- [Notecard CLI](https://dev.blues.io/tools-and-sdks/notecard-cli.md)
- [Notehub MCP](https://dev.blues.io/tools-and-sdks/generative-ai-tools/notehub-mcp.md)
- [note-cli GitHub Repository](https://github.com/blues/note-cli)

Can we improve this page? [Send us feedback](mailto:devrel@blues.com)
