> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Environment variables

> Reference the environment variables used to configure Reporter, organized by category: HTTP server, database, storage, authentication, and telemetry.

This reference lists the environment variables used to configure **Reporter**, the service that generates regulatory, compliance, and accounting reports from configurable templates. Reporter ships as a single binary, and `RUN_MODE` selects its active surfaces: the API manager, the report worker, or both. You set these at deploy time, through Helm values, Docker Compose, or your orchestrator's environment. Variables marked as required cause the server to fail on startup if not set.

For the configuration blocks that every Lerian product shares (TLS posture, OpenTelemetry, Access Manager authentication, multi-tenancy, service discovery, and event streaming), see the [BYOC configuration reference](/en/reference/byoc-configuration). This page focuses on what is distinctive to Reporter.

## Run mode and ports

`RUN_MODE` decides which surfaces the process serves. Run the API and worker as one process (`all`) for small deployments, or split them into separate deployables (`api` and `worker`) to scale report generation independently. See the [health and readiness reference](/en/reference/health-and-readiness) for the probe contract.

| Variable                         | Description                                                                                                                                                               | Default | Required          |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----------------- |
| `RUN_MODE`                       | Surfaces to run: `api`, `worker`, or `all`                                                                                                                                | `all`   | No                |
| `SERVER_PORT` / `SERVER_ADDRESS` | API bind address (`RUN_MODE=api`/`all`), read from `SERVER_ADDRESS`; `SERVER_PORT` is the convention used to build it (`:4005`). Serves `/health`, `/readyz`, `/version`. | —       | Yes (`api`/`all`) |
| `HEALTH_PORT`                    | Worker health port (`RUN_MODE=worker`). Serves `/health`, `/readyz`.                                                                                                      | `4006`  | No                |

## Deployment and TLS

| Variable             | Description                                                                                                                                                                                                                                                | Default | Required |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------- |
| `DEPLOYMENT_MODE`    | Deployment flavor: `local`, `byoc`, or `saas`. In `saas`, TLS is mandatory for every dependency connection and the server refuses to start without it. In `byoc`, TLS is recommended and warned-on rather than enforced. Also tags the `/readyz` response. | `local` | No       |
| `ALLOW_INSECURE_TLS` | Bypass per-connection TLS enforcement on infrastructure DSNs. Leave unset or `false` in production.                                                                                                                                                        | `false` | No       |

## CORS and proxies

| Variable               | Description                                                                                 | Default | Required |
| ---------------------- | ------------------------------------------------------------------------------------------- | ------- | -------- |
| `CORS_ALLOWED_ORIGINS` | Allowed CORS origins (CSV, or `*`). Lock to explicit origins in production.                 | `*`     | No       |
| `CORS_ALLOWED_METHODS` | Allowed CORS methods                                                                        | varies  | No       |
| `CORS_ALLOWED_HEADERS` | Allowed CORS headers                                                                        | varies  | No       |
| `TRUSTED_PROXIES`      | Trusted proxy CIDRs for `X-Forwarded-For` parsing. Set when running behind a load balancer. | —       | No       |
| `SWAGGER_ENABLED`      | Serve the OpenAPI/Swagger UI                                                                | `false` | No       |

## API pagination

| Variable               | Description                                                                                                                    | Default | Required |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------- | -------- |
| `MAX_PAGINATION_LIMIT` | Largest `limit` a list operation accepts. A request above the ceiling is rejected with a pagination error rather than clamped. | `100`   | No       |

## Template previews

| Variable                 | Description                                                                                                                                                                                                                                                                                       | Default | Required |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------- |
| `PREVIEW_MAX_CONCURRENT` | Maximum synchronous template previews the API manager renders at once. When all slots are in use, Reporter rejects a new preview immediately with HTTP `429` and `RPT-0108`; it does not queue it. This is a concurrent-render limit, not a request-rate limit. Values below `1` use the default. | `4`     | No       |

## Database (MongoDB)

Stores report metadata, templates, and run history.

| Variable              | Description                                                            | Default   | Required |
| --------------------- | ---------------------------------------------------------------------- | --------- | -------- |
| `MONGO_URI`           | Connection scheme: `mongodb` or `mongodb+srv`                          | `mongodb` | No       |
| `MONGO_HOST`          | MongoDB host                                                           | —         | Yes      |
| `MONGO_PORT`          | MongoDB port                                                           | —         | Yes      |
| `MONGO_USER`          | Database user                                                          | —         | Yes      |
| `MONGO_PASSWORD`      | Database password. Sensitive.                                          | —         | Yes      |
| `MONGO_NAME`          | Database name                                                          | —         | Yes      |
| `MONGO_MAX_POOL_SIZE` | Maximum connection pool size                                           | varies    | No       |
| `MONGO_TLS_CA_CERT`   | Base64-encoded PEM CA certificate for TLS (for example AWS DocumentDB) | —         | No       |

## Message broker (RabbitMQ)

Carries the generate-report command queue between the API and the worker.

