Skip to content

Configuration

AgentGate is configured entirely through environment variables. This page documents all available options.

Environment Variables

Server

VariableTypeDefaultDescription
PORTnumber3000HTTP server port
HOSTstring0.0.0.0HTTP server host
NODE_ENVenumdevelopmentEnvironment: development, production, test

Database

AgentGate supports both SQLite (default) and PostgreSQL.

VariableTypeDefaultDescription
DB_DIALECTenumsqliteDatabase dialect: sqlite or postgres
DATABASE_URLstring./data/agentgate.dbDatabase connection URL

SQLite (Default)

SQLite requires no additional setup:

bash
# File-based (default)
DATABASE_URL=./data/agentgate.db

# In-memory (for testing)
DATABASE_URL=:memory:

PostgreSQL

For production deployments:

bash
DB_DIALECT=postgres
DATABASE_URL=postgresql://user:password@localhost:5432/agentgate

With SSL:

bash
DATABASE_URL=postgresql://user:pass@db.example.com:5432/agentgate?sslmode=require

Security

VariableTypeDefaultDescription
ADMIN_API_KEYstring-Admin API key (min 16 chars, required in production)
JWT_SECRETstring-JWT signing secret (min 32 chars, recommended in production)
CORS_ALLOWED_ORIGINSstring*Allowed CORS origins (comma-separated)

Production Requirements

In production (NODE_ENV=production), ADMIN_API_KEY is required and must be at least 16 characters.

Rate Limiting

VariableTypeDefaultDescription
RATE_LIMIT_ENABLEDbooleantrueEnable rate limiting
RATE_LIMIT_RPMnumber60Requests per minute per API key

Request Handling

VariableTypeDefaultDescription
REQUEST_TIMEOUT_SECnumber3600Default request timeout (1 hour)
WEBHOOK_TIMEOUT_MSnumber5000Webhook delivery timeout
WEBHOOK_MAX_RETRIESnumber3Maximum webhook retry attempts

Logging

VariableTypeDefaultDescription
LOG_LEVELenuminfoLog level: debug, info, warn, error
LOG_FORMATenumprettyLog format: json, pretty

Integration Configuration

Slack

VariableTypeDescription
SLACK_BOT_TOKENstringSlack bot OAuth token (xoxb-...)
SLACK_SIGNING_SECRETstringSlack app signing secret
SLACK_DEFAULT_CHANNELstringDefault channel for notifications

See Slack Integration for setup details.

Discord

VariableTypeDescription
DISCORD_BOT_TOKENstringDiscord bot token
DISCORD_DEFAULT_CHANNELstringDefault channel ID

See Discord Integration for setup details.

Email (SMTP)

VariableTypeDescription
SMTP_HOSTstringSMTP server hostname
SMTP_PORTnumberSMTP server port
SMTP_USERstringSMTP username
SMTP_PASSstringSMTP password
SMTP_FROMstringSender email address

See Email Integration for setup details.

Channel Routing

Route notifications to different channels based on action type or urgency.

bash
export CHANNEL_ROUTES='[
  {
    "channel": "slack",
    "target": "#general-alerts",
    "enabled": true
  },
  {
    "channel": "slack", 
    "target": "#critical-alerts",
    "urgencies": ["critical"],
    "enabled": true
  },
  {
    "channel": "email",
    "target": "security@company.com",
    "actions": ["transfer_funds", "delete_account"],
    "urgencies": ["high", "critical"],
    "enabled": true
  }
]'

Route Schema

typescript
interface ChannelRoute {
  channel: "slack" | "discord" | "email" | "webhook" | "sms"
  target: string           // Channel ID, email, or webhook URL
  actions?: string[]       // Filter by action types
  urgencies?: ("low" | "normal" | "high" | "critical")[]
  enabled?: boolean        // Default: true
}

Example .env File

bash
# Server
PORT=3000
HOST=0.0.0.0
NODE_ENV=production

# Database
DB_DIALECT=postgres
DATABASE_URL=postgresql://user:password@localhost:5432/agentgate

# Security
ADMIN_API_KEY=your-secure-admin-key-at-least-16-chars
JWT_SECRET=your-secure-jwt-secret-at-least-32-characters
CORS_ALLOWED_ORIGINS=https://app.example.com,https://admin.example.com

# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_RPM=100

# Timeouts
REQUEST_TIMEOUT_SEC=3600
WEBHOOK_TIMEOUT_MS=5000

# Slack
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_SIGNING_SECRET=your-signing-secret
SLACK_DEFAULT_CHANNEL=#agentgate-alerts

# Logging
LOG_LEVEL=info
LOG_FORMAT=json

Production Checklist

When running in production, ensure:

  • [ ] ADMIN_API_KEY is set (min 16 characters)
  • [ ] JWT_SECRET is set (min 32 characters)
  • [ ] CORS_ALLOWED_ORIGINS is restricted (not *)
  • [ ] DATABASE_URL points to a persistent location
  • [ ] LOG_FORMAT=json for structured logging
  • [ ] Rate limiting is enabled

The server logs warnings at startup if these aren't configured.

Database Migrations

bash
# Apply migrations (auto-detects dialect)
pnpm db:migrate

# Or specify dialect
pnpm db:migrate:sqlite
pnpm db:migrate:postgres

# Generate new migrations
pnpm db:generate

Released under the MIT License.