Skip to content

Environment Variables

Core Variables#

These variables are required for every Cognest project.

VariableRequiredDescription
COGNEST_API_KEYYesYour Cognest API key (starts with cn_live_ or cn_test_)
COGNEST_ORG_IDYesOrganization identifier from your dashboard
COGNEST_ENVNoEnvironment name: development, staging, production (default: development)
COGNEST_LOG_LEVELNoLogging level: debug, info, warn, error (default: info)
COGNEST_PORTNoServer port (default: 3000)

Loading Order#

Cognest loads environment variables in the following priority (highest to lowest):

  1. Shell environment variables (already exported)
  2. .env.local — Local overrides (gitignored)
  3. .env.{environment} — Environment-specific (e.g., .env.production)
  4. .env — Default values
.env.local
# .env — Default values (committed to git)
COGNEST_ENV=development
COGNEST_PORT=3000
COGNEST_LOG_LEVEL=info

# .env.local — Secrets (gitignored)
COGNEST_API_KEY=cn_test_sk_a1b2c3d4e5f6...
COGNEST_ORG_ID=org_my-team

# Integration credentials
WHATSAPP_PHONE_ID=1234567890
WHATSAPP_ACCESS_TOKEN=EAAx...
SLACK_BOT_TOKEN=xoxb-...
SLACK_SIGNING_SECRET=abc123...

Integration Variables#

Each integration has its own set of required environment variables. Here are the most common ones:

Messaging Integrations#

VariableIntegrationDescription
WHATSAPP_PHONE_IDWhatsAppBusiness phone number ID from Meta dashboard
WHATSAPP_ACCESS_TOKENWhatsAppPermanent access token from Meta
WEBHOOK_VERIFY_TOKENWhatsAppCustom string for webhook verification
TELEGRAM_BOT_TOKENTelegramBot token from @BotFather
SLACK_BOT_TOKENSlackBot user OAuth token (xoxb-...)
SLACK_SIGNING_SECRETSlackRequest signing secret from Slack app settings
DISCORD_BOT_TOKENDiscordBot token from Discord developer portal
DISCORD_APPLICATION_IDDiscordApplication ID for slash commands

Google Integrations#

VariableIntegrationDescription
GMAIL_CLIENT_IDGmailOAuth 2.0 client ID from Google Cloud Console
GMAIL_CLIENT_SECRETGmailOAuth 2.0 client secret
GOOGLE_CALENDAR_CLIENT_IDGoogle CalendarOAuth 2.0 client ID
GOOGLE_CALENDAR_CLIENT_SECRETGoogle CalendarOAuth 2.0 client secret
GOOGLE_DRIVE_CLIENT_IDGoogle DriveOAuth 2.0 client ID
GOOGLE_DRIVE_CLIENT_SECRETGoogle DriveOAuth 2.0 client secret

Other Integrations#

VariableIntegrationDescription
NOTION_API_KEYNotionInternal integration token from Notion
GITHUB_TOKENGitHubPersonal access token or GitHub App token
TWITTER_API_KEYTwitter / XAPI key from Twitter developer portal
TWITTER_API_SECRETTwitter / XAPI secret key
TWITTER_ACCESS_TOKENTwitter / XUser access token
TWITTER_ACCESS_SECRETTwitter / XUser access token secret
LINKEDIN_CLIENT_IDLinkedInOAuth 2.0 client ID
LINKEDIN_CLIENT_SECRETLinkedInOAuth 2.0 client secret
STRIPE_SECRET_KEYStripeSecret key (starts with sk_live_ or sk_test_)
STRIPE_WEBHOOK_SECRETStripeWebhook endpoint signing secret

Production Secrets Management#

In production, we recommend using a secrets manager instead of .env files. Cognest supports native integration with popular secret stores:

cognest.config.yaml
# cognest.config.yaml
secrets:
  provider: aws-ssm          # aws-ssm | vault | gcp-secrets | azure-keyvault
  prefix: /cognest/prod/    # Key prefix in the secrets store
  cache_ttl: 300             # Cache secrets for 5 minutes

When using a secrets provider, environment variables referenced in your config (${VAR_NAME}) are first looked up in the secrets store, then fall back to process.env.