Configuration file
About 1496 words
unifi-cli keeps its configuration in one YAML file, ~/.config/unifi-cli/config.yaml. The file holds two things: your accounts, controllers and contexts, and your preferences. It never holds API keys.
You rarely need to open it. unifi login and unifi ctx manage the first half, and unifi config set covers the common preferences; the dashboard layout is the one part you edit by hand.
Look at the configuration
$ unifi config get
KEY VALUE DESCRIPTION
theme unifi Theme to render with
colorScheme auto Theme variant: auto detects the terminal background
output text Default output format
glyphs - Glyph set overriding the theme's; empty lets the theme decide
log.level info Minimum level written to the log file
telemetry.otlpEndpoint - OTLP/HTTP endpoint for traces; empty turns tracing off
prompt.format {context} Prompt segment template: {context}, {site}, {controller}, {account}
dashboard.refresh 5s Interval between dashboard refreshes, such as 5s| Command | Prints |
|---|---|
unifi config get | the preferences as a table |
unifi config get theme | one bare value, for scripts; the full path preferences.theme works too |
unifi config view | the effective configuration as YAML: the file's content with every default filled in |
unifi config path | where the files are |
Change a preference
unifi config set theme nord
unifi config set colorScheme dark
unifi config set output json
unifi config set prompt.format '{context} · {site}'
unifi config set dashboard.refresh 10sThe value is validated before anything is written. A theme must exist, an enumerated preference must use one of its values, and the refresh interval must be a duration:
$ unifi config set theme bogus
✗ "bogus" is not a valid value for "theme".
Advice:
• Use one of: catppuccin, dracula, gruvbox, mono, nord, solarized, tokyo-night, unifi.Preferences that can be switched off take an empty value: unifi config set telemetry.otlpEndpoint "".
Setting output to json makes every command print JSON by default. That suits a machine account and is tiresome on your own laptop; --output json per command is usually the better habit.
Edit the file
unifi config editThis opens the file in $VISUAL, then $EDITOR, then vi, and validates it when the editor exits. You edit a copy, and the configuration file is replaced in one step only when the copy validates. Otherwise the file stays as it was, unifi-cli shows the error, and your rejected text is saved next to it with the suffix .rejected.
If you'd like a file where every preference is present and explained, generate one:
unifi config init # only when no file exists yet
unifi config init --force # rewrite an existing file in the commented formWith --force, your accounts, controllers, contexts and preference values carry over. Comments you wrote yourself don't.
The file, section by section
# yaml-language-server: $schema=https://unifi-cli.specht-labs.de/schema/config.schema.json
apiVersion: unifi.specht-labs.de/v1alpha1
kind: Config
currentContext: home
accounts:
- name: me
type: cloud
email: [email protected]
controllers:
- name: udm
consoleId: 0123456789ABCDEF
- name: udm-lan
address: https://192.168.1.1
caFile: ~/.config/unifi-cli/udm.pem
contexts:
- name: home
account: me
controller: udm
site: Default
preferences:
theme: unifi
colorScheme: auto
output: text
log:
level: info
telemetry:
otlpEndpoint: ""
prompt:
format: "{context}"
dashboard:
refresh: 5s
rows: []accounts, controllers and contexts are explained in the contexts guide. The preferences block is everything else:
| Key | What it does | Guide |
|---|---|---|
theme, colorScheme, glyphs | How output looks | Themes |
output | The default of --output | Output formats |
dashboard | Refresh interval and widget layout | Dashboard |
prompt.format | The shell prompt segment | Prompt integration |
log.level | Verbosity of the log file | below |
telemetry.otlpEndpoint | Where traces go | below |
The configuration reference lists every field with its type and default. A complete, commented example with a custom dashboard is in examples/config.yaml.
Schema
The first line of the file points editors at the JSON schema, which gives you completion and validation in any editor with a YAML language server. The schema is published at https://unifi-cli.specht-labs.de/schema/config.schema.json, and the binary prints the version that matches it:
unifi config schema config > config.schema.json
unifi config schema theme | jq '.properties | keys'Where the files are
$ unifi config path
Config file ~/.config/unifi-cli/config.yaml
Themes ~/.config/unifi-cli/themes
Log file ~/.local/state/unifi-cli/unifi.log
Credentials file ~/.config/unifi-cli/credentials.yaml
Cache ~/.local/state/unifi-cli/cacheThe command prints absolute paths; they're shortened here. The configuration lives under ~/.config on every platform, macOS and Windows included, so one dotfiles repository works everywhere. The credentials file only exists on machines without an OS keychain, or when UNIFI_CREDENTIAL_STORE=file asks for it. The history of unifi shell is kept next to the log, in history.
Three environment variables move things:
| Variable | Effect |
|---|---|
UNIFI_CONFIG | Path of the configuration file. Themes and the credentials file follow it into the same directory. |
XDG_CONFIG_HOME | Base directory for configuration; the file becomes $XDG_CONFIG_HOME/unifi-cli/config.yaml. |
XDG_STATE_HOME | Base directory for state; the log becomes $XDG_STATE_HOME/unifi-cli/unifi.log, and the cache moves with it. |
UNIFI_CONFIG is the tool for keeping setups apart. A project can carry its own configuration, and a CI job can use one that's checked in:
UNIFI_CONFIG=./ci/unifi-config.yaml unifi diff -f site/ -RThe cache
unifi-cli remembers a few answers on disk so that it doesn't ask the controller for the same thing on every command.
| What | Kept for |
|---|---|
| A controller's site list and version | 10 minutes |
| Candidates for shell completion (client, device, port names) | 60 seconds |
| The last dashboard and topology snapshot | 24 hours |
| Your terminal's background color | 24 hours |
The first two save a request or two per command, which you notice most through a cloud context. The snapshot is what lets unifi dashboard and unifi topology --watch draw at once and refresh behind the picture; a live view always marks cached data as such.
The cache never holds an API key or another secret, and nothing in it is needed: delete the directory to clear it. --no-cache on any command, or UNIFI_NO_CACHE=1 in the environment, makes unifi-cli ask the controller for everything. Reach for it when you've just changed something in the web interface and want to be sure you're looking at the present.
On a terminal, a command that takes longer than about 300 milliseconds shows a progress line on standard error, which disappears when the output arrives. It never shows up in a pipe.
Environment variables
| Variable | Effect |
|---|---|
UNIFI_CONFIG | Path of the configuration file |
UNIFI_API_KEY | API key that overrides the stored key of every account |
UNIFI_LOG_LEVEL | Log level for this run, overriding log.level: debug, info, warn or error |
UNIFI_CREDENTIAL_STORE | Where unifi login keeps API keys: auto, keyring or file |
UNIFI_NO_CACHE | Set to 1 to bypass the cache, like --no-cache |
UNIFI_API_KEY deserves a warning. It answers for every account, so with it set, every context authenticates with that one key, whichever console the context points at. Set it per command or per job, and don't export it from your shell profile.
The environment reference has the complete list, including the variables unifi-cli reads from your terminal and editor setup.
The log
unifi-cli writes a log of what it does: every API request with its method, path, status and duration, every retry, and every failed command. The file is JSON lines, readable by you alone, and rotates at 5 MB with three files kept.
tail -f "$(unifi config path --output json | jq -r .logFile)" | jq .By default it records at info, which covers failures and retries. unifi config set log.level debug raises the level for good, and UNIFI_LOG_LEVEL overrides the configured level for one command, which is usually what you want when you're chasing a single failure:
$ UNIFI_LOG_LEVEL=debug unifi clients get --limit 1 >/dev/null
$ tail -n 1 ~/.local/state/unifi-cli/unifi.log
{"time":"2026-11-30T12:42:02.05137+01:00","level":"DEBUG","msg":"request","version":"0.1.0","method":"GET","path":"/api/s/default/rest/user","status":200,"duration":"264.083µs"}The log never contains API keys. Every record passes a filter that blanks attributes whose name looks like a key, password, secret, token, cookie or authorization header. It does name your hosts, sites and devices, so read it before you attach it to a public bug report.
Tracing with OpenTelemetry
unifi-cli can export a trace of the API calls behind each command, which shows where a slow unifi dashboard or unifi export spends its time. Tracing is off unless you name an endpoint:
unifi config set telemetry.otlpEndpoint http://localhost:4318The endpoint speaks OTLP over HTTP. Any collector works; for a quick look, run Jaeger locally:
docker run --rm -p 16686:16686 -p 4318:4318 jaegertracing/all-in-one
unifi export > /dev/null
open http://localhost:16686 # service "unifi-cli"Each call to the controller or to the Site Manager API is a span. Spans go to the endpoint you configure and nowhere else, and nothing is sent when the setting is empty. Turn tracing off again with unifi config set telemetry.otlpEndpoint "".
