---
title: "Environment Variables"
description: "Environment variables for Formbricks"
icon: "code"
---

#### Custom Configurations

Save environment changes in your Compose configuration or deployment secret source, then recreate the affected containers or roll out the pods. `docker compose restart` does not load changed values.

<Note>
  Upgrading from Formbricks 4.x to 5.0? Read the [migration guide](/self-hosting/advanced/migration#v5) first.
  Formbricks v5 makes Hub part of the standard self-hosted runtime and changes how rate limiting is enforced.
</Note>

For the `AI_*` variables, see [AI Features](/self-hosting/configuration/ai-features) — it walks through each provider and the credentials it needs. Set only the variables for the provider you use; unused provider variables can be omitted.

{/* prettier-ignore-start */}

| Variable                                | Description                                                                                                                                                                                     | Required                                                                                 | Default                                                                   |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| WEBAPP_URL                              | Base URL of the private/admin Formbricks app. OAuth and MCP protected-resource URLs are derived from this value.                                                                                | required                                                                                 | http://localhost:3000                                                     |
| PUBLIC_URL                              | Base URL for the public domain where surveys and public-facing content are served. If not set, uses WEBAPP_URL. OAuth and MCP do not use PUBLIC_URL.                                           | optional                                                                                 | WEBAPP_URL                                                                |
| FORMBRICKS_WORKSPACE_ID                  | Workspace whose surveys appear inside the authenticated Formbricks app. Leave unset to disable the built-in SDK integration. See [In-app surveys inside Formbricks](#in-app-surveys-inside-formbricks). | optional | |
| FORMBRICKS_APP_URL                       | Browser-accessible base URL of the Formbricks instance serving those surveys. Set this to your own instance to use a self-hosted workspace. | optional | https://app.formbricks.com |
| BETTER_AUTH_URL                         | Auth base URL; Formbricks derives the Better Auth issuer under `/api/auth`. Normally the same as WEBAPP_URL, but it is not inferred from it — leave it unset and Better Auth has no base URL or trusted origin, and every sign-in is rejected. Use a dedicated hostname; [subpaths have a browser sign-in limitation](/self-hosting/configuration/custom-subpath). | required                                | http://localhost:3000                                                     |
| MCP_OAUTH_JWKS_URL                      | Optional server-only URL used to fetch Better Auth signing keys for MCP OAuth. It does not change the public issuer, redirects, cookies, or token audience. Docker Compose and Helm leave it unset unless explicitly configured. Use an internal HTTP URL only on a trusted application network and include any custom application subpath. | optional | `{BETTER_AUTH_URL}/jwks` |
| MCP_DCR_ALLOWED_REDIRECT_URIS           | Optional comma-separated list of extra exact `https` redirect URIs that MCP clients may claim when they register themselves anonymously. Local (`http://localhost`, `127.0.0.1`, `[::1]`) callbacks and the claude.ai and ChatGPT callbacks are always allowed; this only adds to them. Entries match by exact string — no wildcards, no fragments, no credentials, no loopback hosts (local callbacks are already allowed), and a URI containing a comma is not supported. Anyone can register a client with these URIs, so only add a callback owned by the client's vendor, never a page that shows user content or forwards to another URL. | optional | |
| DATABASE_URL                            | Database URL with credentials.                                                                                                                                                                  | required                                                                                 |                                                                           |
| BETTER_AUTH_SECRET                      | Signs session cookies and every invite, email-verification and email-change token. At least 32 characters; Formbricks refuses to start below that on a new install.                             | required                                                                                 | (Generated by the user, `openssl rand -hex 32`)                           |
| ENCRYPTION_KEY                          | Secret used by Formbricks for data encryption and audit log hashing.                                                                                                                            | required                                                                                 | (Generated by the user, must not exceed 32 bytes, `openssl rand -hex 32`) |
| CRON_SECRET                             | API Secret for running cron jobs.                                                                                                                                                               | required                                                                                 | (Generated by the user, must not exceed 32 bytes, `openssl rand -hex 32`) |
| LOG_LEVEL                               | Minimum log level (debug, info, warn, error, fatal)                                                                                                                                             | optional                                                                                 | `warn` (production), `info` (development), `error` (build) |
| S3_ACCESS_KEY                           | Access key for S3.                                                                                                                                                                              | optional                                                                                 | (resolved by the AWS SDK)                                                 |
| S3_SECRET_KEY                           | Secret key for S3.                                                                                                                                                                              | optional                                                                                 | (resolved by the AWS SDK)                                                 |
| S3_REGION                               | Region for S3.                                                                                                                                                                                  | optional                                                                                 | (resolved by the AWS SDK)                                                 |
| S3_BUCKET_NAME                          | S3 bucket name for data storage. Formbricks enables S3 storage when this is set.                                                                                                                | optional (required if S3 is enabled)                                                     |                                                                           |
| S3_ENDPOINT_URL                         | Endpoint for S3.                                                                                                                                                                                | optional                                                                                 | (resolved by the AWS SDK)                                                 |
| S3_FORCE_PATH_STYLE                     | Set to `1` to force path-style S3 URLs. Required for S3-compatible storage (MinIO, RustFS, LocalStack). Leave unset or `0` for standard AWS S3.                                                 | optional                                                                                 | 0                                                                         |
| SAML_DATABASE_URL                       | Database URL for SAML.                                                                                                                                                                          | optional                                                                                 | postgres://postgres:@localhost:5432/formbricks-saml                       |
| PRIVACY_URL                             | URL for privacy policy.                                                                                                                                                                         | optional                                                                                 |                                                                           |
| TERMS_URL                               | URL for terms of service.                                                                                                                                                                       | optional                                                                                 |                                                                           |
| IMPRINT_URL                             | URL for imprint.                                                                                                                                                                                | optional                                                                                 |                                                                           |
| IMPRINT_ADDRESS                         | Address for imprint.                                                                                                                                                                            | optional                                                                                 |                                                                           |
| EMAIL_AUTH_DISABLED                     | Disables the ability for users to signup or login via email and password if set to 1.                                                                                                           | optional                                                                                 |                                                                           |
| PASSWORD_RESET_DISABLED                 | Disables password reset functionality if set to 1.                                                                                                                                              | optional                                                                                 |                                                                           |
| PASSWORD_HIBP_CHECK_DISABLED            | Disables the Have-I-Been-Pwned breach check on password set (signup / reset) if set to 1. The check calls api.pwnedpasswords.com and fails open on network errors; set this on air-gapped / closed-network deployments to skip the outbound call. | optional                                                                                 |                                                                           |
| PASSWORD_RESET_TOKEN_LIFETIME_MINUTES   | Configures how long password reset links remain valid in minutes. Accepted values are integers from 5 to 120.                                                                                   | optional                                                                                 | 30                                                                        |
| EMAIL_VERIFICATION_DISABLED             | Disables email verification if set to 1.                                                                                                                                                        | optional                                                                                 |                                                                           |
| RATE_LIMITING_DISABLED                  | Disables only the application-level rate limiter if set to 1. It does not disable Envoy or an equivalent edge rate limiter.                                                                   | optional                                                                                 |                                                                           |
| TRUSTED_PROXY_HOP_COUNT | Number of trusted reverse proxies (CDN, load balancer, ingress, Envoy) that append to `X-Forwarded-For` before a request reaches Formbricks. Formbricks reads the client IP from that position, for IP-based rate limits, audit logs and the caller IP of a workflow's Webhook trigger. `0` trusts no forwarding header. See [Configure trusted proxy hops](/self-hosting/advanced/enterprise-features/audit-logging#configure-trusted-proxy-hops). | optional | 1 |
| INVITE_RATE_LIMIT_PER_24_HOURS          | Maximum invite recipients one organization, and separately one inviting user across all of their organizations, may target across single, bulk, onboarding, and resend flows within 24 hours.                                                                     | optional                                                                                 | 50                                                                        |
| EMAIL_RATE_LIMIT_MULTIPLIER             | Multiplies the per-organization, per-sender and per-deployment email caps listed in [Email Limits](/self-hosting/configuration/rate-limiting#email-limits). Any number above 0, up to 100; per-recipient caps are not affected. | optional                                                                                 | 1                                                                         |
| ENTERPRISE_LICENSE_KEY                  | License key for the Formbricks Enterprise Edition. Unlocks Enterprise-only features; the instance validates it against the Formbricks license server, so it needs outbound network access (or `HTTP_PROXY`/`HTTPS_PROXY`). See [License Activation](/self-hosting/advanced/license-activation). | optional (required for Enterprise Edition features)                                      |                                                                           |
| TELEMETRY_DISABLED                      | Disables telemetry reporting if set to 1. Ignored when an Enterprise License is active.                                                                                                         | optional                                                                                 |                                                                           |
| DANGEROUSLY_ALLOW_WEBHOOK_INTERNAL_URLS | Allows webhook URLs to point to internal/private network addresses (e.g. localhost, 192.168.x.x) if set to 1. Useful for self-hosted instances that need to send webhooks to internal services. Applies to the Webhooks integration only; workflow HTTP requests use `DANGEROUSLY_ALLOW_WORKFLOW_INTERNAL_URLS`. | optional                                                                                 |                                                                           |
| DANGEROUSLY_ALLOW_WORKFLOW_PLAIN_HTTP | Accepts plain HTTP calls to a workflow's Webhook Secret URL if set to 1, and lets workflow HTTP request steps (and their test requests) call plain-HTTP URLs. HTTPS is required otherwise; for the Secret URL it is read from `X-Forwarded-Proto`, and calls to `localhost` always work. An HTTP request step calling `localhost` or another internal address also needs `DANGEROUSLY_ALLOW_WORKFLOW_INTERNAL_URLS`. Only for fully private networks or proxies that do not forward `X-Forwarded-Proto`: the Secret URL is a credential. See [Workflow Webhook trigger behind a reverse proxy](#workflow-webhook-trigger-behind-a-reverse-proxy). Ignored on Formbricks Cloud. | optional | |
| DANGEROUSLY_ALLOW_WORKFLOW_INTERNAL_URLS | Lets workflow HTTP request steps (and **Send test request**) call internal/private network addresses (e.g. localhost, 192.168.x.x) if set to 1. Separate from `DANGEROUSLY_ALLOW_WEBHOOK_INTERNAL_URLS`, which no longer opens internal addresses to workflows: a webhook only sees the status code, but Send test request shows up to 64 KB of the response body, so this switch lets every workflow editor, and every API key or MCP client that can edit workflows, read your internal services. If you set `DANGEROUSLY_ALLOW_WEBHOOK_INTERNAL_URLS` so workflow HTTP requests could reach internal services, set this one too. Ignored on Formbricks Cloud. | optional | |
| WORKFLOW_WEBHOOK_DAILY_RUN_LIMIT | Calls one enabled workflow's Webhook Secret URL may take per day (UTC). Every call to an enabled workflow that passes the plan check counts, including calls later refused for size or content type and calls that repeat an Idempotency-Key; calls to a draft or disabled workflow don't. Calls over the limit answer 429. | optional | 10000 |
| WORKFLOW_WEBHOOK_ORG_CALLS_PER_MINUTE | Webhook Secret URL calls per minute across all of one organization's workflows. Calls over it answer 429; each workflow is also limited to 100 calls per minute. | optional | 300 |
| WORKFLOW_RUN_DATA_RETENTION_DAYS | Days after a workflow run finished that its content is deleted: the trigger payload, each step's input, output and errors, the run data and the caller's IP. The run's status, times, workflow and version stay, so usage counts don't change. Saved samples not updated for this long are deleted too. Test runs are always deleted after 7 days. A whole number from 1 to 3650. See [Run data retention](/workflows/manage-and-monitor#run-data-retention). | optional | 90 |
| WEBHOOK_DELIVERY_TIMEOUT_MS             | Milliseconds a webhook delivery (and the "test endpoint" button) waits for the receiver to respond before failing the attempt. Between 1000 and 30000. A longer timeout holds a Job Runner slot longer. | optional                                                                                 | 5000                                                                      |
| INVITE_DISABLED                         | Disables the ability for invited users to create an account if set to 1.                                                                                                                        | optional                                                                                 |                                                                           |
| MAIL_FROM                               | Email address to send emails from.                                                                                                                                                              | optional (required if email services are to be enabled)                                  |                                                                           |
| MAIL_FROM_NAME                          | Email name/title to send emails from.                                                                                                                                                           | optional (required if email services are to be enabled)                                  |                                                                           |
| SES_CONFIGURATION_SET | Amazon SES configuration set for event publishing. Set only with SES SMTP and SES_EMAIL_ENVIRONMENT; omitted by default. | optional | |
| SES_EMAIL_ENVIRONMENT | Deployment label for SES metrics, such as staging. Requires SES_CONFIGURATION_SET. Both values accept ASCII letters, digits, hyphens and underscores (up to 64 characters). | optional | |
| SMTP_HOST                               | Host URL of your SMTP server.                                                                                                                                                                   | optional (required if email services are to be enabled)                                  |                                                                           |
| SMTP_PORT                               | Host Port of your SMTP server.                                                                                                                                                                  | optional (required if email services are to be enabled)                                  |                                                                           |
| SMTP_USER                               | Username for your SMTP Server.                                                                                                                                                                  | optional (required if email services are to be enabled)                                  |                                                                           |
| SMTP_PASSWORD                           | Password for your SMTP Server.                                                                                                                                                                  | optional (required if email services are to be enabled)                                  |                                                                           |
| SMTP_AUTHENTICATED                      | If set to 0, the server will not require SMTP_USER and SMTP_PASSWORD(default is 1)                                                                                                              | optional                                                                                 |                                                                           |
| SMTP_SECURE_ENABLED                     | Set to `1` for implicit TLS (typically port 465); set to `0` for STARTTLS or a local relay.                                                                                                    | optional (required if email services are to be enabled)                                  | 0                                                                         |
| SMTP_REQUIRE_TLS                        | Set to `1` to require STARTTLS when implicit TLS is disabled (typically port 587). Sending fails if the server does not offer STARTTLS. Leave at `0` for plaintext local relays.                    | optional                                                                                 | 0                                                                         |
| SMTP_REJECT_UNAUTHORIZED_TLS            | Keep at `1` to verify the SMTP server certificate. Setting `0` disables certificate verification and is unsafe for production; mount a private CA and configure `NODE_EXTRA_CA_CERTS` instead.                                                               | optional                                                                                 | 1                                                                         |
| TURNSTILE_SITE_KEY                      | Site key for Turnstile.                                                                                                                                                                         | optional                                                                                 |                                                                           |
| TURNSTILE_SECRET_KEY                    | Secret key for Turnstile.                                                                                                                                                                       | optional                                                                                 |                                                                           |
| RECAPTCHA_SITE_KEY                      | Site key for survey responses recaptcha bot protection                                                                                                                                          | optional                                                                                 |                                                                           |
| RECAPTCHA_SECRET_KEY                    | Secret key for recaptcha bot protection.                                                                                                                                                        | optional                                                                                 |                                                                           |
| GITHUB_ID                               | Client ID for GitHub.                                                                                                                                                                           | optional (required if GitHub auth is enabled)                                            |                                                                           |
| GITHUB_SECRET                           | Secret for GitHub.                                                                                                                                                                              | optional (required if GitHub auth is enabled)                                            |                                                                           |
| GOOGLE_CLIENT_ID                        | Client ID for Google.                                                                                                                                                                           | optional (required if Google auth is enabled)                                            |                                                                           |
| GOOGLE_CLIENT_SECRET                    | Secret for Google.                                                                                                                                                                              | optional (required if Google auth is enabled)                                            |                                                                           |
| AI_PROVIDER                             | Instance-level AI provider used in the background. Supported values: `aws`, `google`, `azure`, `openai-compatible`.                                                                             | optional (required if AI is enabled)                                                     |                                                                           |
| AI_MODEL                                | Instance-level AI model or deployment name used by the active provider.                                                                                                                         | optional (required if `AI_PROVIDER` is set)                                              |                                                                           |
| AI_TIMEOUT_MULTIPLIER | Multiplies all web app AI call timeouts and the QSF import deadline. Accepts numbers from 1 through 10, including decimals. See [Longer timeouts](/self-hosting/configuration/ai-timeouts). | optional | 1 |
| AI_GOOGLE_CLOUD_PROJECT                 | Google Cloud project ID for the `google` AI provider.                                                                                                                                          | optional (required if `AI_PROVIDER=google`)                                              |                                                                           |
| AI_GOOGLE_CLOUD_LOCATION                | Google Cloud location for `google` AI requests. Passed through as given; `us` and `eu` use multi-region endpoints. `global` is the safe default.                                                                                          | optional (required if `AI_PROVIDER=google`)                                              |                                                                           |
| AI_GOOGLE_CLOUD_CREDENTIALS_JSON        | Optional service account credentials JSON override for the `google` AI provider. Omit when Application Default Credentials are available.                                                       | optional                                                                                 |                                                                           |
| AI_GOOGLE_CLOUD_APPLICATION_CREDENTIALS | Optional path to Google Application Default Credentials used by the `google` AI provider.                                                                                                      | optional                                                                                 |                                                                           |
| AI_AWS_REGION                           | AWS region for Amazon Bedrock.                                                                                                                                                                  | optional (required if `AI_PROVIDER=aws`)                                                 |                                                                           |
| AI_AWS_ACCESS_KEY_ID                    | AWS access key ID for Amazon Bedrock.                                                                                                                                                           | optional (required if `AI_PROVIDER=aws`)                                                 |                                                                           |
| AI_AWS_SECRET_ACCESS_KEY                | AWS secret access key for Amazon Bedrock.                                                                                                                                                       | optional (required if `AI_PROVIDER=aws`)                                                 |                                                                           |
| AI_AWS_SESSION_TOKEN                    | AWS session token for Amazon Bedrock temporary credentials.                                                                                                                                     | optional                                                                                 |                                                                           |
| AI_AZURE_BASE_URL                       | Azure OpenAI / Foundry base URL, ending at `/openai` — the SDK appends `/v1` itself. When set, this is preferred over `AI_AZURE_RESOURCE_NAME`.                                                                                                     | optional (one of this or `AI_AZURE_RESOURCE_NAME` required if `AI_PROVIDER=azure`)       |                                                                           |
| AI_AZURE_RESOURCE_NAME                  | Azure resource name used to assemble the Azure OpenAI URL.                                                                                                                                      | optional (one of this or `AI_AZURE_BASE_URL` required if `AI_PROVIDER=azure`)            |                                                                           |
| AI_AZURE_API_KEY                        | API key for Azure OpenAI / Foundry.                                                                                                                                                             | optional (required if `AI_PROVIDER=azure`)                                               |                                                                           |
| AI_AZURE_API_VERSION                    | Azure API version for OpenAI-compatible calls.                                                                                                                                                  | optional                                                                                 | v1                                                                        |
| AI_OPENAI_COMPATIBLE_BASE_URL           | Base URL for a Qwen/vLLM OpenAI-compatible `/v1` endpoint, e.g. `http://vllm:8000/v1`.                                                                                                         | optional (required if `AI_PROVIDER=openai-compatible`)                                   |                                                                           |
| AI_OPENAI_COMPATIBLE_API_KEY            | Optional API key for the OpenAI-compatible endpoint.                                                                                                                                            | optional                                                                                 |                                                                           |
| AI_OPENAI_COMPATIBLE_PROVIDER_NAME      | Provider name passed to the OpenAI-compatible adapter. Use `vllm` for the supported Qwen/vLLM self-hosted path.                                                                                | optional                                                                                 | openai-compatible                                                         |
| AI_OPENAI_COMPATIBLE_SUPPORTS_STRUCTURED_OUTPUTS | Set to `1` when the Qwen/vLLM endpoint supports structured outputs.                                                                                                                   | optional                                                                                 | 0                                                                         |
| AI_OPENAI_COMPATIBLE_HEADERS_JSON       | Optional JSON object of string-valued headers to send with OpenAI-compatible requests.                                                                                                         | optional                                                                                 |                                                                           |
| AI_OPENAI_COMPATIBLE_QUERY_PARAMS_JSON  | Optional JSON object of string-valued query parameters to send with OpenAI-compatible requests.                                                                                                | optional                                                                                 |                                                                           |
| AI_OPENAI_COMPATIBLE_AUTH_MODE | How Formbricks authenticates to the OpenAI-compatible endpoint: `api-key` or `oauth2-client-credentials`. See [Behind an OAuth2 gateway](/self-hosting/configuration/ai-features#behind-an-oauth2-gateway). | optional | api-key |
| AI_OPENAI_COMPATIBLE_OAUTH_TOKEN_URL | OAuth2 token endpoint, e.g. `https://gateway.example.internal/oauth/token`. Must be `https` (plain `http` only on localhost). | optional (required if `AI_OPENAI_COMPATIBLE_AUTH_MODE=oauth2-client-credentials`) |  |
| AI_OPENAI_COMPATIBLE_OAUTH_CLIENT_ID | OAuth2 client ID. | optional (required if `AI_OPENAI_COMPATIBLE_AUTH_MODE=oauth2-client-credentials`) |  |
| AI_OPENAI_COMPATIBLE_OAUTH_CLIENT_SECRET | OAuth2 client secret. | optional (required if `AI_OPENAI_COMPATIBLE_AUTH_MODE=oauth2-client-credentials`) |  |
| AI_OPENAI_COMPATIBLE_OAUTH_SCOPE | Space-separated scopes to request with the token. | optional |  |
| AI_OPENAI_COMPATIBLE_OAUTH_AUTH_STYLE | Where the client credentials go in the token request: `basic` (Authorization header) or `post` (form body). | optional | basic |
| AI_OPENAI_COMPATIBLE_OAUTH_EXTRA_PARAMS_JSON | Optional JSON object of string-valued parameters to add to the token request, e.g. `audience`. | optional |  |
| STRIPE_SECRET_KEY                       | Secret key for Stripe integration.                                                                                                                                                              | optional                                                                                 |                                                                           |
| STRIPE_WEBHOOK_SECRET                   | Webhook secret for Stripe integration.                                                                                                                                                          | optional                                                                                 |                                                                           |
| DEFAULT_BRAND_COLOR                     | Default brand color for your app (Can be overwritten from the UI as well).                                                                                                                      | optional                                                                                 | #64748b                                                                   |
| UNSPLASH_ACCESS_KEY                     | Unsplash access key used to search Unsplash for survey background images. Without it, the image tab is hidden in the survey editor's background picker and in the Look & Feel settings.         | optional (required for Unsplash background images)                                       |                                                                           |
| AUTH_SSO_DEFAULT_ORGANIZATION_ID        | Requires an [Enterprise Edition](/self-hosting/advanced/license) licence with SSO. Automatically assigns new SSO users to this organization, without requiring an invitation. Must be a valid CUID; the organization is created with this ID on the first sign-up if it does not exist yet. Renamed from `DEFAULT_ORGANIZATION_ID` in v6. | optional (Enterprise Edition, SSO)                                                       |                                                                           |
| AUTH_SSO_DEFAULT_ORGANIZATION_ROLE      | Role given to users auto-assigned by `AUTH_SSO_DEFAULT_ORGANIZATION_ID`. The sign-up that creates the organization is always `owner`. One of `owner`, `manager`, `member`, `billing`. Renamed from `DEFAULT_ORGANIZATION_ROLE` in v6.                                                       | optional (Enterprise Edition, SSO)                                                       | manager                                                                   |
| OIDC_DISPLAY_NAME                       | Display name for Custom OpenID Connect Provider                                                                                                                                                 | optional                                                                                 |                                                                           |
| OIDC_CLIENT_ID                          | Client ID for Custom OpenID Connect Provider                                                                                                                                                    | optional (required if OIDC auth is enabled)                                              |                                                                           |
| OIDC_CLIENT_SECRET                      | Secret for Custom OpenID Connect Provider                                                                                                                                                       | optional (required if OIDC auth is enabled)                                              |                                                                           |
| OIDC_ISSUER                             | Issuer URL for Custom OpenID Connect Provider (should have .well-known configured at this)                                                                                                      | optional (required if OIDC auth is enabled)                                              |                                                                           |
| OIDC_SIGNING_ALGORITHM                  | Signing Algorithm for Custom OpenID Connect Provider                                                                                                                                            | optional                                                                                 | RS256                                                                     |
| OTEL_EXPORTER_OTLP_ENDPOINT             | Base OTLP HTTP endpoint for traces and metrics export (e.g. http://collector:4318).                                                                                                             | optional                                                                                 |                                                                           |
| OTEL_EXPORTER_OTLP_PROTOCOL             | OTLP protocol to use for export.                                                                                                                                                                | optional                                                                                 | http/protobuf                                                             |
| OTEL_SERVICE_NAME                       | Service name reported in OpenTelemetry resource attributes.                                                                                                                                     | optional                                                                                 | formbricks                                                                |
| OTEL_RESOURCE_ATTRIBUTES                | Comma-separated resource attributes in OTel format (`key=value,key2=value2`).                                                                                                                   | optional                                                                                 |                                                                           |
| OTEL_TRACES_SAMPLER                     | Trace sampler strategy (`always_on`, `always_off`, `traceidratio`, `parentbased_traceidratio`).                                                                                                 | optional                                                                                 | always_on                                                                 |
| OTEL_TRACES_SAMPLER_ARG                 | Sampling argument used by ratio-based samplers (`0` to `1`).                                                                                                                                    | optional                                                                                 |                                                                           |
| OTEL_METRIC_EXPORT_INTERVAL             | How often metrics are exported via OTLP, in milliseconds. Set 15000 or lower when you alert on the AuthZed outbox.                                                                              | optional                                                                                 | 60000                                                                     |
| PROMETHEUS_ENABLED                      | Enables Prometheus metrics if set to 1.                                                                                                                                                         | optional                                                                                 |                                                                           |
| PROMETHEUS_EXPORTER_PORT                | Port for Prometheus metrics.                                                                                                                                                                    | optional                                                                                 | 9090                                                                      |
| AUTH_SSO_DEFAULT_TEAM_ID                | ID of the team that new SSO users are automatically added to. The owning organization is derived from this team. Must be set together with `AUTH_SKIP_INVITE_FOR_SSO=1` for auto-provisioning to work. | optional                                                                                 |                                                                           |
| AUTH_SKIP_INVITE_FOR_SSO                | Set to `1` to allow SSO users to create an account without a manual invite. Keep unset (or `0`) for stricter access control where only invited users can join.                                  | optional                                                                                 | 0                                                                         |
| HTTP_PROXY                              | HTTP proxy URL used for outbound requests (e.g., license checks). When both are set, `HTTPS_PROXY` takes precedence.                                                                            | optional                                                                                 |                                                                           |
| HTTPS_PROXY                             | HTTPS proxy URL used for outbound requests. Takes precedence over `HTTP_PROXY`.                                                                                                                 | optional                                                                                 |                                                                           |
| SENTRY_DSN                              | Set this to track errors and monitor performance in Sentry.                                                                                                                                     | optional                                                                                 |                                                                           |
| SENTRY_ENVIRONMENT                      | Set this to identify the environment in Sentry                                                                                                                                                  | optional                                                                                 |                                                                           |
| SENTRY_AUTH_TOKEN                       | Set this if you want to make errors more readable in Sentry.                                                                                                                                    | optional                                                                                 |                                                                           |
| SESSION_MAX_AGE                         | Configure the maximum age for the session in seconds.                                                                                                                                           | optional                                                                                 | 86400 (24 hours)                                                          |
| SINGLE_USE_LEGACY_UNSIGNED_UNTIL        | Grace window for single-use links issued before v6, which carry no `suToken` signature. An ISO 8601 date (`YYYY-MM-DD`); unsigned **encrypted** links are accepted until 00:00 UTC on it. While set, the instance accepts a single-use link that is bound to no survey, so one issued for one survey opens any other on the same instance — on a multi-tenant deployment that is cross-organisation. Leave unset unless you are re-issuing outstanding links, and see the [migration guide](/self-hosting/advanced/migration). | optional                                                                                 |                                                                           |
| USER_MANAGEMENT_MINIMUM_ROLE            | Set this to control which roles can access user management features. Accepted values: "owner", "manager", "disabled"                                                                            | optional                                                                                 | manager                                                                   |
| REDIS_URL                               | Redis URL for caching, rate limiting, audit logging, and the shared BullMQ background-job queue. All web and worker replicas must share this Redis instance. Application will not start without this. | required                                                                                 | redis://localhost:6379                                                    |
| REDIS_TLS_CA | Optional PEM CA bundle for private-CA `rediss://` connections. Applies only to Redis; include all active CAs during rotation and restart all consumers after changes. Certificate and hostname/IP verification remain enabled. | optional | |
| BULLMQ_WORKER_ENABLED                   | Set to `1` to start BullMQ workers inside each Formbricks web process. Set to `0` only in a custom deployment that already runs an external consumer with the complete Formbricks application job handlers. | optional                                                                                 | 1 outside test environments                                              |
| BULLMQ_EXTERNAL_WORKER_ENABLED          | Custom integrations only: set to `1` on web/API processes that only enqueue jobs while an external consumer with the complete Formbricks application job handlers processes them. This flag only keeps queueing enabled; it does not provide or start a worker. | optional                                                                                 | 0                                                                         |
| BULLMQ_WORKER_COUNT                     | Number of BullMQ worker instances to start in each Formbricks web process. Must be a positive integer.                                                                                          | optional                                                                                 | 1                                                                         |
| BULLMQ_WORKER_CONCURRENCY               | Number of jobs each in-process BullMQ worker can process concurrently. Must be a positive integer.                                                                                              | optional                                                                                 | 1                                                                         |
| AUDIT_LOG_ENABLED                       | Set this to 1 to enable audit logging. Also requires an active Enterprise license that includes audit logs, and Redis configured with the REDIS_URL env variable. | optional                                                                                 | 0                                                                         |
| AUDIT_LOG_GET_USER_IP                   | Set to 1 to include user IP addresses in audit logs from request headers                                                                                                                        | optional                                                                                 | 0                                                                         |
See [Job Runner](/self-hosting/configuration/job-runner) for BullMQ architecture, scaling, and
troubleshooting guidance.

#### Database TLS

To have Formbricks verify an external PostgreSQL server, add TLS settings to `DATABASE_URL`, and to
`MIGRATE_DATABASE_URL` if you set it:

```sh
DATABASE_URL=postgresql://formbricks:<password>@db.example.com:5432/formbricks?sslmode=verify-full&sslrootcert=/etc/ssl/postgres/ca.pem
```

- `sslmode=verify-full` checks that the server certificate chains to a trusted CA and matches the host name in
  the URL. Use it for any database you reach over a network.
- `sslrootcert` names the CA file that signed the server certificate, such as your cloud provider's bundle.
  Bundles with several certificates work. Mount the file read-only into the containers that run the app and the
  migrations. Without `sslrootcert`, the certificate must chain to a publicly trusted CA, or to a CA you add with
  `NODE_EXTRA_CA_CERTS` for the app and `SSL_CERT_FILE` for the migrations.
- Migrations treat `sslmode=verify-ca` like `verify-full`: the host name must match too. With `sslrootcert` and any
  `sslmode` other than `disable` or `no-verify`, they verify against that CA too. The app's connections behave the
  same way unless the URL sets `uselibpqcompat=true`, which makes them follow libpq: no host name check for
  `verify-ca`, and no certificate check for `prefer`. Migrations verify either way, so use `sslmode=verify-full`
  to keep both consistent.
- Migrations use TLS whenever the app's connections do: with any `sslmode` other than `disable`, or with
  `sslaccept` when no `sslmode` is set. They never fall back to an unencrypted connection.

If the migrations stop with Prisma error `P1011` while the app connects fine, the migration tool could not verify
the server where the app could (a CA added only through `NODE_EXTRA_CA_CERTS`, or an IP host without an IP entry in
the certificate). Fix the CA file or the host name. As a last resort, set `MIGRATE_DATABASE_URL` to the same URL
with `sslaccept=accept_invalid_certs`: schema migrations still require TLS but skip the certificate check, while the
app's connections, which use `DATABASE_URL`, keep whatever verification that URL sets. This does not help when the app's connections reject the certificate
too: the migration runner opens the same kind of connection, so fix the certificate setup first.

#### In-app surveys inside Formbricks

Formbricks includes its JavaScript SDK in the authenticated app so you can show surveys to your own
Formbricks users. Set `FORMBRICKS_WORKSPACE_ID` to the workspace that manages those surveys, and
`FORMBRICKS_APP_URL` to the instance hosting that workspace:

```dotenv
FORMBRICKS_WORKSPACE_ID=<your-workspace-id>
FORMBRICKS_APP_URL=https://formbricks.example.com
```

The workspace must belong to the instance at `FORMBRICKS_APP_URL`. If you omit the URL, the SDK connects
to `https://app.formbricks.com`. If you omit the workspace ID, the SDK is not initialized. No API key or
`IS_FORMBRICKS_CLOUD` setting is required to enable this integration.

When enabled, the SDK sends each signed-in user's ID, email address, first name, and last name to the
configured instance, or to `https://app.formbricks.com` if `FORMBRICKS_APP_URL` is unset. Choose an
instance that may receive these user details before enabling the integration.

For Docker Compose, add both variables to the app's `environment` configuration and recreate the app
container so the new values take effect. A Compose `.env` file alone does not pass additional variables
into the container.

<Note>
  Banners and feedback buttons use the same SDK integration, but the serving instance needs an active
  Enterprise license that includes [Creatives](/surveys/creatives/overview).
  Creatives are only available on self-hosted instances. Publish the creative in the configured workspace
  and ensure its display conditions and schedule match.
</Note>

#### OAuth and MCP URLs

The MCP server is available on the private/admin app at `/api/mcp`. OAuth discovery and token
issuance are also private/admin app surfaces:

```text
{WEBAPP_URL}/api/mcp
{WEBAPP_URL}/.well-known/oauth-protected-resource/api/mcp
{WEBAPP_URL}/.well-known/oauth-authorization-server/api/auth
```

If you use a custom subpath, include that subpath in both `WEBAPP_URL` and `BETTER_AUTH_URL`. Do not
point MCP or OAuth clients at `PUBLIC_URL`; that domain is reserved for public survey delivery and SDK
traffic.

#### Formbricks Hub

Starting with Formbricks v5, Hub is part of the standard self-hosted runtime. When you run Formbricks with the
bundled Docker Compose or Helm assets, the following variables apply:

| Variable         | Description                                                                        | Required | Default                                             |
| ---------------- | ---------------------------------------------------------------------------------- | -------- | --------------------------------------------------- |
| HUB_API_KEY      | API key used by the Formbricks Hub API. Generate a strong secret and use the same value wherever your deployment supplies Hub auth configuration. | required | (e.g. `openssl rand -hex 32`)                       |
| HUB_API_URL      | Base URL the Formbricks app uses to call Hub. With the bundled Docker stack, keep this at `http://hub:8080` unless Hub runs elsewhere.             | required | `http://hub:8080` (bundled Docker), `http://localhost:8080` (local dev) |
| HUB_DATABASE_URL | PostgreSQL connection URL for Hub. Omit to use the same database as Formbricks.    | optional | Same as Formbricks `DATABASE_URL` (shared database) |

#### SpiceDB Authorization

These variables define the supported SpiceDB client contract. Formbricks v6 requires SpiceDB by default
for fresh Docker, one-click, and Helm installations. Existing installations must pass the release-matched
upgrade gate before enabling the v6 application image.

| Variable            | Description                                                                                                      | Required at server startup | Default            |
| ------------------- | ---------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------ |
| AUTHZED_ENABLED     | Enables the required SpiceDB authorization engine.                                                              | required              | `true` in bundled Docker, Helm, and dev |
| AUTHZED_ENDPOINT    | SpiceDB gRPC endpoint as `host:port`. The default Helm-managed service is `formbricks-spicedb:50051`.             | required              | `spicedb:50051` in Docker; `localhost:50051` in dev |
| AUTHZED_TOKEN       | Preshared API token. Always load this from a secret.                                                             | required              |                    |
| AUTHZED_SYSTEM_KEY  | Stable namespace for Formbricks authorization objects and relationships.                                         | required              | `formbricks`       |
| AUTHZED_INSECURE    | Allows plaintext gRPC for an in-cluster service. Keep disabled for endpoints outside the trusted cluster network. | optional              | `true` in Helm and bundled Docker/dev |
| AUTHZED_CONSISTENCY | Must be `fully_consistent` for v6 authorization.                                                               | required              | `fully_consistent` in released Docker and Helm |

Stored survey visibility restrictions are always enforced. Projection readiness gates visibility mutations
and survey graph checks; before readiness, the PostgreSQL policy and workspace authorization apply
(see [AuthZed operations](/self-hosting/configuration/authzed-operations)). The following variables control
visibility mutations and workspace survey limits:

| Variable                         | Description                                                                                                                                             | Required | Default  |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- |
| SURVEY_VISIBILITY_FORCE_DISABLED | `1` disables visibility mutations. Stored survey restrictions remain enforced, including before projection readiness. Takes effect on restart. | optional | unset    |
| SURVEY_WORKSPACE_LIMIT           | Most surveys one workspace may hold, archived surveys included. Creating one past it answers `422 workspace_survey_limit_reached`.                        | optional | `10000`  |

Bundled Docker Compose requires `AUTHZED_DATABASE_PASSWORD` for its dedicated `spicedb` PostgreSQL login.
Generate both it and `AUTHZED_TOKEN` with `openssl rand -hex 32`. With the
[external SpiceDB PostgreSQL override](/self-hosting/configuration/spicedb-external-postgres), set
`SPICEDB_DATASTORE_CONN_URI` instead and omit `AUTHZED_DATABASE_PASSWORD`. The full PostgreSQL URI, including
TLS options such as `sslmode=verify-full`, reaches both the migration and runtime services. A private CA file
referenced by `sslrootcert` must be mounted read-only into both containers. `SPICEDB_IMAGE_REF` can override the
bundled `authzed/spicedb:v1.56.2` image for an explicitly reviewed upgrade; the migration and server services
always use the same reference.

The v6 server requires `AUTHZED_ENABLED=true` or `1`; unset, `false`, and `0` are rejected before it accepts
requests. `AUTHZED_INSECURE` accepts `true`, `false`, `1`, or `0`; when unset, it uses TLS. A configured endpoint must
be a bare `host:port` with an explicit port from 1 through 65535, for example `spicedb:50051`,
`grpc.authzed.com:443`, or `[::1]:50051`. Do not include a URL scheme, path, query, credentials, or whitespace.
`AUTHZED_SYSTEM_KEY` must be a 3–64 character lowercase SpiceDB identifier made from letters, digits, and
underscores; it must start with a letter or underscore and end with a letter or digit. The supported
consistency values accepted by diagnostic clients are `minimize_latency` and `fully_consistent`. Every v6
server requires an explicit `fully_consistent`; both server startup and the upgrade gate reject weaker consistency.

Builds and diagnostic CLI commands may parse disabled configuration without credentials. That does not make
disabled authorization a supported server mode: there is no PostgreSQL permission fallback. Startup reports
missing field names and setup guidance, never tokens. Retired shadow/cohort variables are not required.
Changing any AuthZed setting requires restarting the Formbricks process.

In a released Docker installation, validate the configured connection without installing a schema or changing
data:

```bash
docker compose --profile authzed-ops run --rm authzed-ops health
docker compose --profile authzed-ops run --rm authzed-ops upgrade check
```

For Helm, run `formbricks-authzed health` inside a Formbricks application pod. Repository development can keep
using `pnpm authzed:health`. See [AuthZed Operations](/self-hosting/configuration/authzed-operations) for the complete
Docker and Kubernetes command set, schema lifecycle, backups, and relationship repair.

Only the repository-development `pnpm authzed:health` command reads the repository `.env`. Docker Compose
uses the `authzed-ops` container environment, while Helm and Kubernetes use the Formbricks Pod environment.
Each invocation performs an authenticated read-only schema request, prints exactly one JSON result, and exits
`0` only for `{"status":"healthy","latencyMs":12}` (the latency varies). Disabled or failed checks exit `1`.
Failures use stable codes: `authzed_unauthenticated` or
`authzed_permission_denied` for rejected credentials or schema-read access (the bundled SpiceDB preshared-key
check reports a wrong token as permission denied), `authzed_timeout` when an attempt exceeds its deadline,
`authzed_overloaded` when SpiceDB is resource constrained, `authzed_unavailable` when the service cannot be
reached, and `authzed_internal` for an unexpected client failure. Schema text, tokens, raw SDK errors, and stack
traces are never included.

This check is intentionally a CLI rather than a browser page or HTTP endpoint. Startup validates configuration
without contacting SpiceDB. Connectivity is not part of the general `/health` response or Kubernetes readiness,
so a transient SpiceDB outage does not restart or mark the rest of Formbricks unhealthy.

Failed or unavailable permission checks fail the protected operation closed; there is no runtime fallback to
legacy authorization. Existing installations must complete `formbricks-authzed upgrade prepare` followed by
`upgrade check` before upgrading. The general application readiness probe remains independent from AuthZed so a
transient authorization outage does not restart unrelated Formbricks workloads.

#### Cube Analytics

Cube is part of the baseline Formbricks v5 stack and is required. Formbricks generates the backend
Cube JWT from `CUBEJS_API_SECRET`, so `CUBEJS_API_TOKEN` is not part of the supported setup contract.

| Variable                  | Description                                                                                            | Required | Default                              |
| ------------------------- | ------------------------------------------------------------------------------------------------------ | -------- | ------------------------------------ |
| CUBEJS_API_URL            | Base URL the Formbricks app uses to call Cube. Local dev (app on host): `http://localhost:4000`. Docker/container: `http://cube:4000` (service name). | required | |
| CUBEJS_API_SECRET         | Shared secret Formbricks uses to sign Cube API JWTs. Generate with `openssl rand -hex 32`.             | required |                                      |
| CUBEJS_JWT_ISSUER         | JWT issuer expected by Cube and used by Formbricks when signing per-request Cube tokens.               | optional | `formbricks-web`                     |
| CUBEJS_JWT_AUDIENCE       | JWT audience expected by Cube and used by Formbricks when signing per-request Cube tokens.             | optional | `formbricks-cube`                    |
| CUBEJS_DB_HOST            | Database host for the Cube service. Only needed when you run Cube yourself and override defaults.      | optional | Depends on your Cube deployment      |
| CUBEJS_DB_PORT            | Database port for the Cube service. Only needed when you run Cube yourself and override defaults.      | optional | Depends on your Cube deployment      |
| CUBEJS_DB_NAME            | Database name for the Cube service. Only needed when you run Cube yourself and override defaults.      | optional | Depends on your Cube deployment      |
| CUBEJS_DB_USER            | Database user for the Cube service. Only needed when you run Cube yourself and override defaults.      | optional | Depends on your Cube deployment      |
| CUBEJS_DB_PASS            | Database password for the Cube service. Only needed when you run Cube yourself and override defaults.  | optional | Depends on your Cube deployment      |

On Helm, the chart sets `CUBEJS_DB_HOST`, `CUBEJS_DB_PORT`, `CUBEJS_DB_NAME`, `CUBEJS_DB_USER` and
`CUBEJS_DB_PASS` for Cube from the `postgresql.*` values when the bundled database is enabled; set them in
`cube.env` to override. With an external database, set them yourself.

The bundled Docker Compose Cube service sets `CUBEJS_DEFAULT_API_SCOPES=meta,data` directly on the Cube
container. If you run Cube outside the bundled Compose stack, configure the equivalent Cube service environment
there rather than adding it to the Formbricks app environment.

The Cube service itself reads a few sizing settings. Set them on the Cube container (the `cube` service in
Compose, `cube.env` in Helm), not on the Formbricks app:

| Variable                    | Description                                                                                                                                                                          | Default        |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------- |
| CUBEJS_COMPILER_CACHE_SIZE  | How many compiled data models Cube keeps in memory. Each takes 2–5 MB; raise Cube's memory limit when you raise this.                                                                 | `60`           |
| CUBEJS_MAX_COMPILED_MEMBERS | Most members all compiled data models may hold together. Keep it in step with `CUBEJS_COMPILER_CACHE_SIZE` (about 500 per model).                                                    | `30000`        |
| CUBEJS_DB_QUERY_TIMEOUT     | How long one database query may run before Cube cancels it. The shipped Compose file and Helm chart set it.                                                                         | `60s`          |

With the bundled Docker Compose stack, PostgreSQL also needs more shared memory than Docker's 64 MB default for
answer filters on large datasets: the shipped `postgres` service sets `shm_size: 512mb`.

For Helm deployments, the chart deploys Cube by default (`cube.enabled: true`). To use an external Cube
cluster instead, set `cube.enabled: false`, point `CUBEJS_API_URL` at your endpoint, and supply
`CUBEJS_API_SECRET` through your existing secret management setup.

#### Workflow Webhook trigger behind a reverse proxy

A workflow's [Webhook Secret URL](/workflows/webhook-trigger) is served on `WEBAPP_URL`, not `PUBLIC_URL`, at
`/api/v3/workflows/<workflowId>/webhook/<token>`. If your admin domain is private, the outside systems that call
the URL must still be able to reach that path.

Configure the proxy in front of Formbricks to:

- **Set `X-Forwarded-Proto`.** Formbricks refuses Secret URL calls that didn't use HTTPS and reads the scheme from
  the first value of `X-Forwarded-Proto`. A proxy that ends TLS and doesn't send the header makes every call
  answer `403`. Set the header to the scheme the client used, replacing any value the client sent. Only if your
  proxy can't do this, and the network is fully private, set `DANGEROUSLY_ALLOW_WORKFLOW_PLAIN_HTTP=1`.
- **Append the client IP to `X-Forwarded-For`,** and set `TRUSTED_PROXY_HOP_COUNT` to the number of proxies that
  append to it. Formbricks records the caller's IP for each Webhook call and shows it in the trigger and in run
  detail. When it can't trust the header, no IP is recorded. The Webhook rate limits count calls per workflow and
  per organization, not per IP, so this setting doesn't change them.
- **Keep the token out of access logs.** The token in the path is a credential. Formbricks redacts it from its own
  logs and error reports, but your proxy, load balancer or CDN may log full request paths. Redact the last path
  segment of `/api/v3/workflows/*/webhook/*`, or don't log those paths. With the Helm chart, Secret URL calls reach
  Formbricks through your Ingress controller, not the chart's Envoy proxy, so set this up on the Ingress controller.
- **Accept request bodies of at least 100 KB,** the largest payload a Secret URL accepts.

For example, with nginx:

```nginx
# In the http block: log a Secret URL's path with its token replaced.
map $request_uri $redacted_request_uri {
  "~^(?<webhook_path>/api/v3/workflows/[^/]+/webhook/)[^/?]+(?<webhook_rest>.*)$" "${webhook_path}[redacted]${webhook_rest}";
  default $request_uri;
}
log_format redacted '$remote_addr - $remote_user [$time_local] '
                    '"$request_method $redacted_request_uri $server_protocol" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent"';

server {
  # …
  access_log /var/log/nginx/access.log redacted;

  location / {
    proxy_pass http://formbricks:3000;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}
```

nginx's error log has a fixed format: when nginx can't reach Formbricks or refuses a request, it writes the full
request line, token included. Keep the error log where only administrators can read it.

{/* prettier-ignore-end */}

Note: If you want to configure something that is not possible via above, please open an issue on our GitHub repo here or reach out to us on Github Discussions and we'll try our best to work out a solution with you.

## Apply configuration changes

Save runtime variables in Compose environment bindings or Kubernetes Secrets/values, then recreate or
roll out the application. `docker compose restart` does not load changed environment values.
Variables consumed at build time require a rebuilt image; changing only the runtime environment cannot
change assets already compiled into it. Follow each variable's documented scope.
