Authorization header of every request. Tokens are scoped to your user account and carry your organization permissions.
Get a Token
You can obtain a token in two ways: via thenh CLI or from the NervesCloud web UI.
- CLI
- NervesCloud UI
Authenticate with the CLI to generate and store a token locally:This opens a browser flow on your NervesHub instance. After you confirm the session, the CLI stores your token automatically for subsequent commands.
Use the Token
Pass the token as aBearer credential in the Authorization header of every API request:
YOUR_TOKEN with your actual token value.
Store the Token as an Environment Variable
Rather than embedding your token in every command, export it as an environment variable. Both the CLI and shell scripts can read from it:nh CLI reads NERVES_HUB_TOKEN (or NH_TOKEN) automatically, so authenticated commands need no additional flags:
curl and scripts, reference the variable in the header:
Verify Authentication
Confirm your token is valid by calling the/api/users/me endpoint:
401 error:
Error Responses
A
403 usually means your organization role is too low for the operation rather than that the token is bad. Read-only calls need view; creating or changing resources needs manage; organization settings, member management, and certificate authorities need admin.
