Authorization: Bearer. The easiest way is to store it once with unkey auth login. You can also pass it with a flag or an environment variable.
Store a key with unkey auth login
Enter your root key:) and doesn’t show what you type, so the key stays out of your screen and shell history. It saves the key to ~/.unkey/config.toml, which only your user can read. Run it again to replace the stored key. See unkey auth login for the full reference.
The file holds the key in plain text, so treat it like the key. Keep it out of version control and off shared machines. It’s best to create a root key just for the CLI, with only the permissions your scripts need. See Root key permissions.
Override the stored key
For one command, pass--root-key:
UNKEY_ROOT_KEY:
Which key unkey api uses
unkey api commands use the first key they find:
- The
--root-keyflag. - The
UNKEY_ROOT_KEYenvironment variable. - The
root_keyvalue in the config file. That’s~/.unkey/config.tomlunless you set--configorUNKEY_CONFIG.
no root key provided. If the API rejects the key, you get Authentication failed: ... and a hint to run unkey auth login.
unkey deploy doesn’t read the config file
unkey deploy only takes a key from --root-key or UNKEY_ROOT_KEY. It never reads ~/.unkey/config.toml, so unkey auth login doesn’t help it. In CI, set UNKEY_ROOT_KEY as a secret. Locally, export it in the shell you deploy from. See unkey deploy.
Point at a different API host
--api-url (or UNKEY_API_BASE_URL) sets the base URL for unkey api commands, and unkey deploy has --api-base-url. The default is https://api.unkey.com. You don’t normally need to change it.