ThingsBoard CLI configuration
ThingsBoard CLI connects to ThingsBoard with a profile. A profile contains a ThingsBoard URL and the credentials of a user. You can create several profiles, like one for each environment, and select the profile that the CLI uses.
Create a profile
Section titled “Create a profile”Run the wizard:
tb configThe wizard asks four questions. Then it tests the connection.
- ThingsBoard URL: Press Enter for ThingsBoard Cloud (
https://thingsboard.cloud). For Cloud EU, enterhttps://eu.thingsboard.cloud. For your own server, enter its URL. - Auth method: Press Enter to use
api_key. Thejwtmethod saves your username and password in plain text. - API Key: Paste your API key. The wizard shows the page where you create a key. For details, see API keys.
- Profile name: Press Enter to use
dev, or enter a name likecloudorprod.
If the connection fails, the wizard shows the reason and asks if you want to try again.
Connect from an AI agent
Section titled “Connect from an AI agent”An AI agent runs commands without a terminal, so it cannot type into the wizard. Use the browser option:
tb config --browserThe CLI opens the page Connect ThingsBoard CLI on your computer. Select ThingsBoard Cloud (North America), ThingsBoard Cloud (Europe), or Your own server. On the next step, paste the API key and click Connect. The key does not appear in the terminal or in the chat. The page closes after 15 minutes.
tb init --browser does the same when a new project has no working profile.
Create a profile in a script
Section titled “Create a profile in a script”tb config add <name> --url <url> --api-key <key> # create a named profiletb config set --url <url> --api-key <key> # set the default profileManage profiles
Section titled “Manage profiles”tb config list # show all profilestb config show # show the default profiletb config use <name> # make a profile the defaulttb config edit <name> # change the URL or the credentialstb config remove <name> # remove a profileTo use another profile for one command, add --profile <name> to the command.
Environment variables
Section titled “Environment variables”| Variable | Purpose |
|---|---|
TB_URL |
ThingsBoard URL. Replaces the URL of the active profile. |
TB_API_KEY |
API key. Replaces the credentials of the active profile. |
TB_PROFILE |
Name of the profile to use, the same as --profile. |
TB_CONFIG_HOME |
Folder for profiles and settings. Default: ~/.thingsboard. |
TB_DEBUG |
Set to 1 to show every HTTP request and response, the same as --debug. |
In CI, set TB_URL and TB_API_KEY as secrets:
TB_URL=https://thingsboard.cloud TB_API_KEY=$TB_API_KEY tb push my-solutionProject settings
Section titled “Project settings”Each project has a thingsboard.json file in its root folder. tb init creates it. The file contains:
- Mode:
local(default) saves changes to project files;remotesends them to ThingsBoard at once. For details, see Local and remote mode. - Agent format: The agent kit that the project uses:
claude,antigravity, orboth. - Kit version: The version of the agent kit. The CLI updates the kit when you install a new CLI version.
Was this helpful?