Skip to content

Complete reference for all environment variables used in the TendSocial API.

Core Configuration

Server

bash
# Server port
PORT=4000

# Node environment
NODE_ENV=development  # or production, test

# API URL (for callbacks)
API_URL=https://api.tendsocial.com

Database

bash
# PostgreSQL connection string
DATABASE_URL=postgresql://user:password@localhost:5432/tendsocial

# Direct connection (for Prisma)
DIRECT_DATABASE_URL=postgresql://user:password@localhost:5432/tendsocial

Authentication

JWT

bash
# JWT secret for signing tokens
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production

# Token expiry
JWT_EXPIRES_IN=7d  # e.g., 1h, 7d, 30d

OAuth

bash
# Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=https://api.tendsocial.com/auth/google/callback

# LinkedIn OAuth
LINKEDIN_CLIENT_ID=your-linkedin-client-id
LINKEDIN_CLIENT_SECRET=your-linkedin-client-secret
LINKEDIN_REDIRECT_URI=https://api.tendsocial.com/auth/linkedin/callback

# Facebook OAuth
FACEBOOK_APP_ID=your-facebook-app-id
FACEBOOK_APP_SECRET=your-facebook-app-secret
FACEBOOK_REDIRECT_URI=https://api.tendsocial.com/auth/facebook/callback

# Twitter OAuth
TWITTER_API_KEY=your-twitter-api-key
TWITTER_API_SECRET=your-twitter-api-secret
TWITTER_REDIRECT_URI=https://api.tendsocial.com/auth/twitter/callback

AI Providers

Anthropic (Claude)

bash
# Required for Claude models
ANTHROPIC_API_KEY=sk-ant-api03-...

# Optional: API version
ANTHROPIC_API_VERSION=2023-06-01

Google (Gemini)

bash
# Required for Gemini models
GOOGLE_AI_API_KEY=AIzaSy...

# Optional: Project ID for Vertex AI
GOOGLE_CLOUD_PROJECT=your-project-id

OpenAI

bash
# Required for GPT models and DALL-E
OPENAI_API_KEY=sk-...

# Optional: Organization
OPENAI_ORG_ID=org-...

AI Gateway Configuration

bash
# Active adapter: vercel-ai-sdk, direct-api, or litellm
AI_GATEWAY_ADAPTER=vercel-ai-sdk

# Cache TTL in seconds
AI_CONFIG_CACHE_TTL=60         # Config cache (1 minute)
AI_GATEWAY_CACHE_TTL=300       # Response cache (5 minutes)

# Optional: LiteLLM proxy URL (if using litellm adapter)
LITELLM_PROXY_URL=http://localhost:4000

# Optional: Cost controls
AI_MAX_COST_PER_CALL_CENTS=100  # Max 100 cents = $1 per call
AI_MONTHLY_BUDGET_CENTS=10000   # Max $100/month

Storage

S3/R2 (Cloudflare)

bash
# Cloudflare R2 (S3-compatible)
R2_ACCOUNT_ID=your-account-id
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=tendsocial-media
R2_PUBLIC_URL=https://media.tendsocial.com

# Or AWS S3
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=...
AWS_S3_BUCKET=tendsocial-media

Email

Resend

bash
# Email API key
RESEND_API_KEY=re_...

# From address
EMAIL_FROM=noreply@tendsocial.com
EMAIL_FROM_NAME=TendSocial

Analytics

Google Analytics 4

bash
# Property ID
GA4_PROPERTY_ID=properties/123456789

# Service account JSON (base64 encoded or path)
GA4_SERVICE_ACCOUNT_JSON={"type":"service_account",...}
# Or path:
GA4_SERVICE_ACCOUNT_PATH=/path/to/service-account.json

Background Jobs

Google Cloud Tasks

bash
# Project and location
GCP_PROJECT_ID=your-project-id
GCP_LOCATION=us-central1
GCP_QUEUE_NAME=tendsocial-jobs

# Service account for task creation
GCP_SERVICE_ACCOUNT_EMAIL=tasks@your-project.iam.gserviceaccount.com
GCP_SERVICE_ACCOUNT_KEY_PATH=/path/to/service-account.json

# Task handler URL
TASK_HANDLER_URL=https://api.tendsocial.com/api/tasks

###Cron Jobs

