Environment Variables Reference
Complete guide to all environment variables needed to configure WhatsApp Team Inbox.TL;DR - Essential Variables
Minimum required to run:| Variable | Get From | Example |
|---|---|---|
DATABASE_URL | PostgreSQL | postgresql://user:pass@host:5432/db |
WHATSAPP_ACCESS_TOKEN | Meta Business Suite | EAAxxxxx... |
WHATSAPP_PHONE_NUMBER_ID | WhatsApp API Setup | 123456789012345 |
WHATSAPP_BUSINESS_ACCOUNT_ID | WhatsApp Accounts | 123456789012345 |
WHATSAPP_WEBHOOK_VERIFY_TOKEN | You create | openssl rand -hex 16 |
JWT_SECRET | Generate | openssl rand -hex 32 |
JWT_REFRESH_SECRET | Generate | openssl rand -hex 32 |
ADMIN_EMAIL | Your email | admin@company.com |
ADMIN_PASSWORD | Strong password | Min 8 chars |
CORS_ORIGIN | Frontend URL | https://app.company.com |
NEXT_PUBLIC_API_BASE_URL | Backend URL | https://api.company.com |
NEXT_PUBLIC_WS_URL | WebSocket URL | wss://api.company.com |
Quick Setup
Copy the example file and customize:Required Variables
These variables must be set for the application to function:Database Configuration
PostgreSQL database usernameDefault:
postgresPostgreSQL database passwordSecurity: Use a strong password (16+ characters). Generate with:
PostgreSQL database nameDefault:
whatsapp_inboxFull PostgreSQL connection URLFormat:
postgresql://user:password@host:port/databaseExample: postgresql://postgres:secretpass@postgres:5432/whatsapp_inboxWhatsApp Business API
Get these credentials from Meta Business Suite. See WhatsApp Setup Guide for details.WhatsApp API endpoint URLDefault:
https://graph.facebook.com/v21.0Note: v21.0 is the recommended version for 2025Permanent access token from Meta Business SuiteHow to get:
- Go to Meta Business Suite
- Navigate to System Users
- Generate a permanent token with
whatsapp_business_messagingpermission
Your WhatsApp Business phone number IDFormat: 15-digit number (e.g.,
123456789012345)Location: Meta Business Suite → WhatsApp → API SetupYour WhatsApp Business Account IDFormat: 15-digit numberLocation: Meta Business Suite → Business Settings → WhatsApp Accounts
Webhook verification token (you create this)Generate with:Usage: Set the same token in Meta Business Suite webhook configuration
Security & Authentication
Secret key for signing JWT access tokensGenerate with:Security: Must be at least 32 characters, use cryptographically secure random generation
Secret key for signing JWT refresh tokensGenerate with:Note: Must be different from
JWT_SECRETAccess token expiration timeFormat: Use time units like
15m, 1h, 7d, 30dRecommended: 7d for web apps, 15m for high-security appsRefresh token expiration timeFormat: Use time units like
7d, 30d, 90dRecommended: 30dAdmin User
These credentials are used to create the initial admin account on first deployment.Admin user email addressExample:
admin@yourcompany.comNote: Change password immediately after first loginAdmin user initial passwordRequirements: Minimum 8 characters (16+ recommended)Security: Use a strong password generator
Admin user first name
Admin user last name
Application URLs
Frontend application URLDevelopment:
http://localhost:3000Production: https://your-domain.comAllowed CORS origins (comma-separated for multiple)Development:
http://localhost:3000Production: https://your-domain.com,https://app.your-domain.comSecurity: Never use * in productionBackend API URL (frontend environment variable)Development:
http://localhost:4000Production: https://api.your-domain.comWebSocket server URL (frontend environment variable)Development:
ws://localhost:4001Production: wss://api.your-domain.comOptional Variables
Port Configuration
Port for Next.js frontend server
Port for Express backend API
Port for WebSocket server
Port for PostgreSQL database
Port for Redis (if enabled)
Email Configuration (Resend)
Required for sending invitation emails, password resets, and notifications.Resend API key for sending emailsGet from: resend.com → Dashboard → API KeysExample:
re_123abc456def789ghi012jkl345mno678Note: Free tier includes 100 emails/day (3,000/month)Email address to send fromDevelopment: Use default
onboarding@resend.devProduction: Use verified domain noreply@yourdomain.comNote: Verify your domain in Resend dashboard for production useDisplay name for email senderExample:
WhatsApp Team Inbox or Your Company NamePush Notifications (Web Push)
Required for browser push notifications.VAPID public key for Web PushGenerate with:
VAPID private key for Web PushSecurity: Keep this secret, never expose to frontend
Contact URL or email for VAPIDFormat:
mailto:admin@your-domain.com or https://your-domain.comRedis (Optional)
Enables caching and session storage for improved performance.Redis connection URLDocker Compose:
redis://redis:6379External: redis://username:password@host:portRedis authentication password (if required)
Monitoring & Logging
Application environmentOptions:
development, production, testLogging levelOptions:
error, warn, info, debugProduction: Use info or warnDevelopment: Use debugEnvironment-Specific Configuration
Development (.env.development)
Production (.env.production)
Security Best Practices
Secret Generation
Generate strong secrets:Production Checklist
All required variables are set
Strong passwords (16+ characters)
Unique JWT secrets for access and refresh tokens
HTTPS URLs in production (https://, wss://)
Specific CORS origins (no wildcards)
Email service configured and verified
Push notification keys generated
Error tracking enabled (Sentry)
Log level appropriate for environment
Validation
Validate your environment configuration:Platform-Specific Setup
Railway
Environment variables are set in the Railway dashboard under Variables tab.Vercel
Set environment variables in Project Settings → Environment Variables. Note: Prefix client-side variables withNEXT_PUBLIC_
Docker Compose
Variables are loaded from.env file in project root automatically.
Kubernetes
Use ConfigMaps for non-sensitive data and Secrets for sensitive data:Troubleshooting
Variables not loading
- Check file name is exactly
.env - Verify no spaces around
=sign - Restart Docker containers:
docker-compose restart
Database connection failed
- Verify
DATABASE_URLformat is correct - Check database credentials match
- Ensure database is running:
docker-compose ps postgres
WhatsApp webhook not working
- Verify
WHATSAPP_WEBHOOK_VERIFY_TOKENmatches Meta configuration - Check
WHATSAPP_ACCESS_TOKENis valid - Ensure webhook URL is publicly accessible