| Variable                         | Description                                                              | Default | Required                   |
| -------------------------------- | ------------------------------------------------------------------------ | ------- | -------------------------- |
| `RABBITMQ_HOST`                  | Broker host                                                              | —       | Yes                        |
| `RABBITMQ_PORT_AMQP`             | AMQP port                                                                | —       | Yes                        |
| `RABBITMQ_PORT_HOST`             | Management/HTTP port                                                     | —       | No                         |
| `RABBITMQ_URI`                   | Connection scheme: `amqp` or `amqps`. Use `amqps` in production.         | `amqp`  | No                         |
| `RABBITMQ_DEFAULT_USER`          | Broker user                                                              | —       | Yes                        |
| `RABBITMQ_DEFAULT_PASS`          | Broker password. Sensitive.                                              | —       | Yes                        |
| `RABBITMQ_EXCHANGE`              | Exchange where the API publishes report-generation commands              | —       | Yes (`api`/`all`)          |
| `RABBITMQ_GENERATE_REPORT_QUEUE` | Queue that carries report-generation commands from the API to the worker | —       | Yes (`api`/`worker`/`all`) |
| `RABBITMQ_GENERATE_REPORT_KEY`   | Routing key the API uses for report-generation commands                  | —       | Yes (`api`/`all`)          |
| `RABBITMQ_NUMBERS_OF_WORKERS`    | Worker consumer concurrency                                              | `5`     | No                         |

## Object storage (S3-compatible)

Where rendered reports are stored. Works with any S3-compatible endpoint.

| Variable                        | Description                                                       | Default            | Required |
| ------------------------------- | ----------------------------------------------------------------- | ------------------ | -------- |
| `OBJECT_STORAGE_ENDPOINT`       | S3-compatible endpoint URL                                        | —                  | Yes      |
| `OBJECT_STORAGE_REGION`         | Storage region                                                    | `us-east-1`        | No       |
| `OBJECT_STORAGE_BUCKET`         | Bucket for rendered reports                                       | `reporter-storage` | No       |
| `OBJECT_STORAGE_ACCESS_KEY_ID`  | Access key ID. Sensitive.                                         | —                  | Yes      |
| `OBJECT_STORAGE_SECRET_KEY`     | Secret access key. Sensitive.                                     | —                  | Yes      |
| `OBJECT_STORAGE_USE_PATH_STYLE` | Use path-style addressing (needed by some S3-compatible stores)   | `false`            | No       |
| `OBJECT_STORAGE_DISABLE_SSL`    | Disable TLS to the storage endpoint. Leave `false` in production. | `false`            | No       |

## Cache (Redis / Valkey)

| Variable            | Description                                                    | Default | Required |
| ------------------- | -------------------------------------------------------------- | ------- | -------- |
| `REDIS_HOST`        | Redis/Valkey host and port                                     | —       | Yes      |
| `REDIS_PASSWORD`    | Authentication password. Sensitive.                            | —       | No       |
| `REDIS_DB`          | Logical database index                                         | `0`     | No       |
| `REDIS_PROTOCOL`    | RESP protocol version                                          | varies  | No       |
| `REDIS_TLS`         | Enable TLS for the connection                                  | `false` | No       |
| `REDIS_CA_CERT`     | Base64-encoded PEM CA certificate for TLS                      | —       | No       |
| `REDIS_MASTER_NAME` | Sentinel master name (Sentinel deployments)                    | —       | No       |
| `REDIS_USE_GCP_IAM` | Authenticate to GCP Memorystore with IAM instead of a password | `false` | No       |

## PDF rendering (worker)

| Variable              | Description                             | Default | Required |
| --------------------- | --------------------------------------- | ------- | -------- |
| `PDF_POOL_WORKERS`    | Concurrent PDF render workers           | `2`     | No       |
| `PDF_TIMEOUT_SECONDS` | Per-report PDF render timeout (seconds) | `90`    | No       |

## Report datasources

Reports read from PostgreSQL and MongoDB datasources in the persisted registry. Create and manage those entries through the [data-source API](/en/reference/products/reporter/list-data-sources). The environment block below is an optional single-tenant bootstrap path. Multi-tenant deployments create datasources per tenant through the API.

`DATASOURCE_{NAME}_CONFIG_NAME` makes an environment seed block exist. Reporter scans for keys that match `DATASOURCE_*_CONFIG_NAME`. The prefix counts as much as the suffix, so a key that only ends in `_CONFIG_NAME` declares nothing. At Manager startup, a complete block seeds its `configName` only when no registry entry, including a soft-deleted one, already uses that name. The value is the name your templates use to address the source.

Within a block, the variables marked required are the ones Reporter needs before it reads the block.

