Skip to content
API Reference

Commands

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.

Sign into your Keycard account by opening an OIDC browser sign-in flow and storing tokens securely in your system keyring.

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

Check your current identity:

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

Sign out and remove stored tokens:

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

Authorize access to one or more resources, also initiate sign-in if you don’t have an active session.

Terminal window
keycard auth resource <uri> [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>

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

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>

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

Terminal window
keycard credential info

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

[zone]
id = "your-zone-id"
[[credentials.default]]
env_var = "GH_TOKEN"
resource = "https://api.github.com"
CommandDescription
keycard runRun a command 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 infoList credential entries from keycard.toml
keycard versionShow version info

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

Terminal window
keycard agent hook --claude

Print the active Cedar policy:

Terminal window
keycard agent 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>

Use --credentials to hydrate a named credential set other than default:

Terminal window
keycard agent exec --credentials <set-name> --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.

Terminal window
keycard agent api <endpoint>

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

Terminal window
keycard agent api <endpoint> -X POST