Skip to main content

CLI

Install and use the Unkey CLI to manage API keys, rate limits, permissions, and identities from your terminal. Supports all core operations.
3 min read

The Unkey CLI gives you direct access to the Unkey API from your terminal. Create and manage API keys, configure rate limits, set permissions, and query analytics, all without leaving the command line.

Warning

The CLI is early and provided on a best-effort basis. There are no breaking change guarantees for commands, flags, or output format. The underlying API is versioned and stable.

Installation#

Authentication#

Before using the CLI, authenticate with your root key:

This stores your key at ~/.unkey/config.toml. All subsequent commands use it automatically.

You can also pass a key per-command or via environment variable:

Usage#

All API operations live under the unkey api command, organized by resource:

Resources#

ResourceDescription
apisCreate, get, delete API namespaces and list their keys
keysCreate, verify, update, delete keys and manage their permissions and roles
identitiesCreate, get, update, delete identities for grouping keys
permissionsCreate, get, delete permissions and roles
ratelimitApply rate limits and manage overrides
analyticsQuery key verification data with SQL

Examples#

Create an API and issue a key:

Verify a key:

Set up rate limiting:

Query analytics:

Manage permissions:

Output#

By default, the CLI prints the request ID, followed by the response data:

For scripting, use --output=json to get the raw API response envelope (meta + data) as JSON on stdout:

Send a typed JSON body#

Every unkey api action accepts --body for sending a JSON string directly to the API. This is useful for AI agents and scripts that already produce an API request body:

Explicitly passing --body selects typed body mode. The CLI decodes the value into the endpoint's generated SDK request type, then the SDK serializes that typed request. Malformed JSON is rejected locally. An explicitly empty value, including --body='', selects body mode and is rejected as malformed JSON. Request schema and business validation remain the API's responsibility.

You cannot combine --body with request-building flags. Selecting body mode waives required request-building flag checks because the typed JSON supplies the request instead.

Operational flags continue to work in body mode. Your configured root key or --root-key is still used, while --api-url and --output keep their normal behavior.

Quote the JSON so your shell passes it as one argument. Single quotes are usually the clearest choice for inline JSON in Bash:

Global Flags#

Every command accepts these flags:

FlagDescription
--root-keyOverride the root key (also: UNKEY_ROOT_KEY env var)
--api-urlOverride the API base URL (default: https://api.unkey.com)
--configPath to config file (default: ~/.unkey/config.toml)
--outputOutput format. Use json for raw JSON
--bodySend this JSON string as the typed request body. You cannot combine it with request-building flags.

Help#

Every command has built-in help with descriptions, flag details, and examples: