Environment Variables

This reference lists all environment variables for the 2Signal web app, workers, and Python SDK.

Web App & Workers

These variables are required for the Next.js application and background workers.

Database

VariableRequiredDescription
DATABASE_URLYesPostgreSQL connection string. Format: postgresql://user:pass@host:5432/dbname

Redis

VariableRequiredDescription
REDIS_URLYesRedis connection string. Format: redis://host:6379. Used for BullMQ job queues and rate limiting.

Supabase Auth

VariableRequiredDescription
NEXT_PUBLIC_SUPABASE_URLYesYour Supabase project URL. Format: https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEYYesSupabase anonymous key for client-side auth. Starts with eyJ.

S3 Object Storage

VariableRequiredDescription
AWS_ACCESS_KEY_IDYesAWS access key (or S3-compatible provider)
AWS_SECRET_ACCESS_KEYYesAWS secret key
S3_BUCKET_NAMEYesBucket name for raw event storage (e.g., twosignal-traces)
AWS_REGIONNoAWS region. Defaults to us-east-1
S3_ENDPOINTNoCustom S3 endpoint for MinIO, Cloudflare R2, etc.

Stripe Billing

VariableRequiredDescription
STRIPE_SECRET_KEYYesStripe secret API key. Starts with sk_.
STRIPE_WEBHOOK_SECRETYesWebhook signing secret. Starts with whsec_.
STRIPE_PRO_PRICE_IDYesStripe Price ID for the Pro plan. Starts with price_.
STRIPE_TEAM_PRICE_IDYesStripe Price ID for the Team plan. Starts with price_.

LLM (for Evaluations)

VariableRequiredDescription
OPENAI_API_KEYConditionalRequired only if using the LLM Judge evaluator. Starts with sk-. Can also be set per-evaluator in the config.

Email Notifications

VariableRequiredDescription
RESEND_API_KEYYesResend API key for sending usage alert emails. Starts with re_.

Application

VariableRequiredDescription
NODE_ENVNodevelopment or production. Affects logging format (pretty vs JSON).
PORTNoPort for the Next.js server. Defaults to 3000.

Python SDK

These variables configure the Python SDK. They can also be passed as constructor arguments.

VariableRequiredDescription
TWOSIGNAL_API_KEYYesAPI key for authenticating with the 2Signal API. Format: 2s_live_...
TWOSIGNAL_BASE_URLNoBase URL of the 2signal API. Defaults to https://api.2signal.dev. Set to http://localhost:3000 for local development.
TWOSIGNAL_ENABLEDNoSet to false to disable tracing. Useful for unit tests.

Example .env File

# Database
DATABASE_URL=postgresql://twosignal:password@localhost:5432/twosignal

# Redis
REDIS_URL=redis://localhost:6379

# Supabase Auth
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

# S3
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
S3_BUCKET_NAME=twosignal-traces

# Stripe
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PRO_PRICE_ID=price_...
STRIPE_TEAM_PRICE_ID=price_...

# Email
RESEND_API_KEY=re_...

# LLM (optional)
OPENAI_API_KEY=sk-...

Security: Never commit .env files to source control. Add .env to your .gitignore.

Have questions? Join our community!

Connect with other developers and the 2Signal team.

Join Discord