Notehub CLI
The Notehub CLI (notehub) is a command-line utility for working with
Notehub from a terminal, a script, or an AI
agent. It signs in to Notehub as you, sends any
Notehub API 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 project, and installs alongside the Notecard CLI.
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, not the CLI.
Run notehub --help-agent and follow its guide to sign in to my Notehub
account, then list my Notehub projects.
Installation
The Notehub CLI and the Notecard CLI install together, from Homebrew or from a release archive.
Using Homebrew
Install both CLIs with Homebrew:
brew install --cask blues/note-cli/note-cliUsing a Release Archive
Visit the
releases page of the note-cli repository
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.
Once it's installed, confirm the version:
notehub --versionSigning In
Commands that reach your Notehub account need you to sign in first. Run:
notehub loginnotehub 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.
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:
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
For a script or CI job that has no one to approve a browser sign-in, use a
personal access token
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:
echo "$SECRET" | notehub login --with-tokenThe CLI doesn't refresh personal access tokens. Each one expires on the date you chose when you created it.
Making API Requests
notehub api sends one request to the Notehub API
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:
notehub api GET /v1/projectsAlways 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
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:
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
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:
{ "environment_variables": { "sample_interval": "60" } }Then send it:
notehub api PUT '/v1/projects/{project}/devices/{device}/environment_variables' \
--project <projectUID> --device <deviceUID> --input vars.jsonReading 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
notehub firmware manages the host firmware stored in a Notehub project, and
asks devices to install it using
host firmware updates. To
list a project's firmware:
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
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
notehub firmware get downloads a firmware and checks it against the MD5
checksum Notehub stored for it:
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
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:
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:
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
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.