--help for its full description and examples.
All commands accept the global flags: --uri, --token, --org, --product, --data-dir, --non-interactive and -o/--output. Commands that work on a product need an organization and a product, from flags, environment variables or saved settings.
Commands that delete or deactivate something ask for confirmation first. Pass -y or --yes to skip the prompt.
nh user
nh user auth is refused for an account with two-factor authentication on. Use nh user login. See Configuration.
nh org
<role> is admin, manage or view. The API cannot assign custom roles, so assign those in the web interface. Setting a built-in role on a member who holds a custom role replaces the custom role. nh org members shows a custom role by its name, marked (custom).
Inviting members, changing roles and removing members need the Admin role. See Roles.
nh product
nh product update sends only the flags you pass. A product cannot be renamed.
The formats are
fwup, esp-idf, atomvm and rauc. fwup is always kept. The yes/no flags take =true or =false, and the flag on its own means true.
fwup must also be enabled on the instance. See Feature prerequisites.
nh device
nh device list
nh device create and nh device update
update changes only the fields you pass.
The API cannot set a device’s deployment group. NervesHub assigns a device to a group whose version and tag conditions it matches when the device connects. To place a device in a group yourself, use the web UI. See Put a device in a group by hand.
nh device import
Create devices, with their certificates, from a Microchip Trust&Go manifest. Pass - to read the manifest from standard input.
nh checks every entry first and sends nothing if any has a problem. NervesHub creates the devices in the background and reports the result on the product’s notifications page.
Device actions
nh device move takes --to-product (required) and --to-org (defaults to the current organization).
Remote access
console and shell need a user access token, not a product API key. See Remote console and Local shell.
Press Ctrl-] to detach from an iroh console.
nh device logs
Show the log lines a device has sent. See Logging.
nh device metrics
Show the metric readings a device has reported, grouped by metric name. See Metrics and alarms.
Run code and scripts
For
scripts and run-script, --org and --product are optional. Set both or neither. When set, the device must belong to that product.
See Support scripts.
nh device network-identities
List the keys a device reports holding on other networks. Alias: identities. See Network identity.
nh device certificates
Manage a device’s certificates. Alias: certs.
generate creates a device private key and, by default, a certificate signing request on disk, without uploading anything. Files go to <data-dir>/certificates/<org>/.
lookup finds the device, anywhere in the organization, that a PEM or DER certificate is registered to. Only the certificate is sent.
See Device certificates.
nh device shared-secrets
Manage a device’s own shared secrets. Alias: shared-secret.
create and cannot be fetched again. list never shows secrets. See Shared secrets.
nh firmware
download saves the image in the current directory as <uuid> with the extension for its format. Pass -f/--file <path> to choose the path, or --file - to write to stdout.
nh firmware upload
Sign a firmware image and upload it to the product.
The path. Inside a Nerves project you can leave out the path.
nh then looks for a single image under _build/<MIX_TARGET>_<MIX_ENV>/nerves/images/ and asks you to confirm it. With --non-interactive or without a terminal, pass the path or --yes.
The format is detected from the file’s contents, not its name. Before uploading, nh shows the image’s own metadata and refuses an image built for a different product.
If you give no key and do not pass
--skip-signing, the upload of an fwup or AtomVM image fails.
Deploying. --deploy creates a release with the new firmware and no archive on each named group. When --deploy is not given, NERVES_HUB_DEPLOYMENT_NAME is used if set. A failed deployment does not undo the upload: the error names the firmware UUID so you can retry with nh deployment update.
With -o json, the command prints the uploaded firmware as one JSON document on stdout, with a deployed list of the groups it updated.
nh archive
Manage archives: supporting fwup files a release can deliver to devices. See Archives.
upload checks the archive’s metadata (its meta-version must be a semantic version), signs it with fwup, and uploads it. It takes --key, --key-file, --password and --skip-signing, which work as they do for nh firmware upload.
download saves the archive as <uuid>.fw. Pass -f/--file <path> to choose the path, or --file - to write to stdout.
The API has no way to delete an archive.
nh deployment
Manage deployment groups. Alias: deployments.
nh deployment create and nh deployment update
The server always creates a group turned off, so
create --state on turns it on with a second request.
On update, a new release and setting changes go to the server as separate requests: settings and --state off first, then the release, then --state on.
nh deployment release
Manage a group’s releases. Alias: releases. See Releases.
A new release becomes the group’s current release. A release’s firmware, archive, description and notes cannot change once it is made.
The
release commands need a server with the deployment release API. On a server without it they fail with a message saying to upgrade. nh deployment update --firmware and nh firmware upload --deploy work on both: they fall back to the older deployment group update request.
See Connecting code.
nh key
Manage an organization’s firmware signing keys. See Firmware signing.
create generates a key pair locally and registers the public key. The private key stays in <data-dir>/keys/<org>/. add registers an existing public key or certificate without generating anything. delete removes the key from the server and keeps the local key files.
A key only verifies firmware of its own scheme.
nh ca
Manage an organization’s CA certificates. See Device certificates and Just-in-time provisioning.
generate writes the key and certificate to <data-dir>/ca/<org>/, named by the generation time.
Registering a CA proves ownership by signing a verification certificate with the CA’s private key, so the key is needed even for a CA made elsewhere.
nh script
Manage a product’s support scripts. Alias: support-script. See Support scripts.
<id> is the integer nh script list shows. list takes --page and --page-size.
To run a script on a device, use
nh device run-script.
nh webhook
Manage an organization’s webhooks. See Webhooks.
create prints the signing secret once. NervesHub does not show it again. regenerate-secret replaces the secret and prints the new one once, and the old one stops working at once. Signing secrets are never listed or shown.
test sends a webhook.test event and reports how the endpoint answered. It exits non-zero when the endpoint did not accept the event.
Run nh webhook create --help for the event types.
nh iroh-endpoint
Manage an organization’s iroh endpoint ids. Alias: iroh.
nh config
View and change saved CLI defaults. See Configuration.
nh status
Check that the configured server is up. It calls the server’s health check, needs no token, and exits non-zero when the server is unreachable or reports a problem.
nh migrate
Import settings and signing keys from the Elixir nerves_hub_cli. See Migrate from the Elixir CLI.
Errors and exit codes
nh exits 0 on success and 1 on failure. A command interrupted with Ctrl-C exits 130.
When the API refuses a request, nh prints the status code and the server’s message, then one line per invalid field:

