# Configuration

Audience: System Administrator

Environment variables and NATS configuration requirements for deploying Pyck

This page covers the required and optional environment variables, the NATS configuration requirements and a reference of the settings an operator sets to run Pyck.

## Required environment variables

All Pyck binaries require the following environment variable to be set:

- **`PYCK_ENV`** (required): Specifies the environment name (for example, `production`, `staging`, `dev`, `local`)
  - This variable **must be set explicitly** in your deployment configuration
  - The application will fail to start if this variable is missing or empty
  - Used for resource naming and namespace construction (for example, `pyck-{PYCK_ENV}-workers`)

Example configuration:

**Docker Compose:**

```yaml
environment:
  - PYCK_ENV=production
```

**Kubernetes ConfigMap:**

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: pyck-config
data:
  PYCK_ENV: "production"
```

**IMPORTANT**: As of commit `15ffdc33` (April 2026), `PYCK_ENV` has no default value. Deployments that previously relied on the implicit "local" default must now explicitly set this variable.

### Optional discovery environment name

The management service publishes a client discovery document at `/.well-known/pyck-configuration`. Its `meta.environment` field holds the name of the environment as listed in the DNS TXT record `_pyck.pyck.cloud`, for example `dev`, `test`, `demo` or `eu`. For the format of the document, see [Client discovery document](https://docs.pyck.cloud/dev/developers/authentication.md#client-discovery-document).

The name can be set with this optional environment variable:

- **`PYCK_DISCOVERY_ENVIRONMENT`**: The name published as `meta.environment` (default: the value of `PYCK_ENV`)

**Example Configuration:**

```yaml
environment:
  - PYCK_DISCOVERY_ENVIRONMENT=eu
```

The management service builds the document once at startup. Restart it after you change the variable.

### Optional health check configuration

Temporal workers expose a `/health` HTTP endpoint (enabled by default on port 8080) to support deployment health monitoring. This endpoint verifies that the worker is actively polling Temporal task queues.

The health server can be configured via these optional environment variables:

- **`HEALTH_DISABLED`**: Set to `1` to disable the health endpoint
- **`HEALTH_PORT`**: HTTP port for health checks (default: `8080`)
- **`HEALTH_INTERVAL`**: How often to probe Temporal (default: `10s`)
- **`HEALTH_TIMEOUT`**: RPC timeout for each probe (default: `3s`)
- **`HEALTH_MAX_STALE`**: Maximum age of last successful probe before reporting unhealthy (default: `90s`)

**Example Configuration:**

```yaml
environment:
  - HEALTH_PORT=9090
  - HEALTH_INTERVAL=30s
  - HEALTH_MAX_STALE=120s
```

The health endpoint returns:

- **200 OK** when the worker is actively polling Temporal
- **503 Service Unavailable** when polling has stalled or Temporal is unreachable

The same server also exposes `/ready` for a readiness probe. It returns 200 only when `/health` would return 200 and the worker has stamped its UI bundle metadata, and 503 otherwise. A worker with no UI bundle configured, or with worker deployment versioning disabled, has nothing to stamp and counts as stamped.

This is particularly useful for container orchestrators (Kubernetes, fly.io) that need to detect and restart wedged workers.

## NATS configuration requirements

Pyck uses NATS.io for event streaming and service messaging with a **strict account separation** for security. The system enforces the following requirements:

### Tenant account separation

The **tenant account** (configured via `PYCK_NATS_TENANT_ACCOUNT_NAME`, default: `pyck-tenants`) must be **separate from the services' account**.

**Why the accounts must be separate:**

- Tenant clients connect to NATS through a dedicated account isolated from backend services
- If tenant clients were placed in the services' account, they could potentially access streams and subjects they shouldn't, creating a security vulnerability
- The answers to tenant API calls would be delivered to whatever reply subject the client names, and stored in a stream under another tenant's or the platform's subjects

### Startup validation

**BREAKING CHANGE** (since v0.26.0): The management service now performs an account separation check at startup using the NATS system API (`$SYS.REQ.USER.INFO`). The service will **refuse to start** if:

1. `PYCK_NATS_TENANT_ACCOUNT_NAME` names the same account as the management service's own NATS connection
2. The NATS server does not have a system account configured (required for the `$SYS.REQ.USER.INFO` API)

**Required NATS Server Configuration:**

- A `system_account` must be configured in the NATS server config
- The tenant account declared in the server config must match `PYCK_NATS_TENANT_ACCOUNT_NAME`
- The tenant account must be distinct from the account used by Pyck backend services

**Example Error:**
If the validation fails, you'll see an error like:

```text
failed checking PYCK_NATS_TENANT_ACCOUNT_NAME: the NATS tenant account is the services' account: "pyck-tenants"
```

**Resolution:**

1. Verify your NATS server configuration has a `system_account` defined
2. Ensure `PYCK_NATS_TENANT_ACCOUNT_NAME` points to a separate account for tenant clients
3. Confirm the account exists in your NATS server configuration's `accounts` block

### Consumer create subject (breaking change)

**BREAKING CHANGE** (in the next release after v0.26.0): tenant clients can no longer create push consumers. Every NATS server configuration, the Kubernetes one included, must export and import the consumer create subject the same way `config/nats/nats.conf` does:

```text
# account "pyck", exports
{service: "$PYCK.TENANT.CONSUMER.CREATE.>", accounts: ["pyck-tenants"]}

