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
Server & BackendSelf-Hosting Guide

Self-Hosting Guide

This guide covers deploying and operating agentsecrets-server on private infrastructure using Docker Compose or standalone Linux servers.


Architecture Overview

Internet / Private Network ┌──────────────────────────┐ │ Reverse Proxy / TLS │ (Caddy / Nginx / Traefik) │ Port 80 / 443 │ └────────────┬─────────────┘ ┌──────────────────────────┐ │ agentsecrets-server │ (Gunicorn + Uvicorn ASGI) │ Port 8000 │ └────────────┬─────────────┘ ┌─────────────┴─────────────┐ ▼ ▼ ┌────────────────────────┐ ┌────────────────────────┐ │ PostgreSQL 14+ │ │ Daily Metrics Cron │ │ Port 5432 │ │ calculate_metrics │ └────────────────────────┘ └────────────────────────┘

Configuration Reference

The server reads configuration from environment variables injected at runtime:

Required Keys

VariableDescriptionExample / Generator
SECRET_KEYDjango cryptographic signing keypython3 -c "import secrets; print(secrets.token_urlsafe(50))"
ENCRYPTION_KEYFernet 32-byte urlsafe base64 encryption keypython3 -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
SETTINGSDjango settings module pathcore.settings.prod (production) or core.settings.dev
ALLOWED_HOSTSComma-separated list of valid Host header domainsapi.agentsecrets.yourcompany.com,localhost
POSTGRES_DBDatabase nameagentsecrets
POSTGRES_USERDatabase userpostgres
POSTGRES_PASSWORDDatabase passwordStrong generated password
POSTGRES_HOSTDatabase hostnamedb (Docker) or localhost
POSTGRES_PORTDatabase port5432

Optional Keys

VariableDescriptionDefault
POSTGRES_SSLMODEPostgreSQL SSL connection mode (require, prefer, disable)prefer (cloud) / disable (docker)
CRON_SECRETBearer token for triggering metrics computation via HTTPNone
LOG_LEVELApplication logging verbosity (INFO, WARNING, ERROR)INFO

Deployment with Docker Compose

1Project Setup

git clone https://github.com/The-17/agentsecrets-server.git cd agentsecrets-server

2Configure Credentials via AgentSecrets

Use the CLI to manage and inject the server's own configuration without writing plaintext .env files to disk:

agentsecrets init agentsecrets project create agentsecrets-server agentsecrets secrets set SECRET_KEY="$(python3 -c 'import secrets; print(secrets.token_urlsafe(50))')" agentsecrets secrets set ENCRYPTION_KEY="$(python3 -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())')" agentsecrets secrets set SETTINGS="core.settings.prod" agentsecrets secrets set ALLOWED_HOSTS="api.agentsecrets.yourcompany.com,localhost" agentsecrets secrets set POSTGRES_DB="agentsecrets" agentsecrets secrets set POSTGRES_USER="postgres" agentsecrets secrets set POSTGRES_PASSWORD="your-strong-db-password" agentsecrets secrets set POSTGRES_HOST="db" agentsecrets secrets set POSTGRES_PORT="5432"

3Launch Containers

docker-compose up -d

The compose stack bootstraps PostgreSQL 16 Alpine, performs database health probes, applies pending database migrations via entrypoint.sh, and starts the ASGI server on port 8000.


Connecting the CLI and SDKs

You can point the AgentSecrets CLI to your self-hosted server globally, per-project, via command-line flags, or using environment variables.

Set the target server globally across your machine:

agentsecrets server set https://api.agentsecrets.yourcompany.com

Or set it exclusively for a specific repository / project:

agentsecrets server set http://localhost:8000 --project

Check connectivity and latency to your server:

agentsecrets server status

View the active server endpoint and configuration source:

agentsecrets server get

To revert back to the default AgentSecrets Server:

agentsecrets server reset

Option B: Initializing with --server

When onboarding or setting up a new project against your self-hosted instance:

agentsecrets init --server https://api.agentsecrets.yourcompany.com agentsecrets login --server https://api.agentsecrets.yourcompany.com

During interactive agentsecrets init, you can also choose "2. Self-Hosted Server (Custom URL)" when prompted.

Option C: Environment Variables

For automated CI/CD runners or containerized workloads, set the server endpoint via environment variable:

export AGENTSECRETS_SERVER_URL="https://api.agentsecrets.yourcompany.com" # (AGENTSECRETS_API_URL is also supported for backwards compatibility)

Verify Status

Verify that your CLI is communicating with the intended server:

agentsecrets status

The output displays the active server URL and whether it is the default server or a self-hosted instance.


Health Checks & Monitoring

The server exposes non-destructive diagnostic endpoints:

  • Probe URL: GET /api/status/health/ (or GET /api/status/)
  • Behavior: Returns 200 OK when database, cache, and encryption pipelines pass; returns 503 Service Unavailable on degraded subsystems.

Automated Telemetry Rollups

To compute historical DAU/WAU/MAU and platform analytics, trigger calculate_metrics daily:

Option A: System Cron

5 0 * * * cd /path/to/agentsecrets-server && agentsecrets env -- python manage.py calculate_metrics --days 7 >> /var/log/metrics.log 2>&1

Option B: Authenticated HTTP Trigger

curl -X POST https://api.agentsecrets.yourcompany.com/telemetry/internal/compute-metrics/ \ -H "Authorization: Bearer your-cron-secret"
Was this helpful?
Thanks for your feedback!
Your feedback helps us improve the platform.