Environment variables
What each setting in the Closeline API's and the frontends' .env files does, which ones you need, and the Docker Compose options.
For the Full Stack package
Where the settings live
| File | Read by | Holds secrets |
|---|---|---|
back-end/.env | The API, with yarn dev and inside Docker Compose | Yes. Never commit it. |
dashboard/.env | The CRM dashboard, at build time (and PORT when it starts) | No. Every value is public. |
website/.env | The website, at build time | No. Every value is public. |
.env beside docker-compose.yml | Docker Compose, for the full stack: ports, addresses, the first start | Only the first account's password |
Create each app's file from the .env.example beside it, which documents every variable: cp .env.example .env. The examples work as they are for a local run.
Where the settings live
One file, .env in the website's folder, read when the website is built. Every value in it is optional and public, so it never holds a secret. Create it from .env.example, which points at an API on http://localhost:8000/api and a dashboard on http://localhost:3031: cp .env.example .env. With no .env, or NEXT_PUBLIC_API_BASE_URL empty, the website runs on its built-in sample data.
Where the settings live
One file, .env in the dashboard's folder, read when the dashboard is built, and for PORT when it starts. Every value in it is public, so it never holds a secret: payment and AI keys live in the API's settings. Create it from .env.example, which points at an API on http://localhost:8000/api: cp .env.example .env. With no .env, or NEXT_PUBLIC_API_BASE_URL empty, the dashboard runs on its built-in sample data.
Where the settings live
One file, .env in the API's folder, read by the API with yarn dev and yarn start:prod. It holds secrets: never commit it. Create it from .env.example, which documents every variable and works as it is for a local run: cp .env.example .env.
The Docker image sets its own defaults, so docker run works without a file: NODE_ENV=production, SQLite at /data/database.sqlite, uploads in /data/uploads, CORS_ORIGIN for the two local frontends, the local addresses and SEED_SAMPLE_DATA=true. Override any of them with -e, one value each, rather than --env-file with a copy of .env.example.
API essentials
The API checks JWT_SECRET and, in production, CORS_ORIGIN before it starts. If one is missing or unusable, it stops with one line saying what to fix.
| Variable | What it does |
|---|---|
NODE_ENV | development locally, which creates and updates the tables on start. production on a server, which never touches the tables. |
PORT | The API's port, 8000. Both frontends point at it. |
DB_TYPE | sqlite (as in .env.example) or mysql. |
SQLITE_DATABASE | Path of the SQLite file, ./database.sqlite, relative to the API's folder. |
JWT_SECRET | Signs every sign-in. Required. The example value is accepted outside production only. |
JWT_EXPIRATION | How long a sign-in lasts, 7d. |
CORS_ORIGIN | The website's and the dashboard's addresses, comma separated. Unset, only http://localhost:3030 and http://localhost:3031 are allowed; required in production. |
FRONTEND_URL | The dashboard's address, the only origin its live permission updates are accepted from. |
DASHBOARD_URL | The dashboard's address, written into invitation and password-reset links, billing notices and the pages a checkout returns to. |
PUBLIC_API_URL | This API as the browser reaches it, for the signed invoice download links. |
PUBLIC_MEDIA_URL | The address /media is reached at from a browser, http://localhost:8000/media. |
MEDIA_UPLOAD_DIR | Where uploads are written when no bucket is set, ./public/media/uploads. |
RATE_LIMIT_LOGIN | Failed sign-ins one address may make in 15 minutes before 429, 10. |
TRUST_PROXY | The number of reverse proxies in front of the API (1 behind Nginx, Caddy or a load balancer, 2 with Cloudflare in front of that), so the sign-in limit counts the real visitor. Empty when the API is reached directly. |
Generate your own JWT_SECRET with:
node -e "console.log(require('crypto').randomBytes(48).toString('hex'))"A start without the sample accounts
| Variable | What it does |
|---|---|
SEED_SAMPLE_DATA | Docker only, on a new volume: true (the default) seeds the sample workspace and its published sign-ins, false starts it empty. |
ADMIN_EMAIL, ADMIN_PASSWORD | Your first account, created by yarn admin:create (or on the first Docker start with SEED_SAMPLE_DATA=false), with a workspace of its own and the installation's Platform admin role. The password needs 8 to 128 characters. |
ADMIN_NAME | Optional: that account's name, Workspace Admin when empty. |
ADMIN_WORKSPACE | Optional: its workspace's name, named after the first name when empty. |
With the full stack's Docker Compose, set these in the .env beside docker-compose.yml: compose passes them from there, not from back-end/.env.
Use MySQL instead of SQLite
Create an empty database, then set the driver and the connection in the API's .env:
DB_TYPE=mysql
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=your-password
DB_DATABASE=closelineThen run yarn seed for the sample workspace, or yarn admin:create for your own first account with no sample data; both create the tables. The running API only creates and updates the tables itself when NODE_ENV=development, so with NODE_ENV=production one of those commands runs before the first start (yarn seed:prod or yarn admin:create:prod after yarn build), and yarn schema:prod after an update. The Docker image creates the database by itself on SQLite only.
Website and dashboard
Every NEXT_PUBLIC_* value is compiled into the JavaScript the browser loads, and anyone who opens the page can read it. Never put a secret in these files, and restart yarn dev or build again after changing one. With Docker, pass them as --build-arg.
| Variable | App | What it does |
|---|---|---|
NEXT_PUBLIC_API_BASE_URL | Both | The API's address including /api, http://localhost:8000/api in .env.example and the Docker builds. Empty, the app runs on its built-in sample data with no API. |
NEXT_PUBLIC_WEBSOCKET_BASE_URL | Dashboard | The API's address without /api, for live permission updates. Empty uses NEXT_PUBLIC_API_BASE_URL without its /api. |
NEXT_PUBLIC_BASE_URL | Dashboard | The dashboard's own public address, http://localhost:3031: robots.txt, the sitemap and the page metadata. |
NEXT_PUBLIC_WEBSITE_URL | Dashboard | The website, http://localhost:3030: the sidebar's Help link, the sign-up page's Privacy and Terms links and the way back to the website from the sign-in pages. |
PORT | Dashboard | The port yarn dev and yarn start use, 3031. |
NEXT_PUBLIC_SITE_URL | Website | The website's public address, http://localhost:3030: canonical links, language alternates, the sitemap and the sharing cards. |
NEXT_PUBLIC_DASHBOARD_URL | Website | The dashboard, http://localhost:3031: Sign in, Start free, the plans' Choose buttons and the /start, /auth/ and /demo addresses hand over to it. |
API_INTERNAL_URL | Website | Optional, server only, read when it starts. Where the website's own server reaches the API when the browser's address does not work from inside it, as in Docker Compose (http://api:8000/api). Empty uses NEXT_PUBLIC_API_BASE_URL. |
NEXT_PUBLIC_SAMPLE_DATA_NOTICE | Website | Optional. always also shows the "Sample data" notice in a production build while a configured API is not answering. |
BUILD_STANDALONE | Both | Build only: true makes yarn build write a self-contained server into .next/standalone, which the Dockerfiles set. Leave it unset for yarn start. |
The website's port is 3030 in its package.json: for another, run yarn next dev -p <port>, or yarn next start -p <port> after yarn build. AI provider keys and payment keys never go in a frontend: they live in the API's .env only.
Ports
With the full stack in Docker, three variables in the .env beside docker-compose.yml set the ports on your computer. Change one when another program already uses it, such as ADMIN_PORT=3041, and run docker compose up --build again.
| Variable | Default | App |
|---|---|---|
SITE_PORT | 3030 | The website |
ADMIN_PORT | 3031 | The CRM dashboard |
API_PORT | 8000 | The API |
Every address built from them follows by itself: the API's CORS_ORIGIN, FRONTEND_URL, DASHBOARD_URL, PUBLIC_API_URL and PUBLIC_MEDIA_URL, and the frontends' API and dashboard addresses. Inside its container each app keeps its own port, so the API's start-up line still says http://localhost:8000/api; the browser address follows API_PORT.
- One app with `docker run`: change the number on the left of
-p, such as-p 3041:3031. A frontend on a new address is built again with its own address (NEXT_PUBLIC_BASE_URLfor the dashboard,NEXT_PUBLIC_SITE_URLfor the website) and added to the API'sCORS_ORIGIN; the dashboard's is also the API'sFRONTEND_URLandDASHBOARD_URL. The API on a new port getsPUBLIC_API_URLandPUBLIC_MEDIA_URLto match, and both frontends are built withNEXT_PUBLIC_API_BASE_URLpointing at it. - Without Docker:
PORTin the API's.envand in the dashboard's.env, and-pfor the website, with the same addresses changed to match.
Docker Compose options
Nothing has to be set for a local run. To change something, put it in a .env file beside docker-compose.yml and run docker compose up --build again: the frontends compile these values in.
| Variable | Default | What it does |
|---|---|---|
SITE_PORT, ADMIN_PORT, API_PORT | 3030, 3031, 8000 | The ports on your computer, as above. |
SITE_URL, ADMIN_URL, API_URL | The local addresses on those ports | Where the browser reaches each app. Set all three when serving the stack on your own domains, such as API_URL=https://api.your-domain.com. |
SEED_SAMPLE_DATA | true | false starts a new volume without the sample data. It matters only on a new volume. |
ADMIN_EMAIL, ADMIN_PASSWORD, ADMIN_NAME, ADMIN_WORKSPACE | Empty | With SEED_SAMPLE_DATA=false, your first account, created on the first start; left empty, only the tables are created. |
The API container also reads back-end/.env when it exists, so Stripe, mail, the bucket, the assistant's keys and the MCP key are set in one place for both yarn dev and Docker. The compose file wins for the values that differ inside a container: the database path, the upload folder, the port, NODE_ENV=production, the addresses above and demo mode, which it keeps off. The database and the uploads live in the closeline-data volume.
File storage
Deal files, project files, profile pictures and chat attachments are stored on the API's disk under MEDIA_UPLOAD_DIR and served at /media/uploads/…, unless a bucket is set. The brand files and artwork the API serves itself live in public/media/closeline. On a server, point MEDIA_UPLOAD_DIR at persistent storage; with Docker it is in the data volume. A file is at most 10 MB.
To send uploads to a Cloudflare R2 bucket, set all five variables:
R2_ACCESS_KEY_ID=your-r2-access-key-id
R2_SECRET_ACCESS_KEY=your-r2-secret-access-key
R2_ENDPOINT=https://your-account-id.r2.cloudflarestorage.com
R2_BUCKET_NAME=your-bucket-name
R2_PUBLIC_URL=https://your-public-url.r2.devBilling
With none of these set, every plan is paid for in the built-in test checkout, which moves no money.
| Variable | What it does |
|---|---|
STRIPE_SECRET_KEY | Stripe Checkout, plan changes on the card on file and the customer portal. A sk_test_ key while you try it. |
STRIPE_WEBHOOK_SECRET | Verifies POST /api/billing/webhooks/stripe. Without it renewals and failed payments are not recorded. |
BILLING_PROVIDER | simulator keeps the test checkout even with a Stripe key. |
BILLING_GRACE_DAYS | Days a past-due workspace, or one whose trial ended unpaid, may still invite people, 7. |
What each plan includes is not an environment variable or a platform setting: it is PLAN_FEATURE_MAP in back-end/src/modules/billing/constants/plans.constants.ts, in the code beside the prices.
The API sends invitations, password resets, billing notices and contact form messages through your SMTP server. Leave SMTP_HOST empty and every message is written to the API's log instead, links included.
SMTP_HOST=smtp.your-provider.com
SMTP_PORT=587
SMTP_SECURE=false
SMTP_USER=your-smtp-user
SMTP_PASSWORD=your-smtp-password
SMTP_FROM=Closeline <no-reply@your-domain.com>
CONTACT_INBOX=sales@your-domain.comSMTP_FROM is the sender: your product's name and an address on your own domain. Left empty, it is the product's name from the site_name platform setting with no-reply@localhost. CONTACT_INBOX is where the website's contact messages are forwarded; empty keeps them in the database only. Links in a message open the dashboard at DASHBOARD_URL.
Invitations, password resets and billing notices are written in the recipient's language, English or Arabic: the language the account chose, otherwise the workspace's language (for a reset, the language the reset was asked in).
Platform settings
A few settings live in the database rather than in .env, seeded with these values and shared by every workspace:
| Key | Seeded value | What it does |
|---|---|---|
site_name | Closeline | The product's name in what the API writes: email subjects (and the sender when SMTP_FROM is empty), invoice PDFs, the Stripe product, the reports export and the assistant. |
trial_days | 14 | How many days a new workspace trials. A value that is not a whole number above 0 counts as 14. |
signups_enabled | true | false closes the sign-up page: POST /api/auth/signup answers 403. |
maintenance_mode | false | true closes the product to everyone but platform staff, with a notice; every route answers 503 to the others. |
support_email | support@closeline.example | The support address the assistant gives. |
site_tagline, notification_email | CRM for small sales teams, an address at closeline.example | Kept for your own use; the API does not read them. |
The dashboard has no page for them. A Platform admin changes one through the API: sign in with POST /api/auth/login, then send one PATCH /api/settings/<key> with the access_token it answers and the value as text, numbers and switches included. It needs the settings.edit permission. A 30-day trial:
curl -X PATCH http://localhost:8000/api/settings/trial_days \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"value":"30"}'| To | Send to PATCH /api/settings/... |
|---|---|
| Close sign-ups | signups_enabled with {"value":"false"} |
| Turn maintenance on, then off | maintenance_mode with {"value":"true"}, later {"value":"false"}. Platform staff keep signing in and working while it is on. |
| Rename the product | site_name with {"value":"Your Product"} |
- A change applies to the next request, and running
yarn seedagain keeps every value you set. GET /api/settings(settings.view) lists them all, andGET /api/settings/<key>reads one.- The dashboard's sign-up page reads the trial length from the API, so it follows
trial_days. The website states it fromTRIAL_DAYSinwebsite/src/config/plans.ts: change that withtrial_days.
AI assistant keys
Included with your purchase. Sign in to read, or open it in your download.
Turning on the AI assistant: where each provider's key goes and how it is billed.
The MCP server
Included with your purchase. Sign in to read, or open it in your download.
Letting coding agents use the CRM tools: the key, the workspace they read and the endpoint.
Demo mode
Included with your purchase. Sign in to read, or open it in your download.
Running a public demo: the demo switches, per-visitor workspaces and their limits.
Going live
Before you deploy anywhere public, set NODE_ENV=production, your own JWT_SECRET and the real addresses on the API, build each frontend with your API's address, start without the sample data or change the sample passwords, and keep demo mode off.