# account "pyck-tenants", imports
{service: {account: "pyck", subject: "$PYCK.TENANT.CONSUMER.CREATE.>"}, to: "$JS.API.CONSUMER.CREATE.>"}
```

If you changed `PYCK_NATS_TENANT_ACCOUNT_NAME`, use that account name instead of `pyck-tenants`.

These lines replace the export and import of `$JS.API.CONSUMER.CREATE.>`. Deploy the new management image before the NATS configuration: until management runs, tenant clients cannot create consumers. For the same reason, only roll back management together with the NATS configuration. For how tenant clients create consumers, see [Tenant NATS clients](https://docs.pyck.cloud/dev/developers/architecture.md#tenant-nats-clients).

## Configuration reference

This reference lists the variables an operator sets to run Pyck. Every service reads its configuration from environment variables only. A required variable that is unset or empty stops the service at startup. A duration uses Go syntax, for example `250ms`, `10s`, `5m` or `72h`.

"All services" means the management, main-data, inventory, picking, receiving, file and workflow services. The Temporal server reads a smaller set, and each table names it where it applies. `PYCK_ENV` is described in [Required environment variables](#required-environment-variables), and `PYCK_NATS_TENANT_ACCOUNT_NAME` in [NATS configuration requirements](#nats-configuration-requirements).

A variable marked **secret** holds a credential. Keep its value in a secret store, not in a ConfigMap or an image. The services leave secrets out of the configuration they log at startup.

Settings for the outbox, event streams, signal routing and other internals have defaults that fit a normal deployment, and this page does not list them.

### Environment, logging and HTTP

The service image sets `PYCK_LOG_LEVEL=info`, `PYCK_LOG_FORMAT=json` and `PYCK_DATABASE_DEBUG=false`, and sets `PYCK_HTTP_PORT` from its `SERVICE_PORT` build argument, which defaults to `8080`.

| Variable | Read by | Default | Description |
| --- | --- | --- | --- |
| `PYCK_LOG_LEVEL` | all services, Temporal server | `info` | Log level: `debug`, `info`, `warn`, `error`, `fatal` or `panic`. Any other value means `info`. |
| `PYCK_LOG_FORMAT` | all services, Temporal server | `json` | `console` writes human-readable lines. Any other value writes JSON. |
| `PYCK_HTTP_HOST` | all services | empty | Host the HTTP server listens on. Empty listens on all interfaces. |
| `PYCK_HTTP_PORT` | all services | `8080` | Port the HTTP server listens on. |
| `PYCK_HTTP_READ_HEADER_TIMEOUT` | all services | `5s` | How long the server waits to read the request headers. |
| `PYCK_HTTP_SHUTDOWN_PREDRAIN_DELAY` | all services | `3s` | How long the server keeps serving after the stop signal, with readiness already returning 503, so that orchestrators stop routing to it. |
| `PYCK_HTTP_SHUTDOWN_DRAIN_TIMEOUT` | all services | `10s` | How long shutdown waits for in-flight requests after the listener closes. Requests still running then are abandoned. |

Set the stop grace period of your container above the pre-drain delay plus the drain timeout plus the time the service needs to release its resources.

The management service enables GraphQL introspection only when `PYCK_ENV` is `development`. All services stamp `PYCK_ENV` on their traces as the deployment environment.

### Database

| Variable | Read by | Default | Description |
| --- | --- | --- | --- |
| `PYCK_DATABASE_MASTER_URL` | all services | none (required, secret) | Connection URL of the PostgreSQL writer. The service adds its own name as `search_path` and sets the transaction isolation. |
| `PYCK_DATABASE_SLAVE_URL` | all services | none (required, secret) | Connection URL of the PostgreSQL reader. It can point at the same database as the writer. |
| `PYCK_DATABASE_DEBUG` | all services | `false` | Log every SQL statement. |
| `PYCK_TX_RETRIES` | all services | `50` | How often a GraphQL mutation is retried after PostgreSQL reports a serialization failure or a deadlock. |
| `PYCK_IDEMPOTENCY_MAX_RESPONSE_BYTES` | all services | `1048576` | Largest GraphQL response that the `Idempotency-Key` feature stores. A larger response rolls the mutation back and returns HTTP 413. |

### Calls between services

| Variable | Read by | Default | Description |
| --- | --- | --- | --- |
| `PYCK_GATEWAY_URL` | Temporal server and all services except management | none (required) | URL of the gateway, which the services call to reach the management API. |
| `PYCK_GATEWAY_HTTP_TIMEOUT` | all services except management | `30s` | Upper limit for one whole outbound gateway call. |
| `PYCK_GATEWAY_HTTP_MAX_IDLE_CONNS` | all services except management | `16` | Size of the pool of idle connections to the gateway. Bursts above it use short-lived extra connections. |
| `PYCK_SERVICE_TOKEN` | all services, Temporal server | none (required, secret) | Personal access token of the system service user. The services send it as a bearer token on gateway calls, and the management service also sends it to the worker API. The Zitadel bootstrap creates it. |
| `PYCK_STRICT_VERSION_CHECK` | all services except management | `true` | At startup, wait until the management service reports the same deploy commit as the service itself. With `false`, the service only waits until management answers. |
| `PYCK_SERVICE_INSTANCE_ID` | all services except management | `default` | Part of the name of the service's JetStream consumer for data types. |

### Temporal

| Variable | Read by | Default | Description |
| --- | --- | --- | --- |
| `PYCK_TEMPORAL_URL` | management, file and workflow services | none (required) | Address of the Temporal frontend. The Temporal bootstrap module reads it too. |
| `PYCK_TEMPORAL_DIAL_TIMEOUT` | management, file and workflow services | `30s` | How long the startup connectivity check to Temporal may take. |
| `PYCK_TEMPORAL_CLIENT_CREATION_TIMEOUT` | workflow service | `30s` | Limit for the one-time setup of a tenant's Temporal namespace, which the first request for that tenant triggers. |

The management and file services, and workers built on the Pyck workflow SDK, read these variables for Temporal Worker Deployment Versioning:

| Variable | Default | Description |
| --- | --- | --- |
| `PYCK_WORKER_BUILD_ID` | unset | Explicit build ID of the worker version. It outranks the ID that the temporal-worker-controller injects. Leave it unset when the controller manages the deployment. |
| `PYCK_WORKER_DEPLOYMENT_NAME` | unset | Explicit deployment name. The same rule applies as for the build ID. |
| `PYCK_WORKER_REQUIRE_BUILD_ID` | `false` | Refuse to start when the build has no version. Without a build ID the worker runs unversioned. |
| `PYCK_WORKER_PROMOTE_ON_START` | `false` | Make this worker's version the current one when it starts. Use it only for deployments that the temporal-worker-controller does not manage. |

The controller sets `TEMPORAL_WORKER_BUILD_ID` and `TEMPORAL_DEPLOYMENT_NAME` in every container, and the worker uses them when the two `PYCK_WORKER_` overrides are unset.

### NATS connection

| Variable | Read by | Default | Description |
| --- | --- | --- | --- |
| `PYCK_NATS_URL` | all services, Temporal server | none (required, secret) | URL of the NATS server. It can carry credentials. |
| `PYCK_NATS_STREAM_NAME` | all services, Temporal server | none (required) | Prefix of the names of the JetStream streams. |
| `PYCK_NATS_REPLICAS_NO` | all services, Temporal server | none (required) | Number of replicas of each JetStream stream. |
| `PYCK_NATS_WS_URL` | all services, Temporal server | none (required) | Address of the NATS WebSocket listener. The services require it at startup, but the backend does not use the value. |
| `PYCK_NATS_AUTH_KEY_SEED` | management service | none (required, secret) | NKey seed of the NATS account whose public key is pinned as the auth callout `issuer` in the NATS server configuration. |

### Zitadel and authentication

These variables apply to all services and to the Temporal server unless the Read by column says otherwise. The Zitadel bootstrap writes `PYCK_ZITADEL_ORG_ID` and `PYCK_ZITADEL_PROJECT_ID`.

| Variable | Read by | Default | Description |
| --- | --- | --- | --- |
| `PYCK_ZITADEL_OAUTH_URL` | all | none (required) | Base URL of the Zitadel token and introspection endpoints. |
| `PYCK_ZITADEL_GRPC_ADDR` | all | none (required) | gRPC address of the Zitadel API. The management service uses it to call Zitadel. |
| `PYCK_ZITADEL_AUDIENCE` | all | none (required) | External URL of the Zitadel instance. It is the audience of the services' JWT assertions, and Pyck derives the tenant UUIDs of Zitadel organizations from it. |
| `PYCK_ZITADEL_ORG_ID` | all | none (required) | ID of the Zitadel root organization. It is not a tenant, and its users skip the check that their home tenant is live. |
| `PYCK_ZITADEL_PROJECT_ID` | all | none (required) | ID of the `Pyck` project in Zitadel. A locally validated JWT must carry it in `aud`. |
| `PYCK_ZITADEL_APP_KEYFILE` | all | none (required) | Path to the key file with which the services authenticate their token introspection calls to Zitadel. |
| `PYCK_ZITADEL_SERVICE_KEYFILE` | management service | none (required) | Path to the key file of the Zitadel service account with which the management service calls Zitadel. |
| `PYCK_ZITADEL_TLS_INSECURE` | all | `false` | Use gRPC without TLS and skip TLS verification on HTTP calls to Zitadel. Leave it `false` unless Zitadel runs without valid TLS. |
| `PYCK_ZITADEL_JWKS_FILE` | all | unset | Path to Zitadel's public key set. When set, the service validates JWT access tokens locally. When unset, it introspects every token. A file that does not load stops the service at startup. |
| `PYCK_ZITADEL_ISSUER` | all | unset | The exact `iss` that a locally validated JWT must carry. It is required when `PYCK_ZITADEL_JWKS_FILE` is set. |
| `PYCK_ZITADEL_JWKS_REFRESH_INTERVAL` | all | `1m` | How often the key set file is read again. An unknown key ID reads it earlier, at most every 5 seconds. |
| `PYCK_ZITADEL_PAT_CACHE_TTL` | all | `1h` | Longest time the service reuses a verified token. It never outlives the token's own expiry. |
| `PYCK_ZITADEL_PAT_CACHE_TTL_OVERLAP` | all | `1m` | Time subtracted from the cached lifetime of a token. A value above `PYCK_ZITADEL_PAT_CACHE_TTL` stops the service at startup, and a value equal to it turns the cache off. |
| `PYCK_ZITADEL_REJECTED_TOKEN_CACHE_TTL` | all | `10s` | How long a token that Zitadel refused is refused again without asking Zitadel. `0` turns this cache off. |
| `PYCK_ZITADEL_INTROSPECTION_TIMEOUT` | all | `10s` | Limit for one introspection call. It must be positive. |
| `PYCK_LIVENESS_CACHE_TTL` | all | `1m` | How long the verdict "this tenant is live" or "is not live" is reused. Lifecycle events evict it earlier, and this is the worst-case delay when such an event is lost. |
| `PYCK_LIVENESS_LOOKUP_TIMEOUT` | all | `1s` | How long one request waits for a verdict that is not cached. It must stay below the timeout of one NATS auth callout and below `PYCK_TEMPORAL_CLAIMS_TIMEOUT`. |
| `PYCK_LIVENESS_SOURCE_TIMEOUT` | all | `10s` | Limit for the background lookup that a cache miss starts. |
| `PYCK_TEMPORAL_CLAIMS_TIMEOUT` | Temporal server | `2s` | Limit for one whole claim mapping, which includes the token introspection and the liveness lookup. It must exceed `PYCK_LIVENESS_LOOKUP_TIMEOUT`, or the server refuses to start. |
| `PYCK_ZITADEL_ACTION_SIGNING_KEY` | management service | none (required, secret) | HMAC key with which Zitadel signs the pre-token webhook. The management service verifies every request, and the Zitadel bootstrap creates the key. |
| `PYCK_ZITADEL_LOGIN_ACTION_SIGNING_KEY` | management service | unset (secret) | HMAC key of the login-event webhook. The management service mounts the webhook only when the key is set. |

`PYCK_ZITADEL_ORGANIZATION_CACHE_TTL` was renamed to `PYCK_LIVENESS_CACHE_TTL`. A service refuses to start while the old name is set.

### Tenants and management settings

These variables apply to the management service.

| Variable | Default | Description |
| --- | --- | --- |
| `PYCK_ZITADEL_SYNC_EVERY` | `10m` | How often the management service reads the Zitadel users of each tenant into the database. A shorter interval picks up user changes sooner and makes more calls to Zitadel. It must not be negative. |
| `PYCK_ZITADEL_SYNC_MAX_SKIPPED_USERS` | `10` | How many users that cannot be written one tenant's sync round skips. Past that number the round commits nothing. The value must be between `0` and `100`. |
| `PYCK_TENANT_RECONCILE_INTERVAL` | `5m` | How often the management service compares tenants in the database with Zitadel organizations and repairs the difference. It must be positive. |
| `PYCK_TENANT_EXPIRY_CHECK_INTERVAL` | `1m` | How often the management service looks for tenants whose expiry date has passed and soft-deletes them. It must be positive. |
| `PYCK_REGISTER_TENANT_MAX_INFLIGHT` | `8` | How many `registerTenant` calls one replica runs at the same time. A further call is refused at once. |
| `PYCK_WORKER_API_URL` | unset | URL of the worker API, which deploys tenant workers. Set it wherever tenants of the `pyck-go` flavour are registered. Without it the management service logs a warning at startup, and registering such a tenant fails. |
| `PYCK_TENANT_WORKER_LIFECYCLE` | `true` | Stop and resume a tenant's worker when the tenant is disabled and restored. Set `false` for an environment without a worker cluster. |
| `PYCK_OPENAI_TOKEN` | unset (secret) | API token for OpenAI. The management service uses it for JSON schema generation, and the file service uses it for image analysis. |

### Client settings

The management service publishes these values to the web app at `/static/settings.json` and to all clients at `/.well-known/pyck-configuration`, see [Client discovery document](https://docs.pyck.cloud/dev/developers/authentication.md#client-discovery-document). Their defaults point at a local setup, so set them in every other environment. `PYCK_DISCOVERY_ENVIRONMENT` is described in [Optional discovery environment name](#optional-discovery-environment-name).

| Variable | Default | Description |
| --- | --- | --- |
| `PYCK_FRONTEND_APP_URL` | `http://localhost:3000` | URL of the web app. The GraphQL URL is this URL plus `/graphql`. |
| `PYCK_FRONTEND_AUTH_URL` | `http://localhost:8080` | URL of the identity provider that clients sign in with. |
| `PYCK_FRONTEND_CLIENT_ID` | unset | OIDC client ID of the web app. |
| `PYCK_FRONTEND_REDIRECT_URI` | `http://localhost:3000/auth/oauth2/callback/zitadel` | OIDC redirect URI of the web app. |
| `PYCK_FRONTEND_FEATURES` | `{}` | JSON object of feature settings for the web app. A value that is not valid JSON is replaced with `{}` in `settings.json`. |
| `PYCK_FRONTEND_DEBUG` | `true` | Debug flag for the web app. |
| `PYCK_FRONTEND_VERSION` | `unknown` | Version of the web app that the settings report. |
| `PYCK_FRONTEND_ENVIRONMENT` | `development` | Environment name in `settings.json`. The discovery document does not use it. |
| `PYCK_CLI_CLIENT_ID`, `PYCK_MOBILE_CLIENT_ID`, `PYCK_BRUNO_CLIENT_ID`, `PYCK_MCP_CLIENT_ID` | unset | OIDC client IDs of the Pyck CLI, the mobile app, the Bruno API collection and the MCP server. A client without an ID is left out of the discovery document. |
| `PYCK_UI_STORE_URL` | unset | Endpoint of the UI store. The discovery document leaves it out when it is empty. |

