What is AgentSecrets?
The Zero-Knowledge Difference
How AgentSecrets Works
Installation
Quick Start
Migrating from .env Files
Migrating from Vault / AWS
Migrating from dotenv-vault
Production Checklist
Credential Exposure
What Zero-Knowledge Means
The Proxy Model
The Three-Layer Model
Environments
Agent Identity
Storage Modes
The No get() Principle
Secret-Level Policies
Cloud Overview & Architecture
The Dual-Engine Model
Cloud Resolver Data Plane
Workload & Agent Tokens
Egress Allowlists & Audit Streams
Cloud REST API Reference
Account (init / login)
Server & Self-Hosting (server)
Docs
Shell Autocompletion
Keychain Auth
Secrets
Environments
Credential Proxy
env Injection
Workspaces & Teams
Projects
Agent Identity
Audit & Governance
Integrations Overview
Claude Desktop
Cursor
OpenClaw
HTTP Proxy (Any)
LangChain (Soon)
CrewAI (Soon)
CI/CD Pipeline
SDK Overview
Python SDK
Python API Reference
Python SDK Manual Testing
JavaScript SDK (Soon)
Ecosystem Overview
Zero-Knowledge MCP Server
Server Overview
5-Layer Architecture
Self-Hosting Guide
Authentication & Keys
Workspaces & Teams
Projects & Scope
Environments
Secrets & Sync Protocol
Agent Identity Resolution
Telemetry & Metrics Engine
Audit Log Sync
API Endpoint Reference
Security Overview
Anti-Impersonation & Process Verification
Encryption Model
Zero-Knowledge Sync
Proxy Security Layers
Threat Model
OWASP Top 10 Mitigation
Security FAQ
Third-Party Audit
Reporting Vulnerabilities
Guides Overview
Building on the SDK
Stripe Integration
OpenAI Integration
Multi-Agent Setup
Onboarding Team
CI/CD Pipeline
Publishing ZK MCP
Rotating Credentials
Auditing Team Activity
Dev to Production
Kubernetes Deployment
Monorepo Setup
Production Proxy Hardening
vs .env Files
vs HashiCorp Vault
vs AWS Secrets Manager
vs dotenv-vault
vs Infisical
When Not to Use
Proxy Not Starting
Proxy Not Resolving
Domain Blocked
Sync Conflicts
MCP Not Connecting
Session Token Errors
Proxy Session Authorization
Keychain Storage & Backends
SSRF & Destination Rules
Installation Issues
Error Codes Reference
Frequently Asked Questions
v3.1.x
v3.0.0
v2.1.0
v2.0.0
v1.4.0
v1.3.x
v1.2.0
v1.1.x
v1.0.x
CLI ReferenceAgent Identity

Agent Identity CLI Reference

This guide provides the hands-on commands and code examples needed to implement, manage, and verify Agent Identity in your workspaces.

To understand the security threat models and conceptual foundations of agent identification, read the Agent Identity Concept Guide.


The Identity CLI Workflow

Governing agent access follows a simple pipeline: registering the identity, setting secret capability policies, and using the tokens to authenticate requests.

