Skip to main content

Environment Variables

Complete reference of every environment variable used by AgentHiFive. Variables are grouped by category. Required means the application will not start or the feature will not work without it; Optional means a sensible default is used when the variable is absent.


Core Configuration

VariableRequiredDefaultDescriptionExample
DATABASE_URLRequiredPostgreSQL connection string.postgresql://agenthifive:secret@localhost:5432/agenthifive
API_PORTOptional8080Port the Fastify API server listens on.4000
API_BIND_HOSTOptional0.0.0.0Host/IP address to bind the API server. Set to 127.0.0.1 on a VPS without a reverse proxy.127.0.0.1
WEB_URLOptionalhttp://localhost:3000Origin of the web app. Used for CORS, JWT issuer, email links, and OAuth callback URLs.https://app.example.com
API_INTERNAL_URLOptionalInternal API URL (container-to-container). Added to the agent token audience allowlist so agents on a private network pass audience checks.http://api:4000
DOCS_INTERNAL_URLOptionalInternal URL of the Docusaurus docs site (used for reverse proxy routing).http://localhost:3001
NODE_ENVOptionalNode.js environment. When set to production, enables structured JSON logging, tighter rate limits, and secure cookies.production
LOG_LEVELOptionalinfoPino log level for the API server (fatal, error, warn, info, debug, trace).debug

URLs (Build-Time / Frontend)

These NEXT_PUBLIC_* variables are baked into the Next.js static build at compile time.

VariableRequiredDefaultDescriptionExample
NEXT_PUBLIC_WEB_URLRequiredPublic URL of the web app, used in client-side links and redirects.https://app.example.com
NEXT_PUBLIC_API_URLRequiredAPI base URL as seen by the browser (typically through a reverse proxy).https://app.example.com/v1
NEXT_PUBLIC_DOCS_URLOptional/docsDocumentation URL. In production this can be a separate subdomain.https://docs.example.com

Authentication

VariableRequiredDefaultDescriptionExample
BETTER_AUTH_SECRETRequiredSecret used by Better Auth for session signing. Generate with node -e "console.log(require('crypto').randomBytes(32).toString('hex'))".a]3f9... (64 hex chars)
JWT_PRIVATE_KEYOptionalAuto-generated ephemeral keyPEM-encoded PKCS#8 private key for JWT signing. Required in production for stable JWKS across restarts. Can be base64-encoded.-----BEGIN PRIVATE KEY-----\nMIIE...
JWT_KIDOptionalRandom UUIDKey ID published in the JWKS endpoint. Set explicitly for key rotation.my-key-2025
JWT_SIGNING_ALGOptionalRS256JWT signing algorithm (RS256 or ES256).ES256
WEB_JWKS_URLRequiredURL of the JWKS endpoint used by the API to verify JWTs. In Docker Compose this points to the internal API container.http://localhost:4000/.well-known/jwks.json

Encryption

VariableRequiredDefaultDescriptionExample
ENCRYPTION_KEYRequired (env mode)AES-256-GCM data encryption key (64 hex characters = 32 bytes). Generate with node -e "console.log(require('crypto').randomBytes(32).toString('hex'))".0a1b2c... (64 hex chars)
ENCRYPTION_KEY_MODEOptionalenvEncryption key provider. env reads from ENCRYPTION_KEY; azure-kv unwraps a DEK from Azure Key Vault at startup.azure-kv
AZURE_KEY_VAULT_URIRequired (azure-kv mode)Azure Key Vault URI for DEK unwrapping.https://my-vault.vault.azure.net
AZURE_KV_KEK_NAMEOptionaldata-encryption-kekName of the Key Encryption Key in Azure Key Vault.data-encryption-kek
AZURE_KV_WRAPPED_DEK_SECRETOptionalWRAPPED-DATA-KEYName of the Key Vault secret containing the wrapped DEK.WRAPPED-DATA-KEY
AZURE_MANAGED_IDENTITY_CLIENT_IDOptionalClient ID of the Azure Managed Identity used to authenticate to Key Vault. When omitted, the default credential chain is used.12345678-abcd-...

OAuth Providers (Social Login)