bash
# Enable background jobs
JOBS_ENABLED=true  # Set to false to disable all cron jobs

# Individual job schedules (cron format)
JOB_PROFILE_ANALYSIS=0 3 * * *     # 3 AM daily
JOB_PERFORMANCE_SYNC=0 */6 * * *   # Every 6 hours
JOB_EXAMPLE_CURATION=0 4 * * *     # 4 AM daily
JOB_SNAPSHOT_GENERATION=0 1 * * *  # 1 AM daily
JOB_AB_TEST_RESULTS=0 2 * * *      # 2 AM daily

Billing

LemonSqueezy

bash
# API key
LEMONSQUEEZY_API_KEY=...

# Store ID
LEMONSQUEEZY_STORE_ID=12345

# Webhook secret
LEMONSQUEEZY_WEBHOOK_SECRET=...

Feature Flags

bash
# Enable/disable features
FEATURE_CAMPAIGNS=true
FEATURE_AB_TESTING=true
FEATURE_VIDEO_SCRIPTS=true
FEATURE_BLOG_DESTINATIONS=true

Monitoring & Logging

bash
# Log level
LOG_LEVEL=info  # debug, info, warn, error

# Sentry (error tracking)
SENTRY_DSN=https://...@sentry.io/...

# Optional: APM
NEW_RELIC_LICENSE_KEY=...

Rate Limiting

bash
# Global rate limits
RATE_LIMIT_GLOBAL_MAX=100          # Requests per window
RATE_LIMIT_GLOBAL_WINDOW=60000     # Window in ms (1 minute)

# Admin endpoints (higher limits)
RATE_LIMIT_ADMIN_MAX=1000
RATE_LIMIT_ADMIN_WINDOW=60000

# AI generation (lower limits, expensive)
RATE_LIMIT_AI_MAX=10
RATE_LIMIT_AI_WINDOW=60000

Frontend URLs

bash
# Frontend app URL (for redirects)
FRONTEND_URL=https://app.tendsocial.com

# Marketing site
MARKETING_URL=https://tendsocial.com

Development Only

bash
# Skip email sending in dev
SKIP_EMAILS=true

# Mock external APIs
MOCK_SOCIAL_APIS=true
MOCK_AI_APIS=false

# Disable auth for testing
DISABLE_AUTH=false  # NEVER use in production!

Testing

bash
# Test database (separate from dev/prod)
TEST_DATABASE_URL=postgresql://user:password@localhost:5432/tendsocial_test

# Disable jobs during tests
TEST_DISABLE_JOBS=true

Environment-Specific Examples

Development (.env.development)

bash
NODE_ENV=development
PORT=4000
DATABASE_URL=postgresql://localhost:5432/tendsocial_dev
FRONTEND_URL=http://localhost:3000
SKIP_EMAILS=true
LOG_LEVEL=debug
JOBS_ENABLED=false

Production (.env.production)

bash
NODE_ENV=production
PORT=4000
DATABASE_URL=postgresql://prod-db:5432/tendsocial
FRONTEND_URL=https://app.tendsocial.com
SKIP_EMAILS=false
LOG_LEVEL=info
JOBS_ENABLED=true
SENTRY_DSN=https://...

Testing (.env.test)

bash
NODE_ENV=test
DATABASE_URL=postgresql://localhost:5432/tendsocial_test
TEST_DISABLE_JOBS=true
SKIP_EMAILS=true
LOG_LEVEL=error

Security Best Practices

  1. Never commit .env files - Use .env.example as template
  2. Rotate secrets regularly - Especially API keys and JWT secrets
  3. Use strong secrets - Minimum 32 characters, random
  4. Encrypt sensitive data - Use encryption keys stored separately
  5. Limit scope - API keys should have minimal required permissions
  6. Monitor usage - Track API key usage for anomalies

Validation

The API validates required environment variables on startup. Missing required variables will cause the server to fail to start with a clear error message.

Required variables:

  • DATABASE_URL
  • JWT_SECRET
  • ANTHROPIC_API_KEY (if using Anthropic)
  • GOOGLE_AI_API_KEY (if using Google)
  • OPENAI_API_KEY (if using OpenAI)
  • R2_ACCESS_KEY_ID or AWS_ACCESS_KEY_ID
  • RESEND_API_KEY

TendSocial Documentation