1. REGISTER (Identity & Token #1) agentsecrets agent register ┌──────────────┐ │ Registered │ │ Agent ID │ └──────┬───────┘ 2. POLICY SET (Grant Access) agentsecrets agent policy set 3. USE TOKEN (Proxy Auth) Export AS_AGENT_TOKEN=<token> 4. ISSUE ADDITIONAL TOKENS (Optional) agentsecrets agent token issue

1Register the Agent (Creates Identity & Token #1)

Registering creates a logical identity inside your workspace and automatically issues its first active token.

agentsecrets agent register my-billing-agent
  • Options:
    • --project, -p <project-name>: Scope the agent identity to a specific project. If omitted, the agent operates workspace-wide.

2Configure Secrets Capabilities (Set Policy)

By default, newly registered agents have zero access. You must explicitly configure their capability boundary to allow them to fetch specific credentials.

To allow access to specific secrets in a project:

agentsecrets agent policy set my-billing-agent --allow STRIPE_SECRET_KEY,PLAID_CLIENT_ID

To deny access to specific secrets (acting as a blacklist):

agentsecrets agent policy set my-billing-agent --deny AWS_ROOT_ACCESS_KEY
  • Options:
    • --allow <keys>: Comma-separated list of permitted secret keys.
    • --deny <keys>: Comma-separated list of prohibited secret keys (takes precedence).

3Issue Additional Tokens (Optional)

While registration generates your first token, you can issue additional tokens for the same agent profile (e.g. for key rotation, different hosting environments like staging/production, or separate developer machines):

agentsecrets agent token issue my-billing-agent --env production

This generates another secure token.

  • OS Keychain Storage: The CLI automatically stores the issued token in your local OS Keychain.
  • Key Reference: You can use <AGENTNAME>_TOKEN (e.g., MY-BILLING-AGENT_TOKEN) in your local developer scripts, and the proxy will resolve it directly from the keyring at runtime.

4List and Inspect

To view all registered agents and their scopes in the current workspace:

agentsecrets agent list

To view all active tokens issued for a specific agent:

agentsecrets agent token list my-billing-agent

Agent Scoping Boundaries

Agents are governed by three hierarchical security boundaries: Workspace, Project, and Environment.

1Workspace-Level Scope

When you register an agent with agentsecrets agent register <name>, it is bound by default to your active workspace. Workspace-scoped agents can access any allowed credentials across all projects in that workspace.

2Project-Level Scope

If an agent only performs tasks for a specific project, you should restrict its identity to that project by specifying the --project flag during registration:

agentsecrets agent register my-billing-agent --project "my-billing-project"

Once scoped to a project, the proxy will strictly block this agent if it attempts to request credentials or resolve variables bound to any other project, returning an agent_project_mismatch block.

3Environment-Level Scope

By default, an agent's tokens can only be used in the environment they were generated for. When registering an agent or issuing a token, you can bind it to a specific environment (e.g. development, staging, or production):

# Scope initial token during registration agentsecrets agent register my-billing-agent --env production # Scope a new token for an existing agent agentsecrets agent token issue my-billing-agent --env production

At runtime, the proxy matches the token's environment scope against the proxy's active running environment. If they mismatch, the proxy blocks resolution immediately with agent_environment_mismatch.

4Visualizing Scope in the CLI

To inspect agent scopes and active attributes:

  • Run agentsecrets agent list to see the SCOPE column (either workspace or the specific project name).
  • Run agentsecrets agent token list <agent-name> to see active token IDs, their labels, and expiry dates.

Code Integration

Configure your agent code or environment to present its identity to the credential proxy.

Level 1: Declared Identity (Attribution only)

Self-report the agent's name. Use this during local multi-agent debugging.

Via HTTP Header

Add the X-AS-Agent-ID header to outbound requests:

GET https://api.stripe.com/v1/charges X-AS-Agent-ID: my-billing-agent

Via Python SDK

from agentsecrets import AgentSecrets with AgentSecrets(agent_id="my-billing-agent") as client: response = client.call( "https://api.stripe.com/v1/charges", bearer="STRIPE_KEY" )

Level 2: Issued Identity (Cryptographic verification)

Present the cryptographically signed token. Use this for production and sensitive staging systems.

Via Environment Variable (Recommended)

Set the AS_AGENT_TOKEN environment variable in the process space where the agent is running:

export AS_AGENT_TOKEN="agt_3f8a9..."

The proxy automatically detects this environment variable and uses it to authorize credential requests.

Via HTTP Header

Pass the token in the X-AS-Agent-Token header:

GET https://api.stripe.com/v1/charges X-AS-Agent-Token: agt_3f8a9...

Via Python SDK (Keychain Token Reference)

from agentsecrets import AgentSecrets with AgentSecrets(agent_token="MY_BILLING_AGENT_TOKEN") as client: response = client.call( "https://api.stripe.com/v1/charges", bearer="STRIPE_KEY" )

Revoking an Agent or Token

If an agent is compromised or decommissioned, you can revoke its access instantly without rotating the target credentials.

Revoking a Single Token

To invalidate a specific token without deleting the agent identity:

agentsecrets agent token revoke agt_3f8a9...

Deleting the Agent

Deleting an agent automatically invalidates all tokens associated with it and wipes its capability policy:

agentsecrets agent delete my-billing-agent

All future requests presenting revoked tokens will immediately fail with a 401 Unauthorized status at the proxy boundary, and the attempt will be logged in the forensic audit trail.

Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.