Skip to content
Environment variables

Environment variables

This page lists every environment variable MicroB2B reads. They hold what MicroB2B needs before it can open its database. Everything else is stored in the database and changed in the web UI or the REST API.

Some settings are not environment variables:

  • Where message contents are stored, and other global settings, are in System > Settings. See settings.
  • Ports, directories and retry settings of receivers, senders and other parts are in their own configuration in the web UI.

Variables take effect when MicroB2B starts. After a change, restart MicroB2B.

For a key, you can give the value itself or, with the _FILE variant, the path of a file that holds it. Give one of the two, never both.

Required

VariableWhat it doesDefault
PUBLIC_URLThe address users reach MicroB2B at, such as https://b2b.example.com. HTTPS, no path. http only for localhost, 127.0.0.1 and ::1none, required
SESSION_KEY, SESSION_KEY_FILEKey of the sign-in cookies. Base64 or hex of at least 32 random bytesnone, required
SECRETS_KEY, SECRETS_KEY_FILEMaster key of stored secrets and private keys. Base64 or hex of exactly 32 random bytesnone, required

See required settings for how to generate them.

Sign-in

VariableWhat it doesDefault
SESSION_TTLHow long a sign-in lasts, from 5m to 72h8h

Database

VariableWhat it doesDefault
DB_TYPEsqlite3 or postgressqlite3
DB_URLWhere the database isfile:microb2b.db
DB_MAX_OPEN_CONNSPostgreSQL only: most open connections. 0 means no limit25
DB_MAX_IDLE_CONNSPostgreSQL only: idle connections kept. At most DB_MAX_OPEN_CONNS10
DB_CONN_MAX_LIFETIMEPostgreSQL only: close a connection after this age. 0 means never30m
DB_CONN_MAX_IDLE_TIMEPostgreSQL only: close a connection idle this long. 0 means never5m
BUNDEBUG1 or 2 logs every SQL statement. Needs LOG_LEVEL=debug. Failed statements are always loggednot set

See database.

Web server

VariableWhat it doesDefault
HTTP_PORTPort of the web UI and REST API, on every interface8080
ALLOWED_ORIGINSOther websites whose pages may call the REST API from a browser. Comma-separated, or * for allempty: none

See reverse proxy.

Secrets and audit log

VariableWhat it doesDefault
SECRETS_PREVIOUS_KEYS, SECRETS_PREVIOUS_KEYS_FILEEarlier master keys while you replace SECRETS_KEY. Separated by commas, spaces or new linesnot set
AUDIT_KEY, AUDIT_KEY_FILEMakes the audit log tamper-evident. Base64 or hex of at least 32 random bytesnot set: no hashes

MicroB2B refuses to start with an unknown variable that starts with SECRETS_ or AUDIT_. That catches typing errors. See secrets and audit log.

S3 payload storage

VariableWhat it doesDefault
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEYCredentials for S3 payload storagenot set

MicroB2B finds S3 credentials the way every AWS tool does. Instead of these variables, you can use the AWS credentials file or a role of the server. The bucket itself is a setting in System > Settings. See payload storage.

Logging

VariableWhat it doesDefault
LOG_LEVELdebug, info, warn or error. Anything else means infoinfo
LOG_STREAM_LEVELLowest level on the Logs page and in the OpenTelemetry export. Cannot be below LOG_LEVELinfo

OpenTelemetry

VariableWhat it doesDefault
OTEL_ENABLEDtrue sends traces, metrics and logsfalse
OTEL_EXPORTER_OTLP_ENDPOINTWhere to send them, host:port, over gRPC with TLSlocalhost:4317
OTEL_EXPORTER_OTLP_INSECUREtrue sends without TLSfalse
OTEL_EXPORTER_OTLP_HEADERSHeaders for every export, key=value,key2=value2. For Uptrace: uptrace-dsn=<DSN>not set
OTEL_SERVICE_NAMEName MicroB2B reports itself asmicrob2b
OTEL_SERVICE_VERSIONVersion it reportsthe program’s version

See monitoring.

Which commands read what

  • microb2b standalone reads all of the above.
  • microb2b users and microb2b service-accounts read the database variables. microb2b users also reads PUBLIC_URL, to print whole setup links.
  • microb2b secrets reads the database variables and the SECRETS_* variables.
  • microb2b audit reads the database variables and the AUDIT_* variables.

See the command line.