# Configuration

> Every environment variable the stack reads, grouped by service, with what breaks without it.

URL: https://chatwork.io/en/docs/configuration
Section: Reference

Values live in `infra/.env` (never committed). The bridge refuses to start in production (`APP_ENV=production`) when `DOT_ADMIN_API_KEY`, `CHATWOOT_WEBHOOK_SECRET` or `DOT_WIDGET_SIGNING_KEY` are shorter than 32 characters or look like placeholders.

## Edge and site

| Variable | Meaning |
|---|---|
| `PLATFORM_DOMAIN` | apex domain; Caddy serves `www.`, `app.`, `api.`, `chat.` under it |
| `ACME_EMAIL` | Let's Encrypt contact |

## chatwork

`SECRET_KEY_BASE`, `POSTGRES_DB`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `REDIS_PASSWORD`, `CHATWOOT_PUBLIC_URL` (`https://chat.<domain>`). Mail and storage variables follow chatwork's own documentation.

## Bridge — core

| Variable | Meaning |
|---|---|
| `APP_ENV` | `development` or `production` |
| `DOT_PUBLIC_BASE_URL` | `https://<domain>`; agent-bot webhook and widget origin are built from it |
| `DOT_ALLOWED_ORIGINS` | CORS allowlist (portal origin + customer sites) |
| `DOT_ADMIN_API_KEY`, `CHATWOOT_WEBHOOK_SECRET`, `DOT_WIDGET_SIGNING_KEY` | access-control secrets (≥ 32 chars) |
| `DOT_CREDENTIALS_KEY` | Fernet key for secrets at rest |
| `DOT_STORAGE_BACKEND` | `redis` (default) or `postgres` |
| `DOT_DATABASE_URL` | bridge database URL; required by Chatwork Router and the built-in knowledge base |
| `UVICORN_FORWARDED_ALLOW_IPS` | proxy IPs trusted for `X-Forwarded-*` |

## Bridge — signup and languages

| Variable | Default | Meaning |
|---|---|---|
| `DOT_SIGNUP_MODE` | `open` | `open`, `code` (requires `DOT_SIGNUP_CODE`) or `closed` |
| `DOT_SIGNUP_CODE` | — | shared code for `code` mode; without it `code` behaves as `closed` |
| `DOT_SIGNUP_TRIAL_DAYS` | `14` | trial length for self-service signups; `0` starts in `pending_payment` |
| `DOT_SIGNUP_DAILY_CAP` | `50` | platform-wide signups per day (bounds trial cost); `0` disables the cap |
| `DOT_DEFAULT_LOCALE` | `ar` | language of unprefixed portal and sign-in paths |
| `DOT_SITE_URL` | `https://chatwork.io` | marketing site origin (terms and privacy links on the signup page) |

## Bridge — chatwork and channels

`CHATWOOT_BASE_URL` (internal, `http://chatwoot-rails:3000`), `CHATWOOT_ACCOUNT_ID`, `CHATWOOT_INBOX_ID`, `CHATWOOT_ADMIN_API_TOKEN`, `CHATWOOT_BOT_TOKEN`, `CHATWOOT_PLATFORM_TOKEN`; X: `X_API_KEY`, `X_API_SECRET`, `X_ACCESS_TOKEN`, `X_ACCESS_TOKEN_SECRET`, `X_BEARER_TOKEN`, `X_BOT_USER_ID`, `X_POLL_INTERVAL_SECONDS`, `X_REPLY_MIN_DELAY_SECONDS`, `X_REPLY_MAX_DELAY_SECONDS`, `ENABLE_X_DIRECT_DISPATCH`.

## Bridge — AI and Chatwork Router

| Variable | Default | Meaning |
|---|---|---|
| `DOT_LLM_BASE_URL` | `https://api.openai.com/v1` | OpenAI-compatible endpoint |
| `DOT_LLM_API_KEY`, `DOT_LLM_MODEL` | — / `gpt-4o-mini` | provider key and chat model |
| `DOT_SYSTEM_PROMPT`, `DOT_HANDOFF_KEYWORDS` | file defaults | tenant-independent overrides |
| `CLOUDRAG_ENABLED` | `true` | turn the store-backed layers off (lexical routing stays) |
| `CLOUDRAG_EMBEDDINGS` | `off` | `off` (built-in knowledge base, no outside call) or `provider` (enable semantic vectors) |
| `CLOUDRAG_EMBEDDING_MODEL` | `text-embedding-3-small` | embeddings model at the same endpoint |
| `CLOUDRAG_EMBEDDING_DIM` | `1536` | must match the `vector(1536)` columns |
| `CLOUDRAG_TOP_K` | `4` | default passages per grounded reply |
| `CLOUDRAG_LOG_DECISIONS` | `true` | write the routing log |
| `CLOUDRAG_REGISTRY_DIR` | bundled | override the registry location |
| `PRICING_CATALOG_FILE` | bundled | override the location of `pricing/catalog.json` |

## Bridge — money and commerce

`SELLER_NAME`, `SELLER_VAT_NUMBER`, `SELLER_CR_NUMBER`, `SELLER_ADDRESS`, `DOT_PLANS_JSON`, `MOYASAR_SECRET_KEY`, `MOYASAR_PUBLISHABLE_KEY`, `MOYASAR_WEBHOOK_SECRET`, `MOYASAR_LIVE`, `SALLA_CLIENT_ID`, `SALLA_CLIENT_SECRET`, `SALLA_WEBHOOK_SECRET`, `ZID_CLIENT_ID`, `ZID_CLIENT_SECRET`, `ZID_WEBHOOK_SECRET`, `ticket_sla_first_response_minutes`, `ticket_sla_resolution_minutes`.