### Bootstrap

The management service can run a bootstrap module before it starts. Each module prepares one dependency: `zitadel`, `temporal` or `minio`. The `minio` module creates the configured S3 bucket on any S3-compatible store.

| Variable | Default | Description |
| --- | --- | --- |
| `PYCK_BOOTSTRAP_ENABLED` | `true` | Run a bootstrap module at startup. |
| `PYCK_BOOTSTRAP_MODULE` | unset | The module to run: `zitadel`, `temporal` or `minio`. |
| `PYCK_BOOTSTRAP_ONLY` | `true` | Exit after the module has finished. With `false`, the service continues as the management API. |
| `PYCK_BOOTSTRAP_TIMEOUT` | `5m` | Limit for the whole bootstrap run. |
| `PYCK_BOOTSTRAP_CONFIG_FILE` | unset | Path to a bootstrap configuration file. Without it, the configuration built into the binary is used. |

`PYCK_BOOTSTRAP_ENABLED` defaults to `true` and the module has no default. A management service that is not meant to bootstrap must therefore set `PYCK_BOOTSTRAP_ENABLED=false`. Otherwise it fails at startup with an `unknown bootstrap module` error.

### Object storage

The file service stores files in an S3-compatible object store. The local Docker Compose setup uses RustFS. The `minio` bootstrap module reads the same variables and requires all of them except the HTTP endpoint.

