Docs · Reference

Environment variables

The settings a self-hosted copy reads from its environment, with their defaults. Set them in your compose file, or in a .env file when running from source. Magpie Cloud needs none of this. To get started, see Self-hosting.

Checked against magpiecrm@0.9.23 · Updated

Core and sign-in

VariableRequiredWhat it does
NODE_ENVYes, in productionSet to production. The app then refuses to sign or encrypt anything until TRACKING_SECRET or CREDENTIALS_SECRET is set, instead of using a development key.
AUTH_EMAILYesThe first login's email. Add more people in Settings, then Team and login.
AUTH_PASSWORDYesThe first login's password. Changing it resets that login's password on the next restart, for when it's forgotten.

Secrets

Generate each with openssl rand -hex 32. Secrets can't be changed in the app.

VariableRequiredWhat it does
TRACKING_SECRETYes, in productionSigns tracking and unsubscribe links, and encrypts the credentials saved in Settings. Set it once: rotating it makes saved credentials unreadable.
CREDENTIALS_SECRETNoA separate key for credentials saved in Settings: sending provider keys, the SocialFetch key, the verification secret and proxy passwords, and copilot API keys. Defaults to TRACKING_SECRET. Also set once.
SUPPRESSION_SECRETRecommendedKeys the hashes behind opt-outs, unsubscribes and bounces. Defaults to TRACKING_SECRET. Never rotate it: people who opted out would reappear.

URLs

VariableRequiredWhat it does
PUBLIC_URLRecommendedThis app's public origin, such as https://crm.example.com. Used for links others open: tracking and unsubscribe links, images in emails, survey links, webhook addresses. Unset: the host of the incoming request.
PUBLIC_SITE_URLNoYour website. The unsubscribe page shows a link back to it. Unset: no link.
SUBSCRIBE_ALLOWED_ORIGINSNoComma-separated origins whose pages may call POST /api/subscribe from the browser, such as https://example.com. Unset: none.

Prospect data

VariableRequiredWhat it does
SOCIALFETCH_API_KEYNoYour SocialFetch key (sfk_…). A key saved in Settings, then Data source takes priority.
SOCIALFETCH_BASE_URLNoThe SocialFetch API address. Default https://api.socialfetch.dev.
SOCIALFETCH_BALANCENohidden hides the SocialFetch credit balance; the sidebar shows this month's prospects instead.

Email verification

Connect your email verifier in Settings, then Email verification, with its server URL and secret. See Email verification.

Sending

A provider saved in Settings, then Sending takes priority. Its saved values win field by field, and these variables fill any field left empty. See Sending and deliverability.

VariableRequiredWhat it does
EMAIL_PROVIDERNoThe provider to use when none is saved in Settings, then Sending: smtp, ses, cloudflare, resend, postmark, sendgrid, mailgun, brevo or mailchimp. Unset: ses if the SES keys are set, else cloudflare if its token and account ID are set, else smtp. Only SMTP, SES and Cloudflare take credentials from variables; the rest are set up in Settings.
SMTP_HOSTNoSMTP server host.
SMTP_PORTNoSMTP port. Default 465.
SMTP_USERNoSMTP username.
SMTP_PASSNoSMTP password.
SMTP_SENDERNoA sender such as "Jane Smith" <jane@example.com>, added to Sender addresses on start and used as the default sender when none is set.
SES_REGIONNoAmazon SES region. Default us-east-1.
SES_ACCESS_KEY_IDNoAmazon SES access key ID.
SES_SECRET_ACCESS_KEYNoAmazon SES secret access key.
SES_CONFIGURATION_SETNoSES configuration set, needed for SES to publish bounce and complaint events.
SES_MESSAGE_TAGSNoname=value,… tags added to every email SES sends, and returned on its events.
CLOUDFLARE_ACCOUNT_IDNoCloudflare account ID.
CLOUDFLARE_API_TOKENNoCloudflare API token with Email Sending: Send, plus Analytics: Read for bounces.
CLOUDFLARE_ZONE_IDNoCloudflare zone ID. Turns on bounce polling.

Webhooks and bounces

VariableRequiredWhat it does
WEBHOOK_SECRETFor bounce trackingTurns on the bounce and complaint webhooks, which refuse every request until it's set. Providers send it as ?s= or a Bearer token.

For plain SMTP, the Cloudflare Email Worker in the repository's cloudflare-worker/ folder takes two variables of its own, set in Cloudflare: BOUNCE_WEBHOOK_URL (such as https://crm.example.com/api/webhooks/bounce) and the same WEBHOOK_SECRET.

AI copilot

VariableRequiredWhat it does
ANTHROPIC_API_KEYNoYour Anthropic API key for the copilot. A key saved in Settings, then Copilot is used first.
OPENAI_API_KEYNoYour OpenAI API key for the copilot. A key saved in Settings, then Copilot is used first.
COPILOT_CHROMIUM_PATHNoPath to a Chrome or Chromium the copilot uses to render email previews. The Docker image already includes one.

Web push

Generate a key pair with:

Terminal
npx web-push generate-vapid-keys
VariableRequiredWhat it does
VAPID_PUBLIC_KEYFor pushWeb push public key. Push is off unless both keys are set.
VAPID_PRIVATE_KEYFor pushWeb push private key.
VAPID_SUBJECTNoContact for push services. Default mailto: plus AUTH_EMAIL.

Server

VariableRequiredWhat it does
PORTNoPort to listen on. Default 3000.
HOSTNoAddress to listen on. Default 0.0.0.0.
DATABASE_PATHNoWhere the JSON data file lives. Uploaded images go in uploads/ next to it. Default local_db.json in the working directory; in Docker, put it on the volume, such as /data/db.json.
HOMEIn DockerSet to the volume's mount path, such as /data. The container gives its user ownership of $HOME at start, which makes the volume writable.

The README on GitHub has a commented sample .env file.

Something wrong or missing? Email pele@magpiecrm.com or open an issue.