These configure social sign-in via Better Auth. The AUTH_* prefixed variants take precedence; the unprefixed variants (GOOGLE_CLIENT_ID, etc.) are used as fallbacks and also serve as connection credentials for the OAuth connector factory.

VariableRequiredDefaultDescriptionExample
AUTH_GOOGLE_CLIENT_IDOptionalGoogle OAuth client ID for social login. Falls back to GOOGLE_CLIENT_ID.123...apps.googleusercontent.com
AUTH_GOOGLE_CLIENT_SECRETOptionalGoogle OAuth client secret for social login. Falls back to GOOGLE_CLIENT_SECRET.GOCSPX-...
AUTH_MICROSOFT_CLIENT_IDOptionalMicrosoft Entra ID client ID for social login. Falls back to MICROSOFT_CLIENT_ID.12345678-...
AUTH_MICROSOFT_CLIENT_SECRETOptionalMicrosoft Entra ID client secret for social login. Falls back to MICROSOFT_CLIENT_SECRET.abc123~...
AUTH_MICROSOFT_TENANT_IDOptionalcommonMicrosoft tenant ID. Falls back to MICROSOFT_TENANT_ID.common
APPLE_CLIENT_IDOptionalApple Sign In service ID.com.example.signin
APPLE_CLIENT_SECRETOptionalApple Sign In client secret (JWT).eyJ...
FACEBOOK_CLIENT_IDOptionalFacebook Login app ID.123456789012345
FACEBOOK_CLIENT_SECRETOptionalFacebook Login app secret.abc123...

Connection Credentials (OAuth Connector Factory)

Used by the server-side OAuth connector factory for token refresh and provider API calls. These are the unprefixed variants; they double as social login fallbacks when AUTH_* variants are not set.

VariableRequiredDefaultDescriptionExample
GOOGLE_CLIENT_IDOptionalGoogle OAuth client ID for connections.123...apps.googleusercontent.com
GOOGLE_CLIENT_SECRETOptionalGoogle OAuth client secret for connections.GOCSPX-...
MICROSOFT_CLIENT_IDOptionalMicrosoft OAuth client ID for connections.12345678-...
MICROSOFT_CLIENT_SECRETOptionalMicrosoft OAuth client secret for connections.abc123~...
MICROSOFT_TENANT_IDOptionalcommonMicrosoft tenant ID for connections.common

Agent Configuration