| Variable | Default | Description |
| --- | --- | --- |
| `PYCK_AWS_S3_BUCKET` | unset | Name of the bucket. |
| `PYCK_AWS_S3_REGION` | unset | Region of the store. |
| `PYCK_AWS_S3_ENDPOINT_URL` | unset | Endpoint that the service talks to. The service uses TLS when the URL starts with `https`. |
| `PYCK_AWS_S3_HTTP_ENDPOINT_URL` | unset | Endpoint that clients reach the store on. The service puts its host and scheme into the pre-signed URLs it hands out. |
| `PYCK_AWS_ACCESS_KEY_ID` | unset | Access key ID. |
| `PYCK_AWS_SECRET_ACCESS_KEY` | unset (secret) | Secret access key. |

### Tracing

All services read these variables, and so do workers built on the Pyck workflow SDK. Without `PYCK_OTEL_EXPORTER_OTLP_ENDPOINT`, a service creates traces but exports none.

| Variable | Default | Description |
| --- | --- | --- |
| `PYCK_OTEL_EXPORTER_OTLP_ENDPOINT` | unset | OTLP collector. With `http`, give the full traces URL including the path, because the exporter posts to the URL as given. With `grpc`, only the host and port are used, and TLS is on unless the URL starts with `http://`. |
| `PYCK_OTEL_EXPORTER_OTLP_PROTOCOL` | `http` | `grpc`, `http` or `http/protobuf`. Any other value stops the service at startup. |
| `PYCK_OTEL_EXPORTER_OTLP_AUTHORIZATION` | unset (secret) | Value of the `Authorization` header sent to the collector. |
| `PYCK_OTEL_EXPORTER_OTLP_TIMEOUT` | `5s` | Limit for creating the exporter at startup. |
| `PYCK_OTEL_TRACES_SAMPLER` | `always_on` | `always_on`, `always_off`, `traceidratio`, `parentbased_always_on`, `parentbased_always_off` or `parentbased_traceidratio`. Any other value stops the service at startup. |
| `PYCK_OTEL_TRACES_SAMPLER_ARG` | `0.1` | Sampling ratio from `0` to `1`, for the two ratio samplers. A value outside that range is clamped. |
| `PYCK_OTEL_SHUTDOWN_TIMEOUT` | `5s` | Time the tracer gets to shut down. |