| Variable                           | Description                                                                                                                                                                                                                                                                                | Default  | Required |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | -------- |
| `DATASOURCE_{NAME}_CONFIG_NAME`    | Name that templates use to address this datasource. Declares the block.                                                                                                                                                                                                                    | —        | Yes      |
| `DATASOURCE_{NAME}_TYPE`           | Datasource engine: `postgresql` or `mongodb`                                                                                                                                                                                                                                               | —        | Yes      |
| `DATASOURCE_{NAME}_HOST`           | Datasource host                                                                                                                                                                                                                                                                            | —        | Yes      |
| `DATASOURCE_{NAME}_PORT`           | Datasource port                                                                                                                                                                                                                                                                            | —        | Yes      |
| `DATASOURCE_{NAME}_DATABASE`       | Database name                                                                                                                                                                                                                                                                              | —        | Yes      |
| `DATASOURCE_{NAME}_USER`           | Datasource user                                                                                                                                                                                                                                                                            | —        | No       |
| `DATASOURCE_{NAME}_PASSWORD`       | Datasource password. Sensitive.                                                                                                                                                                                                                                                            | —        | No       |
| `DATASOURCE_CRED_ENC_KEY`          | Persistent hex-encoded AES key shared by Manager and worker to encrypt and decrypt registry credentials. Keep it unchanged across restarts and deployments; changing it prevents them from decrypting credentials already stored in the registry. Generate it with `openssl rand -hex 32`. | —        | Yes      |
| `DATASOURCE_{CONFIG_NAME}_SCHEMAS` | Schemas to expose from the datasource (CSV). This key uses the uppercased `CONFIG_NAME` value, unlike the other keys in the block.                                                                                                                                                         | `public` | No       |
| `DATASOURCE_{NAME}_SSLMODE`        | SSL mode for a PostgreSQL connection                                                                                                                                                                                                                                                       | —        | No       |
| `DATASOURCE_{NAME}_SSLROOTCERT`    | Path to the PostgreSQL SSL root certificate                                                                                                                                                                                                                                                | —        | No       |
| `DATASOURCE_{NAME}_SSL`            | Enable TLS on a MongoDB connection                                                                                                                                                                                                                                                         | —        | No       |
| `DATASOURCE_{NAME}_SSLCA`          | Path to the MongoDB CA certificate file                                                                                                                                                                                                                                                    | —        | No       |
| `DATASOURCE_{NAME}_OPTIONS`        | Extra MongoDB URI options                                                                                                                                                                                                                                                                  | —        | No       |
| `CRYPTO_HASH_SECRET_KEY_CRM`       | Hashing key to read CRM datasource PII. Sensitive.                                                                                                                                                                                                                                         | —        | No       |
| `CRYPTO_ENCRYPT_SECRET_KEY_CRM`    | Encryption key to read CRM datasource PII. Sensitive.                                                                                                                                                                                                                                      | —        | No       |

A complete per-datasource seed block follows. Set the global `DATASOURCE_CRED_ENC_KEY` separately as described above. We recommend using the same name for `CONFIG_NAME` and `{NAME}`, with the environment-variable segment uppercased (for example, `ONBOARDING` for `CONFIG_NAME=onboarding`). That keeps the schema key intuitive, because `SCHEMAS` uses the `CONFIG_NAME` value as its key while every other field uses `{NAME}`:

```bash theme={null}
DATASOURCE_ONBOARDING_CONFIG_NAME=onboarding
DATASOURCE_ONBOARDING_TYPE=postgresql
DATASOURCE_ONBOARDING_HOST=midaz-postgres-replica
DATASOURCE_ONBOARDING_PORT=5702
DATASOURCE_ONBOARDING_DATABASE=onboarding
DATASOURCE_ONBOARDING_USER=reporter
DATASOURCE_ONBOARDING_PASSWORD=<secret>
DATASOURCE_ONBOARDING_SCHEMAS=public
```

A template then addresses that source by its config name, as in `{{ onboarding.accounts }}`. Use the API to add or update a datasource. In single-tenant mode, an environment block only seeds a previously absent entry. It never overwrites an API-managed entry or restores a soft-deleted one.

## Shared configuration backbone

The following blocks are identical across Lerian products. The [BYOC configuration reference](/en/reference/byoc-configuration) documents them in full. They default off.

* **Access Manager authentication**: `PLUGIN_AUTH_ENABLED`, `PLUGIN_AUTH_ADDRESS`. Enable in production.
* **Multi-tenancy**: `MULTI_TENANT_*`, plus `RABBITMQ_MULTI_TENANT_SYNC_INTERVAL` and `RABBITMQ_MULTI_TENANT_DISCOVERY_TIMEOUT`. Off by default.
* **Service discovery**: `SD_*` (Consul, and Reporter also accepts the legacy `SD_ADVERTISE_*` / `CONSUL_ADDR` aliases). Off by default.
* **Event streaming**: `STREAMING_ENABLED`, `STREAMING_BROKERS`, `STREAMING_CLOUDEVENTS_SOURCE`, plus `RABBITMQ_REPORT_EVENTS_EXCHANGE` for the events exchange. Off by default.
* **OpenTelemetry**: `ENABLE_TELEMETRY`, `OTEL_*`, `OTEL_INSECURE_EXPORTER`. Telemetry is OTLP push.
