Campaign Kit docs
v1.1.0
Get help
● Deploy · Environment

Configuration
every variable, explained.

All apps read one file: the repository-root .env. The API validates its variables at start-up and stops with a list of problems if one is invalid. The Mini App and admin read only VITE_* variables, and only at build time.

01API: required secrets

VariableRulePurpose / how to get it
ENCRYPTION_KEY64 hex charactersEncrypts each campaign's bot token at rest (AES-256-GCM). openssl rand -hex 32. Never change it once tokens are saved; if you must, paste every bot token again.
ADMIN_JWT_SECRET≥ 32 charactersSigns admin sessions (12 hours). openssl rand -hex 32. Changing it signs every admin out.
ABUSE_HASH_SALT≥ 16 charactersSalt for hashed IPs and user agents used by anti-bot, and for daily puzzle answer hashes. openssl rand -hex 16. Changing it breaks cluster matching with older data and invalidates every stored puzzle answer.

02API: URLs, network and behaviour

VariableDefaultPurpose
PUBLIC_API_URLhttp://localhost:8787Public URL of the API, e.g. https://api.example.com. Used for the Telegram webhook (registered only when it is https), the Adsgram Reward URL and the curl example of dev:initdata.
CORS_ORIGINShttp://localhost:5173,http://localhost:5174Comma-separated exact origins of the Mini App and the admin: scheme + host (+ port), for example https://admin.example.com. No path and no trailing slash: an entry such as https://admin.example.com/ stops the API at start-up with a message naming that entry. Admin changes from any other Origin are refused with forbidden_origin. Every host listed here is also accepted as a TON Connect proof domain.
ADMIN_PUBLIC_URLhttp://localhost:5174 in .env.examplePublic https URL of the hosted admin. Client report links are built as <ADMIN_PUBLIC_URL>/r/<token>. Optional, but it is validated at start-up: when set it must be a full URL, or the API refuses to start. If it is not set, the API falls back to the first entry of CORS_ORIGINS, which is usually the Mini App, and the links would be wrong, so always set it in production.
BROADCAST_WORKERon (true)Runs the bot broadcast worker inside the API process (ticks every second, at most 25 messages per second per bot). Allowed values: true or false (anything else stops the API at start-up); unset means on. Keep it on in exactly one API process.
DEMO_READ_ONLYoffSet true only on a public showcase install: the API refuses every change except admin sign-in and sign-out, the bot does not answer and the broadcast worker does not start. Never use it for a real campaign. See Read-only demo mode.
TON_NETWORKtestnettestnet or mainnet. Network for anti-bot wallet checks and the default for distributor deploy messages. Keep testnet until you have run a full airdrop there.
TONCENTER_API_KEYemptyYour own toncenter key. Turns on the wallet_fresh and wallet_shared_funder anti-bot signals. Empty: those checks are skipped and the report says so, never guessed.
TON_PROOF_DOMAINSemptyExtra hosts (host[:port], comma-separated) accepted as the TON Connect ton_proof domain. The campaign's Mini App host and every CORS_ORIGINS host are always accepted, so most installs leave this empty.
TRUST_PROXYfalsetrue (or 1) uses X-Forwarded-For as the client IP. Docker Compose sets it to true. Leave false when clients connect directly, otherwise they could fake their IP.
PORT8787API port.
DATABASE_URLpostgres://localhost:5432/campaign_kitPostgreSQL URL. Docker Compose sets it for you.

03Start-up checks

The API checks .env every time it starts.

Errors stop the API. If a value is invalid, the API prints one readable list of every problem and exits. Examples: ENCRYPTION_KEY that is not 64 hex characters, a CORS_ORIGINS entry with a path or a trailing slash, an ADMIN_PUBLIC_URL that is not a full URL, or a BROADCAST_WORKER other than true or false. Fix the listed lines and start it again.

Warnings in production. When the API runs with NODE_ENV=production (always the case in Docker), it starts but logs one warning line for each setting Telegram cannot use:

Warning aboutWhat it means
PUBLIC_API_URL is http or localhostTelegram does not deliver webhooks, so bot commands and Stars payments stay off. Use your public https API URL.
CORS_ORIGINS lists only localhost (or is empty)The hosted Mini App and admin cannot call the API. Add their https origins.
ADMIN_PUBLIC_URL missing or httpClient report links point to the wrong host or do not open for your clients. Set the admin's https origin.
TON_NETWORK=mainnet without TONCENTER_API_KEYOn-chain wallet checks are skipped and the anti-bot report says so. Add your own toncenter key.

With DEMO_READ_ONLY=true the API also logs a warning that the read-only demo mode is on.

04Deployment extras

VariablePurpose
POSTGRES_PASSWORDPassword of the Compose PostgreSQL. openssl rand -hex 24. Required by docker-compose.yml.
NODE_ENVDo not set it in .env. The runtime sets it (production in Docker). The web apps share .env, and putting it there breaks their builds. In production it also makes the admin cookie Secure.
MIGRATIONS_DIRSet inside the Docker image. Do not touch.
TEST_DATABASE_URLTests only. Default postgres://localhost:5432/campaign_kit_test.
E2E_DATABASE_URLE2E test only. Must end in /campaign_kit_e2e.
MINIAPP_DEV_URLDevelopment only: base URL printed by pnpm dev:initdata (default http://localhost:5173).

05Mini App (build time)

VariablePurpose
VITE_API_URLAPI origin, e.g. https://api.example.com. Empty = same origin.
VITE_PUBLIC_URLPublic https origin of the Mini App, e.g. https://play.example.com. Required for TON Connect (manifest) in production.
VITE_APP_NAME, VITE_APP_ICON_URLOptional. Name and icon wallets show in the connect dialog. Defaults: Campaign and <VITE_PUBLIC_URL>/icon.png.
VITE_TERMS_URL, VITE_PRIVACY_URLOptional links added to the TON Connect manifest.
VITE_DEFAULT_CAMPAIGNOptional slug used when the URL has no ?c= and no c_<slug> start parameter.
VITE_TWA_RETURN_URLOptional https://t.me/<bot>/<app> that wallets return to after signing. Default https://t.me/<bot>.
VITE_DEV_INIT_DATADevelopment only (output of pnpm dev:initdata). Ignored in production builds. Leave empty.

06Admin (build time)

VariablePurpose
VITE_ADMIN_API_URLAPI origin, e.g. https://api.example.com.
VITE_ADMIN_PUBLIC_URLPublic https origin of the admin, e.g. https://admin.example.com. Used for the admin's TON Connect manifest (deploying and funding the distributor).
Two variables, same value
ADMIN_PUBLIC_URL (read by the API for client report links) and VITE_ADMIN_PUBLIC_URL (baked into the admin build) are separate. In production both are the admin's https origin.

07What is not in .env

Everything per campaign lives in the database and is edited in the admin: bot token (encrypted), Mini App URL, branding, token and jetton master, economy, quests, shop, seasons, events, puzzles, fairness rules, ads settings and the Adsgram Reward URL secret (only its SHA-256 is stored). See Running a campaign.