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
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | Yes | PostgreSQL connection string. Format: postgresql://user:pass@host:5432/dbname |
Redis
| Variable | Required | Description |
|---|---|---|
REDIS_URL | Yes | Redis connection string. Format: redis://host:6379. Used for BullMQ job queues and rate limiting. |
Supabase Auth
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL | Yes | Your Supabase project URL. Format: https://your-project.supabase.co |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Yes | Supabase anonymous key for client-side auth. Starts with eyJ. |
S3 Object Storage
| Variable | Required | Description |
|---|---|---|
AWS_ACCESS_KEY_ID | Yes | AWS access key (or S3-compatible provider) |
AWS_SECRET_ACCESS_KEY | Yes | AWS secret key |
S3_BUCKET_NAME | Yes | Bucket name for raw event storage (e.g., twosignal-traces) |
AWS_REGION | No | AWS region. Defaults to us-east-1 |
S3_ENDPOINT | No | Custom S3 endpoint for MinIO, Cloudflare R2, etc. |
Stripe Billing
| Variable | Required | Description |
|---|---|---|
STRIPE_SECRET_KEY | Yes | Stripe secret API key. Starts with sk_. |
STRIPE_WEBHOOK_SECRET | Yes | Webhook signing secret. Starts with whsec_. |
STRIPE_PRO_PRICE_ID | Yes | Stripe Price ID for the Pro plan. Starts with price_. |
STRIPE_TEAM_PRICE_ID | Yes | Stripe Price ID for the Team plan. Starts with price_. |
LLM (for Evaluations)
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY | Conditional | Required only if using the LLM Judge evaluator. Starts with sk-. Can also be set per-evaluator in the config. |
Email Notifications
| Variable | Required | Description |
|---|---|---|
RESEND_API_KEY | Yes | Resend API key for sending usage alert emails. Starts with re_. |
Application
| Variable | Required | Description |
|---|---|---|
NODE_ENV | No | development or production. Affects logging format (pretty vs JSON). |
PORT | No | Port for the Next.js server. Defaults to 3000. |
Python SDK
These variables configure the Python SDK. They can also be passed as constructor arguments.
| Variable | Required | Description |
|---|---|---|
TWOSIGNAL_API_KEY | Yes | API key for authenticating with the 2Signal API. Format: 2s_live_... |
TWOSIGNAL_BASE_URL | No | Base URL of the 2signal API. Defaults to https://api.2signal.dev. Set to http://localhost:3000 for local development. |
TWOSIGNAL_ENABLED | No | Set 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.