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 ReferenceCryptographic Tokens

Issuing Cryptographic Tokens

Issued Identity is the highest tier of agent identity in AgentSecrets. It is powered by cryptographically signed, high-entropy tokens that uniquely identify an agent instance to the Credential Proxy.

By using cryptographic tokens, you ensure that every secret resolution is fully authenticated, audited, and individually revocable.


Registering an Agent

Before you can issue tokens for a specific cryptographic agent identity, the identity must be registered in your workspace. You perform this registration using the agent register command.

1Run the register command

Open your terminal and register a new agent identity:

agentsecrets agent register "billing-processor"

2Capture the Token & Keychain Storage

The register command will output the newly created agent's metadata and its first cryptographic token:

Agent registered Name billing-processor Scope workspace Token tVwXyZ_4kR9mNpQ9aBcDeFgHiJkLmNoPqRs Store this token securely. It will not be shown again. To use it: export AS_AGENT_TOKEN=tVwXyZ_4kR9mNpQ9aBcDeFgHiJkLmNoPqRs

The server only stores a cryptographic SHA-256 hash of this token for validation; it cannot be recovered if lost.

OS Keychain Prompt

After generating the token, the CLI will ask interactively:

Would you like to store this agent token in your local OS Keychain? (y/N)
  • y (Yes): Automatically stores the token in your native OS Keychain. This allows you to reference it in your local developer configurations using the <AGENTNAME>_TOKEN format (e.g. BILLING-PROCESSOR_TOKEN), which the credential proxy resolves transparently.
  • N (No): Skips keychain integration; you must manually manage the token via environment variables.

CLI Flags

  • --project, -p <project>: Scope the agent identity to a specific project.
  • --label, -l <label>: Label description for the initial token.
  • --expires, -e <duration>: Expiry duration for the token (e.g. 30d, 90d, 1y).
  • --env <name>: Restrict the token to a specific environment (e.g. development, staging, production).
  • --save-token: Auto-save the token to the OS Keychain without prompting (useful for scripts and automated setups).

Issuing Additional Tokens

If you need to generate additional tokens for an already registered agent (for example, to deploy a second instance, separate environment containers, or perform key rotation), use the agent token issue command:

agentsecrets agent token issue "billing-processor"

This generates another active token bound to the same billing-processor identity profile.

3Store the token securely

Save the token in your production environment variables (AS_AGENT_TOKEN) or a secure secret manager (e.g. AWS Secrets Manager or Kubernetes Secrets) to inject into your running agent container.

Similar to the registration flow, the CLI will prompt you to save the token to the local OS Keychain, or you can bypass it with the --save-token flag.

CLI Flags

  • --label, -l <label>: Label description for this token.
  • --expires, -e <duration>: Expiry duration for the token (e.g. 30d, 90d).
  • --env <name>: Restrict the token to a specific environment.
  • --save-token: Auto-save the token to the OS Keychain without prompting.

Token ID format and structure

An AgentSecrets token utilizes two components: a private raw token used for authentication, and a public Token ID used for monitoring and revocation.

Raw Token (Secret)

The raw token is a high-entropy, 32-byte URL-safe base64 string generated using secure random bytes. It contains no prefix.

Token ID (Public)

Every issued token is assigned a public database identifier (Token ID) that starts with an agent token prefix:

$$\text{agt_} + \text{workspace_short} + \text{_} + \text{random_payload}$$

  • agt_: The prefix indicating this is an Agent Token ID.
  • ws01hxyz_: A short identifier (first 8 characters) of the workspace ID. This allows administrators and audit trails to easily trace which workspace the token belongs to without decoding the token itself.
  • random_payload: A random base62-encoded string generated for primary key uniqueness.

When the proxy receives a raw agent token:

  1. Cache Verification: It checks its local memory cache (TokenCache) to see if the token has been validated recently (cache TTL defaults to 5 minutes) to avoid network overhead.
  2. Hash Match: If not cached, the proxy sends the token to the cloud backend's verification endpoint. The backend hashes the raw token with SHA-256 and compares it against the stored token_hash in the database.
  3. Status Check: It ensures the token's matching Token ID is active, not expired, and has not been revoked.

Authenticating requests with the token

Once you have issued a token, you can pass it to authorize API requests. Choose the method that fits your architecture:

To authenticate client calls in the Python SDK, initialize the client by passing the token to the agent_token parameter:

from agentsecrets import AgentSecrets # Initialize with the issued agent token client = AgentSecrets( project="payments-service", agent_token="tVwXyZ_4kR9mNpQ9aBcDeFgHiJkLmNoPqRs" # Pass the raw agent token ) # Outbound requests will be cryptographically attributed to "billing-processor" response = client.call( url="https://api.stripe.com/v1/balance", bearer="STRIPE_KEY" )

If the token is invalid, expired, or has been revoked, the proxy will immediately terminate the call, returning a 401 Unauthorized status:

{ "detail": "Invalid or revoked Agent Token", "code": "agent_unauthorized" }

This failed attempt is recorded in the audit log to alert administrators of potential unauthorized access attempts.

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