Health and readiness
GET /health reports liveness. It answers 200 while the process runs, and it does not check dependencies.
GET /readyz runs the dependency checks. It answers 200 when the service can take traffic, and 503 when it cannot or while it shuts down. It reuses a result for 250 milliseconds.
/readyz does not call BC Correio. To check the link to BC Correio, call POST /settings/test-connection.
GET /version returns the build version of the service.
BACEN request quota and circuit breaker
Lerian BC Correios limits its calls to BC Correio per Sisbacen credential:
BC_CORREIO_RATE_LIMIT_PER_MINUTEcalls per minute, 50 by default.BC_CORREIO_RATE_LIMIT_PER_HOURcalls per hour, 2700 by default.
BC_CORREIO_RATE_LIMIT_MAX_WAIT_SEC seconds for a free slot, 90 by default.
Lerian BC Correios has one circuit breaker for BC Correio. Five failures in a row open it. After 30 seconds, it lets calls reach BC Correio again. A successful call closes it.
Credentials and keys
ENCRYPTION_KEY holds the AES-256-GCM key that encrypts the BC Correio credentials, the AI API keys, and the stored idempotency answers. It takes exactly 32 bytes. Outside the development environment, the service does not start without it.
After ENCRYPTION_KEY changes, the stored credentials and the stored AI key no longer decrypt. Lerian BC Correios then skips its polling cycles, so no new BACEN mail arrives, and the automatic AI analysis stops. A send returns 422 BCC-2007. /readyz stays green. Enter the credentials and the AI key again in your settings.
Event broker, storage and retention
Lerian BC Correios stores mail in PostgreSQL. It stores attachments in S3-compatible object storage, or on the local filesystem when
OBJECT_STORAGE_PROVIDER is local.
Lerian BC Correios needs a Kafka broker in every environment. The service does not start without STREAMING_BROKERS. It publishes its events to the topic lerian.streaming.br-correios, and to lerian.streaming.br-correios.dlq for dead letters.
By default, the service asks the broker to create both topics at startup. A broker credential without the permission to create topics produces a warning, and the service starts. If you create the topics yourself, set STREAMING_TOPIC_AUTO_PROVISION to false and create both topics before the first event.
The service writes an event that it must not lose to a PostgreSQL table, in the same transaction as the change that caused it. A relay publishes it to Kafka. When the broker is down, the service keeps running. The relay retries an event for 7 days. It deletes published events after STREAMING_OUTBOX_RETENTION_DAYS days, 7 by default.
The retention worker runs once every 24 hours and applies your retention period.
The service does not apply its own database schema. A separate migration step applies it before the service starts.
Metrics and tracing
Set
TRACING_ENABLED=true to export traces, and METRICS_ENABLED=true to export metrics, over OTLP to OTEL_EXPORTER_OTLP_ENDPOINT.
Set METRICS_PROMETHEUS_ENABLED=true to open a separate listener for a Prometheus scrape, on METRICS_PROMETHEUS_ADDRESS. The default address is 127.0.0.1:9076. The main port has no metrics endpoint.
See Observability for the platform view.
Deployment posture
DEPLOYMENT_MODE takes local, byoc, or saas. In saas, every configured dependency must use TLS, or the service does not start.
ENV_NAME decides how strict the startup checks are. With any value other than development, the service also requires:
POSTGRES_USERandPOSTGRES_NAME, with aPOSTGRES_SSLMODEother thandisable.ENCRYPTION_KEY, with exactly 32 bytes.ALLOWED_ORIGINS, with a value other than*.FEATURE_AUDIT_ENABLEDnot set tofalse.
saas, the broker also needs STREAMING_TLS_ENABLED=true and a SASL identity: STREAMING_SASL_MECHANISM, STREAMING_SASL_USERNAME, and STREAMING_SASL_PASSWORD.
Every environment needs a license, set with LICENSE_KEY or LICENSE_FILE_PATH, a Kafka broker in STREAMING_BROKERS, and an explicit true or false in PLUGIN_AUTH_ENABLED. A missing or invalid value stops the boot.