VariableRequiredDefaultDescriptionExample
AGENT_TOKEN_TTL_SECONDSOptional7200Lifetime of agent access tokens in seconds (2 hours).900
AGENT_TOKEN_AUDIENCEOptionalAPI base URL (http://localhost:4000)Expected aud claim in agent client assertions. Localhost and WEB_URL variants are auto-added. Falls back to API_BASE_URL.https://api.example.com
BOOTSTRAP_SECRET_TTL_HOURSOptional1Lifetime of bootstrap secrets in hours before they expire.24

Email

VariableRequiredDefaultDescriptionExample
EMAIL_PROVIDEROptionalnoopEmail transport: smtp (any SMTP relay), acs (Azure Communication Services), ethereal (dev preview URLs), noop (log only).smtp
SMTP_HOSTRequired (smtp)SMTP server hostname.smtp.sendgrid.net
SMTP_PORTOptional587SMTP server port.465
SMTP_USERNAMERequired (smtp)SMTP authentication username.apikey
SMTP_PASSWORDRequired (smtp)SMTP authentication password.SG.xxxxx
EMAIL_FROMOptionalnoreply@agenthifive.comSender address for outbound emails. For ACS, defaults to DoNotReply@agenthifive.com.noreply@example.com
ACS_CONNECTION_STRINGRequired (acs)Azure Communication Services connection string for the ACS email provider.endpoint=https://...;accesskey=...

External Services

VariableRequiredDefaultDescriptionExample
SENTRY_DSNOptionalSentry Data Source Name for error monitoring. When unset, Sentry is disabled.https://abc@o123.ingest.sentry.io/456
SENTRY_ENVIRONMENTOptionaldevelopmentSentry environment tag.production
SENTRY_TRACES_SAMPLE_RATEOptional1.0 (dev)Fraction of transactions sent to Sentry for performance tracing (0.0 to 1.0).0.2
SENTRY_SERVER_NAMEOptionalServer name tag reported to Sentry.api-prod-01
TELEGRAM_BOT_TOKENOptionalTelegram Bot API token for the Telegram connection provider and notification channel.123456:ABC-DEF...
EXPO_ACCESS_TOKENOptionalExpo push notification access token for mobile push notifications.ExponentPushToken[...]

Security

VariableRequiredDefaultDescriptionExample
BASIC_AUTH_PASSWORDOptionalWhen set, enables a Basic Auth gate on all non-health, non-auth endpoints. Username is always ah5. Useful for staging/preview environments.my-staging-password
AZURE_FRONT_DOOR_IDOptionalAzure Front Door profile resource_guid. When set, requests without a matching X-Azure-FDID header are rejected with 403.12345678-abcd-...
TURNSTILE_SECRET_KEYOptionalCloudflare Turnstile secret key for bot protection on registration. When unset, Turnstile verification is skipped.0x4AAA...
SSRF_ALLOWLIST_HOSTSOptionalComma-separated hostnames that bypass private-IP SSRF checks. Used for integration testing with Docker internal hostnames. Never set in production.echo,mock-provider

Enterprise

VariableRequiredDefaultDescriptionExample
ADMIN_EMAILOptionalEmail address for the auto-seeded superadmin user (enterprise overlay). Both ADMIN_EMAIL and ADMIN_PASSWORD must be set to seed.admin@example.com
ADMIN_PASSWORDOptionalPassword for the auto-seeded superadmin user (enterprise overlay).StrongP@ss!

Frontend Feature Flags (NEXT_PUBLIC_*)

These are build-time flags that control UI feature visibility. They are automatically derived from OAuth provider variables in next.config.mjs but can be set explicitly to override.

VariableRequiredDefaultDescriptionExample
NEXT_PUBLIC_SOCIAL_GOOGLEOptionalDerived from AUTH_GOOGLE_CLIENT_ID or GOOGLE_CLIENT_IDShow Google sign-in button when truthy.1
NEXT_PUBLIC_SOCIAL_MICROSOFTOptionalDerived from AUTH_MICROSOFT_CLIENT_ID or MICROSOFT_CLIENT_IDShow Microsoft sign-in button when truthy.1
NEXT_PUBLIC_SOCIAL_APPLEOptionalDerived from APPLE_CLIENT_IDShow Apple sign-in button when truthy.1
NEXT_PUBLIC_SOCIAL_FACEBOOKOptionalDerived from FACEBOOK_CLIENT_IDShow Facebook sign-in button when truthy.1
NEXT_PUBLIC_TURNSTILE_SITE_KEYOptionalCloudflare Turnstile site key for the registration page captcha widget.0x4BBB...
NEXT_PUBLIC_BUILD_NUMBEROptionalBuild number displayed on the Settings page. Typically set by CI.142
NEXT_PUBLIC_BUILD_DATEOptionalBuild date displayed on the Settings page. Typically set by CI.2026-04-04

Build / CI Metadata

These are typically injected by the CI/CD pipeline and exposed via GET /v1/version.

VariableRequiredDefaultDescriptionExample
BUILD_NUMBEROptionaldevBuild number returned by the version endpoint.142
BUILD_DATEOptionalunknownBuild date returned by the version endpoint.2026-04-04T12:00:00Z
GIT_SHAOptionalunknownGit commit SHA returned by the version endpoint and reported to Sentry as the release.a1b2c3d

Production Docker Compose

These variables are used by the production Docker Compose file and Nginx configuration, not by the application directly.

VariableRequiredDefaultDescriptionExample
NGINX_HOSTRequiredProduction domain used for TLS certificate generation and Nginx server_name.app.example.com
POSTGRES_USERRequiredPostgreSQL container user. Must match the user in DATABASE_URL.agenthifive
POSTGRES_PASSWORDRequiredPostgreSQL container password. Must match the password in DATABASE_URL.StrongP@ss!
POSTGRES_DBRequiredPostgreSQL container database name. Must match the database in DATABASE_URL.agenthifive