Skip to content
API Reference
Reference
CLI

CLI

Install, authenticate, manage credentials, authorize resources, and run commands in secure sessions with Keycard.

The keycard CLI handles authentication, credential management, resource authorization, and secure agent sessions.

Terminal window
brew install keycardai/tap/keycard

Verify the installation:

Terminal window
keycard version

Install the Keycard plugin for Claude Code:

Terminal window
keycard plugin install

The plugin includes a set of Skills Claude uses to manage credentials, query policy, and update keycard.toml.

Pull down the latest version of the plugin at any time:

Terminal window
keycard plugin update

The Keycard CLI supports macOS and Linux on both amd64 and arm64 architectures.

Update to the latest version with Homebrew:

Terminal window
brew upgrade keycard

Sign into your Keycard account. The CLI opens an OIDC browser sign-in flow and stores the resulting tokens in your system keyring.

Terminal window
keycard auth signin --zone <zone-id> --org <org-id>
FlagDescription
-z, --zoneZone ID. Falls back to ZONE or zone.id in keycard.toml
-o, --orgOrganization ID

Check your current identity:

Terminal window
keycard auth whoami --zone <zone-id>

Sign out and remove stored tokens. Accepts -z/--zone and -o/--org:

Terminal window
keycard auth signout --zone <zone-id>

Authorize access to one or more Resources. The command also initiates sign-in if you don’t have an active session.

Terminal window
keycard auth resource <uri>... --zone <zone-id>

Use this when a tool reports that resource access requires authorization.

Run a command inside a Keycard secure session to provision just-in-time credentials and enforce policy on tool use.

Terminal window
keycard run --zone <zone-id> -- <command>
FlagDescription
-z, --zoneZone ID. Falls back to ZONE or zone.id in keycard.toml
--itl-promptIn-the-loop prompter backend: osascript, browser, or native. Also settable via ITL_PROMPT

Credentials are sourced from [[credentials.default]] entries in keycard.toml. See Configuration for details.

To run Claude Code inside a secure session, use the dedicated subcommand:

Terminal window
keycard run claude --zone <zone-id>

The policy enforced on tool use comes from your local policy file. Platform-Managed Policy (coming soon) distributes and enforces that policy centrally from your Zone instead.

Inside a secure session, the following environment variables are set automatically:

  • KEYCARD_RUN=1: indicates the process is running inside a Keycard session.
  • KEYCARD_RUN_SESSION_ID: the unique session identifier.

Get an access credential for a Resource URI:

Terminal window
keycard credential read <uri> --zone <zone-id>

The URI must be present in the default credential set. Configure it in keycard.toml first.

List all credential entries configured in keycard.toml that would be hydrated by keycard run:

Terminal window
keycard credential info

Add a gateway credential entry, or sync credential configuration down from your Zone:

Terminal window
keycard credential add
keycard credential sync

The CLI loads configuration from keycard.toml in the current directory. Override the path with --config or CLI_CONFIG.

[zone]
id = "<zone-id>"
[[credentials.default]]
env_var = "GH_TOKEN"
resource = "https://api.github.com"
FlagDescription
--configConfiguration file path. Defaults to keycard.toml
-h, --helpShow help for a command

The Zone ID is resolved from --zone, then the ZONE environment variable, then zone.id in keycard.toml. Commands that need a Zone fail with an explicit error if none of the three is set.

CommandDescription
keycard runRun a command in a Keycard secure session
keycard run claudeRun Claude Code in a Keycard secure session
keycard auth signinAuthenticate with your account
keycard auth signoutRemove local authentication tokens
keycard auth whoamiIdentify the current account
keycard auth resourceAuthorize access to Resources
keycard credential readRead a credential for a URI
keycard credential infoShow configured credential identifiers
keycard credential addAdd a gateway credential entry
keycard credential syncSync credential configuration from your Zone
keycard plugin installInstall the Keycard plugin for Claude Code
keycard plugin updateUpdate the Keycard plugin for Claude Code
keycard versionShow version info. Accepts --json
CommandDescription
keycard agent hookProcess agent hooks
keycard agent policyPrint the active Cedar policy
keycard agent execRun a command with credentials injected
keycard agent apiMake an authenticated Management API request

Process hook events from AI agents (Claude Code, Cursor, and others).

Terminal window
keycard agent hook <agent>

Print the Cedar policy currently in effect, including its @description, @credentials, and @itl annotations:

Terminal window
keycard agent policy

When policy is managed on the platform, this prints the version resolved for the session. See Platform-Managed Policy.

Run a command with credentials hydrated from [[credentials.default]] entries in keycard.toml. Unlike keycard run, this fails immediately if any credential requires interactive authentication. Safe for use in non-interactive agent subprocesses.

Terminal window
keycard agent exec --zone <zone-id> -- <command>

Inside an agent exec subprocess, KEYCARD_AGENT_EXEC=1 is set automatically.

Make an authenticated HTTP request to the Keycard Management API and print the response body to stdout.

FlagDescription
-X, --methodHTTP method. Defaults to GET
-d, --dataJSON request body. Reads stdin if omitted
-o, --orgOrganization ID
-z, --zoneZone ID
Terminal window
keycard agent api <endpoint>

Use -X to override the HTTP method (default: GET):

Terminal window
keycard agent api <endpoint> -X POST

Use -d to pass a JSON request body (reads stdin if omitted):

Terminal window
keycard agent api <endpoint> -X POST -d '{"key":"value"}'

Use -o / --org to specify an organization ID:

Terminal window
keycard agent api <endpoint> --org <org-id>