Skip to main content
Devices are the core entities in NervesHub. Each device has a unique identifier and belongs to exactly one product. NervesHub tracks the device’s current firmware version, online status, health metrics, and update history. Registering a device before it first connects is optional — NervesHub can auto-register devices on first connection when configured to do so — but explicit registration gives you full control over identifiers, tags, and certificates before any hardware is deployed.
Most nh device commands accept --org and --product flags to scope the operation. Set the NERVES_HUB_ORG and NERVES_HUB_PRODUCT environment variables to avoid repeating these flags on every command:

Registering a Device

Create a new device record with a unique identifier:
List all devices in a product, or inspect a specific device:
The device identifier is permanent. Choose identifiers that match your hardware serial numbers or manufacturing labels to make physical-to-digital traceability straightforward.

Assigning Tags

Tags control which deployment groups a device falls into. A group lists one or more tags and a tag operator — Require all (the default) or Allow any — so assigning the right tags is how you route firmware updates to the correct subset of your fleet:
This command sets the device’s tags to main and qa, replacing any previously assigned tags. A device can hold multiple tags simultaneously. Common tagging strategies:
  • By environmentdev, staging, production
  • By cohortbeta, canary, stable
  • By hardware revisionhw-rev-a, hw-rev-b

Bulk Registration

For large manufacturing runs, use the CSV import feature in the NervesCloud UI:
  1. Navigate to Products → my-product → Devices.
  2. Click Import Devices.
  3. Upload a CSV file with one device identifier per row (and optional tag columns).
For scripted workflows, use the nh CLI in a loop:

Device Certificates

For mTLS authentication, each device needs a certificate signed by a CA that you have registered with NervesHub. The nh CLI manages the full certificate lifecycle. List certificates for a device:
Generate a new certificate (development/testing):
This creates a certificate and private key pair locally. For production devices, provision certificates at the factory using your own PKI infrastructure and upload only the certificate (never the private key) to NervesHub. Upload an existing certificate:
NervesHub stores the public certificate so it can verify the device’s identity during the TLS handshake. The private key never leaves the device.

Device Actions

Trigger remote actions on a connected device directly from the CLI: Reboot the device:
Reconnect the device to NervesHub (closes and re-opens the WebSocket channel):
Open a remote IEx console:
The console streams an interactive IEx session over the NervesHub channel. Press Ctrl+C twice to exit without affecting the running device.
A device that repeatedly fails to apply an update is placed in the penalty box and stops receiving update notifications until its timeout expires. You can clear it from the device page in the console, or with the API, once you have addressed the underlying problem.

Device Logs

Stream or review logs from a device:
The --follow flag tails the log stream in real time. Omit it to retrieve a snapshot of recent log lines. Logs are useful for diagnosing connection issues, firmware crashes, or unexpected reboots without requiring physical access to the device.
Device logs require the logging extension to be enabled on the product, and the device’s client library must support it.

Deleting a Device

Remove a device record from NervesHub when a device is decommissioned:
Deleting a device removes it from NervesHub immediately, including its certificate associations and update history. The physical device will no longer be able to connect and receive updates. Ensure the device is properly decommissioned and offline before deleting it.