# Environment Variables

> Reference for every environment variable a self-hosted LearnHouse instance reads, with types, defaults and the service that uses each one.

This page is the deployment reference for LearnHouse environment variables. The backend
loads `apps/api/config/config.yaml` first, then overrides matching settings from the
environment. The web app reads `NEXT_PUBLIC_*` values from runtime config or `process.env`.
The CLI-generated `.env` file is the recommended way to configure a self-hosted instance. See
[CLI Environment Variables](https://docs.learnhouse.app/cli/environment-variables) for how that file is laid out and the
variables the CLI itself reads.

> Values shown as "required" have no safe production fallback. Values shown as "unset" are
> optional: the feature stays disabled or uses a runtime fallback when the variable is missing.

## Instance and hosting

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_SITE_NAME` | Instance name returned by the API. | string | `LearnHouse` | API |
| `LEARNHOUSE_SITE_DESCRIPTION` | Short instance description returned by the API. | string | `LearnHouse is an open-source platform tailored for learning experiences.` | API |
| `LEARNHOUSE_CONTACT_EMAIL` | Contact email for the instance. | email | `hello@learnhouse.app` | API |
| `LEARNHOUSE_ENV` | Environment label for backend and Sentry reporting. | string | `dev` | API, Web |
| `LEARNHOUSE_DEVELOPMENT_MODE` | Enables development-only API behavior such as docs routes and EE dev override. | boolean | `false` | API, CLI |
| `LEARNHOUSE_SAAS` | Enables SaaS deployment mode, plan gating, and platform endpoint warnings. | boolean | `false` | API |
| `LEARNHOUSE_SELF_HOSTED` | Legacy self-hosting flag used in tenancy inference. Prefer `LEARNHOUSE_TENANCY`. Accepts `true`/`1`/`yes`/`on` (case-insensitive); anything else is off. Previously any non-empty value enabled it, including the string `false`. | boolean | unset (off) | API |
| `LEARNHOUSE_USE_DEFAULT_ORG` | Legacy default-org flag used in tenancy inference. Prefer `LEARNHOUSE_TENANCY`. Accepts `true`/`1`/`yes`/`on` (case-insensitive); anything else is off. Previously any non-empty value enabled it, including the string `false`. | boolean | unset (off) | API |
| `LEARNHOUSE_TENANCY` | Selects `single` host tenancy or `multi` subdomain tenancy. Multi-tenancy requires EE or SaaS mode. | enum: `single`, `multi` | `single` unless inferred as multi-tenant | API, EE CLI |
| `LEARNHOUSE_DOMAIN` | Public domain used for org routing, cookie decisions, and custom-domain CNAME targets. Include the port for local development. | hostname | `localhost:3000` | API, CLI |
| `LEARNHOUSE_FRONTEND_DOMAIN` | Frontend host used by the API when it needs the public frontend domain separately from the backend host. | hostname | `localhost:3000` | API, EE CLI |
| `LEARNHOUSE_SSL` | Backend-side SSL flag: picks `https` vs `http` for generated links (password reset, email verification, invites, magic links, SSO redirect, media URLs). Accepts `true`/`1`/`yes`/`on` (case-insensitive); anything else is off. Previously any non-empty value enabled it, including the string `false`, so check your value before upgrading. | boolean | `false` | API |
| `LEARNHOUSE_PORT` | Backend port. Local config defaults to `1338`. In the Docker image it must stay `9000`: the image's internal nginx sends API traffic there. | integer | `1338` locally, `9000` in generated Docker installs | API, CLI, API container |
| `LEARNHOUSE_ALLOWED_ORIGINS` | Comma-separated CORS allowlist. | CSV of URLs | `http://localhost:3000,http://localhost:3001` | API |
| `LEARNHOUSE_ALLOWED_REGEXP` | Origin regex used by CORS and CSRF checks, and when validating the base URL of emailed links. The default matches any origin, so set it to your own domain in production, for example `^https://(?:[a-z0-9-]+\.)*example\.com$`. | regex string | `\b((?:https?://)[^\s/$.?#].[^\s]*)\b` (matches everything) | API |
| `LEARNHOUSE_MAX_REQUEST_BODY_MB` | Largest JSON, form or raw request body the API accepts before returning `413`. Multipart uploads keep their own per-type limits. `0` disables the cap. | integer | `25` | API |
| `LEARNHOUSE_COOKIE_DOMAIN` | Cookie domain for auth cookies in multi-organization mode (`LEARNHOUSE_TENANCY=multi`). Ignored in single mode, where cookies are host-only. | hostname | unset | API, EE CLI |
| `LEARNHOUSE_COOKIE_DOMAIN_ALLOW_BROAD` | Acknowledges intentionally broad cookie domains such as `.example.com` and silences the safety warning. | boolean | `false` | API, EE CLI |
| `LEARNHOUSE_CUSTOM_DOMAIN_DEV_MODE` | Skips DNS verification for all custom domains and marks them verified immediately. Development/testing only. | boolean | `false` | API |
| `LEARNHOUSE_PUBLIC` | Docker build argument that produces a community build by excluding non-community code. Also forces the community build of the web app when set to `true`. | boolean | `false` | Dockerfiles (root, API, Web), Web build |
| `LEARNHOUSE_PLATFORM_URL` | Base URL for LearnHouse platform links, upgrade URLs, and email allowlist checks. | URL | unset; backend flows fall back to `https://www.learnhouse.app` and the web token-exchange to `https://learnhouse.app` | API, Web |
| `LEARNHOUSE_PLATFORM_API_KEY` | Shared secret for platform-only internal endpoints such as packs. When unset, those endpoints reject every request with a 403 and the API logs an error on the first rejected request. | secret string | required for SaaS/platform endpoints | API |
| `CLOUD_INTERNAL_KEY` | Shared secret for SaaS-internal endpoints (custom-domain sync and the `cloud_internal` router). When unset, those endpoints reject every request and the API logs a startup warning. | secret string | unset; required for SaaS custom-domain provisioning | API |

## Database, Redis, and collaboration

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_SQL_CONNECTION_STRING` | PostgreSQL connection string for the API and Alembic migrations. | PostgreSQL URL | `postgresql://learnhouse:learnhouse@localhost:5432/learnhouse`; production installs should set it | API, API migrations, CLI |
| `LEARNHOUSE_DB_URL` | Fallback database URL for the standalone `apps/api/scripts/migrate.py` migration helper when `DATABASE_URL` is unset. | PostgreSQL URL | `postgresql://learnhouse:learnhouse@localhost:5432/learnhouse` | API migration script |
| `LEARNHOUSE_AUTO_MIGRATE` | Migrate the database schema when the API starts. Set to `false` to run migrations yourself (`uv run python cli.py migrate`); the API then only creates missing tables. See [Database Migrations](https://docs.learnhouse.app/self-hosting/maintenance/updates#database-migrations). | boolean | `true` | API |
| `LEARNHOUSE_DB_PING_AFTER_IDLE_SECONDS` | A pooled database connection that sat idle this many seconds is checked before reuse. Lower it if a pooler or firewall drops idle connections sooner. | number | `10` | API |
| `LEARNHOUSE_PGBOUNCER` | Uses the small client-side pool meant for a PgBouncer/Supavisor pooler even when the URL does not reveal one. | boolean | `false` | API |
| `LEARNHOUSE_DB_DRIVER` | Async PostgreSQL driver for the API and CLI: `asyncpg` or `psycopg` (psycopg 3). psycopg sends each query in one round trip behind a transaction-mode pooler (PgBouncer, Supavisor) where asyncpg needs two, which roughly halves database time when the pooler is far away. Migrations always use psycopg2. | string | `asyncpg` | API, CLI |
| `LEARNHOUSE_REDIS_CONNECTION_STRING` | Redis URL for the API cache/session/event clients. Required: password reset, invitations and email verification fail without Redis. | Redis URL | `redis://localhost:6379/learnhouse` | API, CLI |
| `LEARNHOUSE_REDIS_URL` | Redis URL for the collaboration server. | Redis URL | `redis://localhost:6379`; CLI setup emits `redis://redis:6379` | Collab, CLI |
| `LEARNHOUSE_API_URL` | API base URL used by the collaboration server. | URL | `http://localhost:8000`; generated compose sets `http://localhost:9000` | Collab, CLI |

## Security, setup, and auth

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_AUTH_JWT_SECRET_KEY` | JWT signing key shared by the API and collaboration server. Must be at least 32 characters. | secret string | required | API, Collab, CLI |
| `LEARNHOUSE_INITIAL_ADMIN_EMAIL` | Initial admin email used by the API install command and generated `.env` files. | email | `admin@school.dev` for the API install command; CLI setup writes the chosen email | API, CLI |
| `LEARNHOUSE_INITIAL_ADMIN_PASSWORD` | Initial admin password used by the API install command and generated `.env` files. | secret string | required for install/bootstrap | API, CLI |
| `LEARNHOUSE_INITIAL_ORG_NAME` | Initial organization display name used during install. | string | `Default Organization` | API, CLI |
| `LEARNHOUSE_INITIAL_ORG_SLUG` | Initial organization slug used during install. | slug string | `default` | API, CLI |
| `LEARNHOUSE_GOOGLE_CLIENT_ID` | Google OAuth client ID used by web auth proxy routes. The API also accepts it as a fallback audience for backend token validation. | string | unset unless Google OAuth is enabled | Web, CLI, API |
| `LEARNHOUSE_GOOGLE_CLIENT_SECRET` | Google OAuth client secret used by the web token exchange route. | secret string | unset unless Google OAuth is enabled | Web, CLI |
| `LEARNHOUSE_GOOGLE_OAUTH_CLIENT_ID` | Expected Google OAuth audience for backend ID-token validation. Required to enable Google sign-in: if neither this nor `LEARNHOUSE_GOOGLE_CLIENT_ID` is set the audience cannot be checked and Google sign-in is refused. | string | unset | API |

## Web runtime

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `NEXT_PUBLIC_LEARNHOUSE_API_URL` | Explicit API URL for frontend API calls. If unset, the web app derives it from `NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL`. | URL | derived as `{backend}/api/v1/` | Web, CLI |
| `NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL` | Backend base URL used by the web app and server-side auth proxy routes. | URL | `http://localhost/` in config helpers; local dev checker writes `http://localhost:1338/` | Web, CLI |
| `LEARNHOUSE_INTERNAL_API_URL` | Optional server-only backend base URL (same shape as `NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL`, e.g. `http://learnhouse-api:9000/`). When set, server-side rendering and the session lookup call the API over this internal address instead of the public URL. It takes precedence over `NEXT_PUBLIC_LEARNHOUSE_API_URL` on the server and is never sent to the browser. Sign-in/out still go through `NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL`. | URL | unset, server uses the public URL | Web |
| `NEXT_PUBLIC_LEARNHOUSE_DOMAIN` | Public frontend domain. The web app can also fall back to runtime cookies set by the backend. | hostname | `localhost` or runtime cookie fallback | Web, CLI |
| `NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN` | Top-level/root domain used for cookie and subdomain helpers. | hostname | derived from `NEXT_PUBLIC_LEARNHOUSE_DOMAIN` when unset | Web, CLI |
| `NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG` | Legacy public multi-org flag generated by the CLI. Backend `LEARNHOUSE_TENANCY` is authoritative for current behavior. | boolean | `false` | CLI, legacy Web config |
| `NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG` | Default organization slug used by frontend routing fallbacks. | slug string | `default` | Web, CLI |
| `NEXT_PUBLIC_LEARNHOUSE_HTTPS` | Selects `https://` instead of `http://` in frontend URL helpers. The web app only treats the exact lowercase value `true` as enabled. | boolean | `false` | Web, CLI |
| `NEXT_PUBLIC_LEARNHOUSE_MEDIA_URL` | Base URL for direct media links. If unset, media URLs use the backend URL. | URL | unset, falls back to backend URL | Web |
| `NEXT_PUBLIC_LEARNHOUSE_PLATFORM_URL` | Browser-safe platform base URL for upgrade and auth exchange flows. | URL | unset | Web |
| `NEXT_PUBLIC_LEARNHOUSE_SENTRY_DSN` | Browser/server Sentry DSN for the web app. | URL | unset | Web |
| `NEXT_PUBLIC_LEARNHOUSE_ENV` | Web Sentry environment label. | string | `dev` | Web |
| `NEXT_PUBLIC_POSTHOG_KEY` | PostHog project key for product analytics. Analytics stay off unless this is set. | string | unset | Web |

## AI

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_IS_AI_ENABLED` | Kept for older configurations; not read by the API. AI features depend on a configured provider key. | boolean | `false` | CLI |
| `LEARNHOUSE_GEMINI_API_KEY` | Legacy Google/Gemini key and fallback embeddings key for providers without embeddings. | secret string | unset | API, CLI |
| `LEARNHOUSE_AI_PROVIDER` | Provider for generation: `google`, `openai`, `anthropic`, `deepseek`, `moonshot`, `mistral`, `openrouter`, `bedrock`, `ollama`, or another supported Pydantic AI provider. | string | `google` | API |
| `LEARNHOUSE_AI_API_KEY` | API key for the selected AI provider. Not required for `ollama`; optional for `bedrock`. | secret string | unset; required for most providers | API |
| `LEARNHOUSE_AI_BASE_URL` | Custom endpoint for OpenAI-compatible or local providers. | URL | unset; Ollama falls back to `http://localhost:11434/v1` | API |
| `LEARNHOUSE_AI_MODEL_FAST` | Low-latency model tier for titles, follow-ups, and migration tasks. | model id | `gemini-3.1-flash-lite` | API |
| `LEARNHOUSE_AI_MODEL_STANDARD` | Standard model tier for chat, RAG, and standard-plan generation. | model id | `gemini-3.5-flash` | API |
| `LEARNHOUSE_AI_MODEL_PRO` | Pro model tier for upgraded course planning and generation flows. | model id | `gemini-3.1-pro-preview` | API |
| `LEARNHOUSE_AI_IMAGE_MODEL` | Google image-generation model ("nano banana"). Google-only path (uses the Gemini key regardless of provider). | model id | `gemini-2.5-flash-image` | API |
| `LEARNHOUSE_AI_TTS_MODEL` | Google text-to-speech model for AI audio / podcast generation. Google-only path. | model id | `gemini-3.8-flash-tts` | API |
| `LEARNHOUSE_AI_EMBEDDING_PROVIDER` | Optional provider override for RAG embeddings. | string | same as `LEARNHOUSE_AI_PROVIDER` | API |
| `LEARNHOUSE_AI_EMBEDDING_MODEL` | Optional embedding model override. | model id | provider default, such as `gemini-embedding-001`, `text-embedding-3-small`, or `nomic-embed-text` | API |
| `LEARNHOUSE_AI_EMBEDDING_DIMENSIONS` | Embedding vector size. Changing this requires a matching database migration and re-index. | integer | `768` | API |

## MCP

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_MCP_ENABLED` | Serves the MCP endpoint at `/mcp` so members can connect AI apps such as Claude, ChatGPT or Cursor. | boolean | `true` | API |
| `LEARNHOUSE_MCP_PUBLIC_URL` | Public URL of the MCP endpoint. Set it when a proxy changes the host or scheme, since sign-in tokens are bound to this URL. | URL | unset; derived from each request | API |

## Email

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_EMAIL_PROVIDER` | Outbound email provider. | enum: `resend`, `smtp` | `resend` | API, CLI |
| `LEARNHOUSE_RESEND_API_KEY` | Resend API key when `LEARNHOUSE_EMAIL_PROVIDER=resend`. | secret string | unset; required to send via Resend | API, CLI |
| `LEARNHOUSE_SYSTEM_EMAIL_ADDRESS` | Sender address for system email. | email | unset; CLI setup can emit `noreply@{domain}` | API, CLI |
| `LEARNHOUSE_SYSTEM_EMAIL_SENDER_NAME` | Display name on system email, as in `Name <address>`. The address itself is not configurable per sender. | string | `LearnHouse` | API |
| `LEARNHOUSE_SMTP_HOST` | SMTP server hostname when `LEARNHOUSE_EMAIL_PROVIDER=smtp`. | hostname | unset | API, CLI |
| `LEARNHOUSE_SMTP_PORT` | SMTP server port. | integer | `587` | API, CLI |
| `LEARNHOUSE_SMTP_USERNAME` | SMTP authentication username. | string | unset | API, CLI |
| `LEARNHOUSE_SMTP_PASSWORD` | SMTP authentication password. | secret string | unset | API, CLI |
| `LEARNHOUSE_SMTP_USE_TLS` | Enables TLS for SMTP. | boolean | `true` | API, CLI |

## Content storage

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_CONTENT_DELIVERY_TYPE` | Storage backend for uploaded content. | enum: `filesystem`, `s3api` | `filesystem` | API, CLI |
| `LEARNHOUSE_S3_API_BUCKET_NAME` | S3-compatible bucket name when using `s3api`. | string | unset; required for S3 storage | API, CLI |
| `LEARNHOUSE_S3_API_ENDPOINT_URL` | S3-compatible endpoint URL. Leave unset for provider defaults where supported. | URL | unset | API, CLI |
| `LEARNHOUSE_S3_API_REGION` | Region for the course import/export S3 client (falls back to `AWS_REGION`, then `AWS_DEFAULT_REGION`). The default suits Cloudflare R2; set the real region for AWS S3 or MinIO, which check it against the endpoint. Uploads use `AWS_DEFAULT_REGION`. | string | `auto` | API |
| `LEARNHOUSE_MEDIA_URL` | Public base URL that serves `/content` files, used for images in emails (such as organization logos). `LEARNHOUSE_BACKEND_URL` is accepted as a fallback name. When unset, the API uses `{scheme}://api.{LEARNHOUSE_DOMAIN}` for a real domain, otherwise the request's own host. | URL | unset | API |
| `LEARNHOUSE_LMS_IMPORT_MAX_MB` | Largest file accepted by the LMS course import, in MB. | integer | `4096` | API |

## Sessions and security

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_AUTH_REFRESH_TOKEN_DAYS` | How many days a user can stay away before having to sign in again. Each refresh starts a new window, so active users stay signed in. Values below `14` are raised to `14`. | integer | `30` | API |
| `LEARNHOUSE_AUTH_LEGACY_SESSION_GRACE_DAYS` | How long, in days, a session created before LearnHouse recorded the sign-in method keeps working after it is first refreshed. | integer | `30` | API |
| `LEARNHOUSE_MFA_ENCRYPTION_KEY` | Key material used to encrypt users' MFA secrets in the database. | secret string | falls back to `LEARNHOUSE_AUTH_JWT_SECRET_KEY` | API |
| `LEARNHOUSE_SECURITY__TRUST_PROXY_HEADERS` | Read the client IP from `X-Forwarded-For` / `X-Real-IP` for rate limiting, but only when the direct connection comes from a private or loopback address. Set to `false` to always use the connection address. | boolean | `true` | API |

## Logging and startup

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_LOG_LEVEL` | API log level (`DEBUG`, `INFO`, `WARNING`, `ERROR`). | string | `INFO` | API |
| `LEARNHOUSE_DB_STARTUP_ATTEMPTS` | How many times the API retries a transient database connection error at startup before giving up. Permanent errors such as a wrong password fail at once. | integer | `5` | API |

## Background jobs and media processing

These jobs run inside the API process. Most of them need Redis.

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_HLS_ENABLED` | Transcode uploaded videos to HLS streams. Needs Redis and `ffmpeg`/`ffprobe` on the API's `PATH`; the community `ghcr.io/learnhouse/app` image includes them. Until a video is transcoded, the MP4 is served. Only the exact value `true` enables it. | boolean | `false` | API |
| `LEARNHOUSE_HLS_CONCURRENCY` | Maximum transcodes running at once per API process. | integer | `1` | API |
| `LEARNHOUSE_HLS_FFMPEG_THREADS` | Threads per `ffmpeg` transcode. `0` lets `ffmpeg` use all cores. | integer | `1` | API |
| `LEARNHOUSE_HLS_MAX_RETRIES` | Attempts per video before a transcode is marked failed. | integer | `6` | API |
| `LEARNHOUSE_HLS_ENCRYPT` | Encrypt HLS segments. Any value other than `true` turns it off. | boolean | `true` | API |
| `LEARNHOUSE_CAPTIONS_CONCURRENCY` | Maximum AI caption jobs running at once per API process. | integer | `1` | API |
| `LEARNHOUSE_FFMPEG_PATH` | `ffmpeg` executable used for AI captions. | path | `ffmpeg` | API |
| `LEARNHOUSE_FFPROBE_PATH` | `ffprobe` executable used for AI captions. | path | `ffprobe` | API |
| `LEARNHOUSE_RAG_CONCURRENCY` | Maximum AI search indexing jobs running at once. | integer | `2` | API |
| `LEARNHOUSE_RAG_BACKFILL_HOURS` | Hours between sweeps that index course content missing from AI search. `0` turns the sweep off. | number | `3` | API |
| `LEARNHOUSE_RAG_BACKFILL_BATCH` | Maximum items queued per indexing sweep. | integer | `500` | API |
| `LEARNHOUSE_BACKFILL_INTERVAL_HOURS` | Hours between scheduled backfill runs, which catch up work that predates a feature: HLS transcodes for older videos (when HLS is enabled), AI search indexing, and AI chapters for captioned videos on paid plans. `0` turns them off. | number | `48` | API |
| `LEARNHOUSE_BACKFILL_HLS_LIMIT` | Maximum videos one backfill run queues for HLS. | integer | `50` | API |
| `LEARNHOUSE_BACKFILL_CHAPTERS_LIMIT` | Maximum videos one backfill run spends AI credits on for chapters. | integer | `100` | API |
| `LEARNHOUSE_DRIP_EMAILS_DISABLED` | Any value turns off the hourly job that emails learners when drip content unlocks. | any value or unset | unset (job runs) | API |
| `LEARNHOUSE_MESSAGING_EMAILS_DISABLED` | Any value turns off the job that emails unread messages and delivers reminders. | any value or unset | unset (job runs) | API |

## Code execution

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_JUDGE0_API_URL` | Judge0 API URL. Setting it enables code execution routes. | URL | unset | API |
| `LEARNHOUSE_JUDGE0_CLIENT_ID` | Optional Judge0 client ID. | string | unset | API |
| `LEARNHOUSE_JUDGE0_CLIENT_SECRET` | Optional Judge0 client secret. | secret string | unset | API |

## Observability

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_SENTRY_DSN` | Backend Sentry DSN; also used by the web edge Sentry config as a non-public fallback. | URL | unset | API, Web edge |
| `LEARNHOUSE_LOGFIRE_ENABLED` | CLI-generated Logfire flag. The current OSS runtime does not read it directly. | boolean | `False` in CLI-generated `.env` | CLI |

## Development controls

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_DISABLE_EE` | Set to `1` to disable Enterprise hooks even if the `ee/` folder exists. The web build also drops Enterprise code when it is set. | `1` or unset | unset; CLI dev sets `1` unless `--ee` is used | API, Web build, CLI dev |
| `LEARNHOUSE_FORCE_EE` | Set to `1` to serve Enterprise features without a license. Only honored when `LEARNHOUSE_DEVELOPMENT_MODE` is on. | `1` or unset | unset; CLI dev sets `1` with `--ee` | API, EE backend, CLI dev |

## Enterprise Edition

These variables only take effect on Enterprise builds, which include the `ee/` code. Enterprise features also need an active license (or `LEARNHOUSE_FORCE_EE=1` in development mode).

### License

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_LICENSE_KEY` | Enterprise license key. The API checks it with the license server at startup and on a periodic heartbeat. The CLI also uses it as the password for the Enterprise image registry. | secret string | required for Enterprise | EE backend, EE CLI |
| `LEARNHOUSE_LICENSE_SERVER_URL` | License server URL. | URL | `https://enterprise.learnhouse.app` | EE backend |
| `LEARNHOUSE_LICENSE_GRACE_HOURS` | How long, in hours since the license server last answered, Enterprise features keep working while the server can't be reached. Clamped to 1 to 168. A revoked or expired license is deactivated at once. | integer | `25` | EE backend |
| `LEARNHOUSE_DATA_DIR` | Directory where the API stores the cached license token, the instance ID and the time of the last successful license check. Mount it on a volume so they survive container recreation. | path | `/app/data` | EE backend |
| `LEARNHOUSE_DEPLOYMENT_ID` | Deployment identifier reported to the license server. | string | the instance ID | EE backend |
| `LEARNHOUSE_VERSION` | Version reported to the license server. | string | `unknown` | EE backend |

### Payments (Stripe)

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_STRIPE_SECRET_KEY` | Stripe secret key (`sk_live_...` or `sk_test_...`). Required to enable Stripe. | secret string | unset | API, EE backend |
| `LEARNHOUSE_STRIPE_PUBLISHABLE_KEY` | Stripe publishable key (`pk_...`). Required to enable Stripe. | string | unset | API, EE backend |
| `LEARNHOUSE_STRIPE_CLIENT_ID` | Stripe Connect OAuth client ID (`ca_...`), needed for organizations to connect their own Stripe account. | string | unset | API, EE backend |
| `LEARNHOUSE_STRIPE_WEBHOOK_STANDARD_SECRET` | Signing secret (`whsec_...`) for the standard webhook endpoint, `POST /api/v1/payments/stripe/webhook`. | secret string | unset | API, EE backend |
| `LEARNHOUSE_STRIPE_WEBHOOK_CONNECT_SECRET` | Signing secret (`whsec_...`) for the Connect webhook endpoint, `POST /api/v1/payments/stripe/webhook/connect`. | secret string | unset | API, EE backend |

### Single sign-on

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `WORKOS_API_KEY` | WorkOS API key. WorkOS-backed SSO is available only when both this and `WORKOS_CLIENT_ID` are set. | secret string | unset | EE backend |
| `WORKOS_CLIENT_ID` | WorkOS client ID. | string | unset | EE backend |
| `SSO_REDIRECT_URI` | Full SSO callback URL. When set, it is used as is. | URL | unset | EE backend |
| `SSO_REDIRECT_URI_BASE` | Base URL for the SSO callback when `SSO_REDIRECT_URI` is unset. `/api/v1/auth/sso/callback` is appended unless the value already ends with it. | URL | falls back to `LEARNHOUSE_DOMAIN`, then `http://localhost:4000` | EE backend |

### SCORM

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_SCORM_MAX_PACKAGE_SIZE_MB` | Largest SCORM package upload, in MB. | integer | `5120` (5 GB) | EE backend |
| `LEARNHOUSE_SCORM_MAX_FILE_SIZE_MB` | Largest single file inside a package, in MB. | integer | `2048` (2 GB) | EE backend |
| `LEARNHOUSE_SCORM_MAX_UNCOMPRESSED_MB` | Cap on the total uncompressed size of a package, in MB (zip-bomb guard). | integer | `25600` (25 GB) | EE backend |
| `LEARNHOUSE_SCORM_TEMP_TTL_MINUTES` | How long an uploaded package that was analyzed but not imported is kept, in minutes. | integer | `120` | EE backend |

### Live sessions

See [Live Sessions](https://docs.learnhouse.app/enterprise/live-sessions).

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_MEET_URL` | Public websocket URL of the LearnHouse Meet media server (`apps/meet`). | URL | unset | EE backend |
| `LEARNHOUSE_MEET_API_KEY` | API key of that server. | string | unset | EE backend |
| `LEARNHOUSE_MEET_API_SECRET` | Matching secret; signs room tokens and checks webhooks. | secret string | unset | EE backend |
| `LEARNHOUSE_MEET_INTERNAL_URL` | How the API reaches the media server, when different from the public URL. | URL | `LEARNHOUSE_MEET_URL` | EE backend |
| `LEARNHOUSE_MEET_RECORDING` | `true` when the recorder runs; shows hosts the record button. | boolean | `false` | EE backend |
| `LEARNHOUSE_LIVE_GOOGLE_CLIENT_ID` / `_SECRET` | Platform Google OAuth app for live sessions. Unset: org admins can use their own app. | string / secret | unset | EE backend |
| `LEARNHOUSE_LIVE_ZOOM_CLIENT_ID` / `_SECRET` | Platform Zoom OAuth app for live sessions. | string / secret | unset | EE backend |
| `LEARNHOUSE_LIVE_OAUTH_REDIRECT_URI` | Exact OAuth callback URL for live session providers. | URL | `<API>/api/v1/live_sessions/oauth/callback` | EE backend |

### Analytics

See [Analytics](https://docs.learnhouse.app/platform/analytics). Analytics is stored in PostgreSQL and needs no extra service.

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_ANALYTICS_MAINTENANCE` | Run the analytics summary and retention job inside the API. Set to `false` only if another process runs it. | boolean | `true` | EE backend |
| `LEARNHOUSE_TINYBIRD_API_URL` | Legacy. Only read by the one-time [Tinybird import](https://docs.learnhouse.app/platform/analytics#migrating-from-tinybird). | URL | unset | EE import script |
| `LEARNHOUSE_TINYBIRD_READ_TOKEN` | Legacy. Tinybird read token for the same import. | secret string | unset | EE import script |

### LTI

See [LTI](https://docs.learnhouse.app/enterprise/lti).

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `LEARNHOUSE_LTI_BASE_URL` | Public API origin used in the tool URLs you give the LMS (login, launch, keyset, registration). Set it when the LMS reaches the API through a different host than browsers do. | URL | unset; resolved like `LEARNHOUSE_MEDIA_URL` | EE backend |
| `LEARNHOUSE_LTI_ALLOW_PRIVATE_HOSTS` | Allow LTI requests to LMS addresses on private or internal networks. Accepts `true`/`1`/`yes`. Ignored on LearnHouse Cloud. | boolean | `false` | EE backend |

## LearnHouse Cloud only

The hosted LearnHouse Cloud platform reads these variables. Self-hosted instances don't need them.

| Variable | Used by | Purpose |
| --- | --- | --- |
| `LEARNHOUSE_NUDGES_ENABLED`, `LEARNHOUSE_NUDGES_NO_SCHEDULER`, `LEARNHOUSE_NUDGES_BACKFILL_MODE`, `LEARNHOUSE_NUDGES_ACTIVATION_DATE` | API | Lifecycle email nudges. The scheduler only runs in SaaS mode. |
| `LEARNHOUSE_RESEND_WEBHOOK_SECRET` | API | Verifies Resend delivery webhooks for nudges |
| `LOOPS_API_KEY` | API, Web | Marketing contact sync |
| `NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` | Web | Cloudflare Turnstile on auth forms, active only in SaaS mode |
| `RESEND_API_KEY`, `RESEND_FROM_EMAIL`, `ABSTRACT_EMAIL_API_KEY` | Web | Platform emails and disposable-email checks |
| `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`, `STRIPE_PRICE_*`, `CRON_SECRET`, `LEARNHOUSE_CLOUD_INTERNAL_KEY` | Web | Platform billing |

## Related generated variables

These variables do not use the `LEARNHOUSE_` prefix, but the CLI writes them into the same
`.env` file and several services require them.

| Variable | Description | Type | Default / required | Used by |
| --- | --- | --- | --- | --- |
| `HTTP_PORT` | Public HTTP port chosen during CLI setup. | integer | setup choice | CLI-generated compose |
| `NEXTAUTH_URL` | Base URL for NextAuth-compatible auth helpers. | URL | generated from the configured domain | CLI, doctor |
| `NEXTAUTH_SECRET` | Secret used by NextAuth-compatible auth helpers. | secret string | generated by CLI setup | CLI, doctor |
| `COLLAB_INTERNAL_KEY` | Shared key for API-to-collaboration-server internal auth. | secret string | required for dev and production collab auth | API, Collab, CLI |
| `NEXT_PUBLIC_COLLAB_URL` | Public WebSocket URL for the collaboration server. | WebSocket URL | `ws://localhost:4000`; CLI setup generates it from the configured domain | Web, CLI |
| `COLLAB_PORT` | Local collaboration server port. | integer | `4000` in local dev checker | Collab, CLI dev |
| `COLLAB_TRUST_PROXY` | Set to `true` when the collaboration server runs behind a reverse proxy so client IPs (used for WebSocket rate limiting) are read from `X-Forwarded-For`. | boolean | `false` | Collab |
| `POSTGRES_USER` | PostgreSQL user for generated non-external database installs. | string | `learnhouse` | CLI-generated compose |
| `POSTGRES_PASSWORD` | PostgreSQL password for generated non-external database installs. | secret string | generated by CLI setup | CLI-generated compose |
| `POSTGRES_DB` | PostgreSQL database name for generated non-external database installs. | string | `learnhouse` | CLI-generated compose |

## Full example

```env title=".env"
# Domain and hosting
LEARNHOUSE_DOMAIN=learn.example.com
HTTP_PORT=443
NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL=https://learn.example.com/
NEXT_PUBLIC_LEARNHOUSE_API_URL=https://learn.example.com/api/v1/
NEXT_PUBLIC_LEARNHOUSE_DOMAIN=learn.example.com
NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN=example.com
NEXT_PUBLIC_LEARNHOUSE_HTTPS=true
NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=default

# Backend
LEARNHOUSE_SQL_CONNECTION_STRING=postgresql://learnhouse:change-me@db:5432/learnhouse
LEARNHOUSE_REDIS_CONNECTION_STRING=redis://redis:6379/learnhouse
LEARNHOUSE_PORT=9000

# Security and bootstrap
# Generate each secret with: openssl rand -hex 32
LEARNHOUSE_AUTH_JWT_SECRET_KEY=
LEARNHOUSE_INITIAL_ADMIN_EMAIL=admin@example.com
LEARNHOUSE_INITIAL_ADMIN_PASSWORD=change-this-password
LEARNHOUSE_INITIAL_ORG_NAME=Default Organization
LEARNHOUSE_INITIAL_ORG_SLUG=default

# Collaboration
COLLAB_INTERNAL_KEY=
LEARNHOUSE_REDIS_URL=redis://redis:6379
NEXT_PUBLIC_COLLAB_URL=wss://learn.example.com/collab

# AI, email, and storage
LEARNHOUSE_IS_AI_ENABLED=False
LEARNHOUSE_EMAIL_PROVIDER=resend
LEARNHOUSE_CONTENT_DELIVERY_TYPE=filesystem
```
