Try the demo controller
About 1261 words
unifi-cli ships with a mock controller, unifi-mock. It's a stateful fake of a UniFi OS console with a hand-built home-lab data set, and it's what the end-to-end tests, the examples in this documentation and the screenshots run against.
Use it to try commands without hardware, to rehearse a change before you make it on a real network, or to develop against unifi-cli.
Start it
From a checkout of the repository, with Docker:
docker compose up -d --build --wait unifi-mockOr without Docker, with the binary that mise run build produces (release archives named unifi-mock_<version>_<os>_<arch> carry it too):
./bin/unifi-mock --deterministicEither way it listens on https://localhost:8443 with a self-signed certificate, the way a console does out of the box. Both ways, it's reachable from your own machine only: the binary listens on 127.0.0.1 by default, and the compose file publishes the port on loopback.
Sign in
UNIFI_API_KEY=demo-api-key unifi login --local \
--address https://localhost:8443 --insecure-skip-tls-verify --name demoThe mock creates a new certificate each time it starts, which is why this sign-in skips verification instead of pinning; a pinned certificate would be wrong after the next restart.
To keep the demo out of your real configuration, put UNIFI_CONFIG=<some file> in front of this and the later commands; the key then goes into a keychain entry of its own. Add UNIFI_CREDENTIAL_STORE=file to keep it out of the keychain altogether.
The mock knows two API keys:
| Key | Acts as | Can |
|---|---|---|
demo-api-key | the administrator admin (owner) | read and change everything |
demo-readonly-key | the administrator viewer (view only) | read; every change is refused |
The read-only key is useful for seeing how unifi-cli reports a permission problem:
$ UNIFI_API_KEY=demo-readonly-key unifi clients block "Guest-iPhone" --yes
✗ The API key is not allowed to do this.
The client "Guest-iPhone" could not be blocked.
Advice:
• Check that your API key may change the network; read-only keys cannot.What's in it
Everything in the data set is invented. Addresses come from private and documentation ranges, and MAC addresses are locally administered.
The controller has two sites.
Default is a well-used home lab:
- A Dream Machine Pro Max as the gateway, with a fiber WAN and an LTE backup on standby.
- Three adopted switches (Core Switch with 26 ports, Garage Switch, Office Switch) and a USW Flex Mini that waits for adoption.
- Four access points. One of them, AP Hallway Mesh, has a wireless uplink, and AP Garden is offline.
- 48 clients: wired servers and cameras, phones and laptops on WiFi, three guests, a VPN client, and one blocked device.
- Six networks (Default, Trusted, IoT, Guest, Servers, Management), three SSIDs, eight firewall zones with their policies, port profiles, port forwards, DNS records, a WireGuard server, a site-to-site tunnel, traffic rules, vouchers and 18 settings keys.
- A system log with device, client, security, admin and update events.
The oddities are deliberate. There's an offline access point, a firmware update waiting on Office Switch, disabled ports, ports that negotiated 100 Mbit/s, and IDS alerts in the log, so that filters such as --offline, --upgradable and --severity warning have something to find.
Lake House is a small second site with a gateway, a switch, an access point, six clients and two networks. It's there for --site, unifi export --all-sites and multi-site manifests.
It keeps state
The mock is stateful: block a client, rename a port or apply a manifest, and the next command sees the change, including an entry in the audit log. State lives in memory, so restarting the mock brings back the original data set.
docker compose restart unifi-mockWith --deterministic, which the compose file sets, the mock's clock is frozen at 2026-03-14 20:30 UTC and every response is reproducible. That's why ages in the examples read "260d ago" or thereabouts, depending on when you run them. Without the flag, the clock runs and the statistics move.
The fake cloud
The mock also plays the cloud side: a Site Manager API with two consoles, the cloud connector that forwards to the Network application, and the UI account sign-in. It's mounted under /cloud.
Point unifi login at it with --cloud-address, a flag that exists for exactly this purpose and is hidden from --help. Together with it, the TLS flags apply to the cloud address too:
UNIFI_API_KEY=demo-api-key unifi login \
--cloud-address https://localhost:8443/cloud --insecure-skip-tls-verify \
--console "Dream Machine Pro Max" --name demo-cloud$ unifi consoles get --context demo-cloud --output wide
NAME MODEL VERSION STATUS IP ACCESS LAST SEEN ID
→ Dream Machine Pro Max UDM Pro Max 4.3.6 Online 203.0.113.10 owner 263d ago demo-console-home
Lake House Gateway Cloud Gateway Ultra 4.3.6 Online 198.51.100.24 invited 263d ago demo-console-lakeBoth consoles forward to the same Network application. The experimental e-mail sign-in works against it as well, with the account [email protected], the password demo-password and the one-time code 123456:
printf 'demo-password' | unifi login --sso \
--cloud-address https://localhost:8443/cloud --insecure-skip-tls-verify \
--username [email protected] --password-stdin --one-time-code 123456 \
--console "Lake House Gateway" --name demo-ssounifi logout demo-sso --revoke-key then exercises the revocation path.
These credentials are public, so anyone who can reach the mock could sign in with them and create API keys. The mock therefore refuses sign-in under /cloud unless it listens on a loopback address or you gave it a password and a code of your own with --demo-password and --demo-code. The compose file sets the public values on purpose, because it publishes the port on 127.0.0.1 only.
Options
| Flag | Default | Effect |
|---|---|---|
--listen | 127.0.0.1:8443 | address to listen on; :8443 listens on every interface |
--tls | true | serve HTTPS with a self-signed certificate |
--tls-hosts | localhost,127.0.0.1,::1,unifi-mock | names the certificate is valid for |
--api-key | demo-api-key | full-access key; also UNIFI_MOCK_API_KEY |
--readonly-api-key | demo-readonly-key | read-only key; also UNIFI_MOCK_READONLY_API_KEY. The default is only accepted while the full-access key is the default too |
--demo-user | [email protected] | e-mail address of the fake UI account; also UNIFI_MOCK_DEMO_USER |
--demo-password, --demo-code | the public demo values | password and one-time code of the fake UI account; also UNIFI_MOCK_DEMO_PASSWORD and UNIFI_MOCK_DEMO_CODE |
--deterministic | off | freeze the clock so responses are reproducible |
--latency | none | delay added to every response, such as 150ms, to feel a slow link |
--log-level | info | debug, info, warn or error |
--latency is a cheap way to see how the dashboard behaves over a cloud connection.
What it can't tell you
The mock imitates the documented and observed wire formats of UniFi Network 10.0. It answers what unifi-cli asks, and it validates far less than a real controller does, so it accepts writes that hardware might reject.
A change that works against the mock is a change with correct syntax. Whether your controller accepts it is something only your controller can say, which is the reason for --dry-run and for trying things on a spare port first.
The fixed demo credentials also mean the mock must never listen on an untrusted network.
Clean up
unifi logout demo --yes
docker compose down --volumes