> For the complete documentation index, see [llms.txt](https://docs.prestd.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.prestd.com/get-started/configuring-prest.md). Agents can also search and read this documentation through its [MCP server](https://docs.prestd.com/~gitbook/mcp).

# Configuring pREST

The ***prestd*** configuration is via an *environment variable* or *toml* file. Starting from version [`v1.2.0`](https://github.com/prest/prest/releases/tag/v1.2.0) it will be possible to use `prestd` without any *environment variable* or the *toml* file, but the configurations used will be the described in the default column bellow.

### Environment variables

From v2.5.0 every `PREST_PG_<KEY>` connection variable can also be set as `PREST_DB_<KEY>` (for example `PREST_DB_URL`, `PREST_DB_DATABASE`); when both are set, `PREST_DB_*` wins. The `PREST_PG_*` names below keep working.

| var                                  | default                            | description                                                                                                                                                                                                                                                                                                        |
| ------------------------------------ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `PREST_VERSION`                      | `1`                                | version used for environment variables. Set to `2` for v2 deployments (recommended). v2 uses `PREST_PG_SSL_*` for PostgreSQL SSL.                                                                                                                                                                                  |
| `PREST_CONF`                         | `./prest.toml`                     | path to the TOML configuration file                                                                                                                                                                                                                                                                                |
| `PREST_CONFIG_JSON`                  |                                    | v2.6.0: application config (auth, JWT, ACL, queries, cache, CORS, …) as one JSON document, merged over the TOML file. See [Configuration as JSON](#configuration-as-json)                                                                                                                                          |
| `PREST_CONFIG_JSON_B64`              |                                    | v2.6.0: the same document base64-encoded, for platforms that mangle multi-line values. Read only when `PREST_CONFIG_JSON` is unset                                                                                                                                                                                 |
| `PREST_MIGRATIONS`                   | `./migrations`                     |                                                                                                                                                                                                                                                                                                                    |
| `PREST_QUERIES_LOCATION`             | `./queries`                        |                                                                                                                                                                                                                                                                                                                    |
| `PREST_HTTP_HOST`                    | `0.0.0.0`                          |                                                                                                                                                                                                                                                                                                                    |
| `PREST_HTTP_PORT` **or** `PORT`      | `3000`                             | `PORT` is for cloud factor, *when declared this variable overwrittes* `PREST_HTTP_PORT`                                                                                                                                                                                                                            |
| `PREST_HTTP_ALLOWED_HOSTS`           |                                    | v2.6.0: comma-separated host names pREST answers; any other `Host` header gets **400**. Unset serves every host. See [Allowed hosts](#allowed-hosts)                                                                                                                                                               |
| `PREST_HTTP_REQUEST_ID_HEADER`       |                                    | v2.6.0: response and request header that carries a request ID, such as `X-Request-Id`. Unset adds no request ID. See [Request IDs](#request-ids)                                                                                                                                                                   |
| `PREST_HTTPS_MODE`                   | `false`                            | `true` serves HTTPS on the HTTP host and port instead of plain HTTP. See [Serving over HTTPS](https://docs.prestd.com/deployment/serving-over-https.md)                                                                                                                                                            |
| `PREST_HTTPS_CERT`                   | `/etc/certs/cert.crt`              | PEM certificate (full chain) for HTTPS                                                                                                                                                                                                                                                                             |
| `PREST_HTTPS_KEY`                    | `/etc/certs/cert.key`              | PEM private key for HTTPS                                                                                                                                                                                                                                                                                          |
| `PREST_CORS_ALLOWORIGIN`             | `*`                                | origins allowed to read responses from the browser. **Space-separated**, not comma-separated. See [CORS Support](https://docs.prestd.com/get-started/cors-support.md)                                                                                                                                              |
| `PREST_CORS_ALLOWHEADERS`            | `Content-Type`                     | space-separated request headers a preflight may ask for. Add `Authorization` for browser apps that send a JWT                                                                                                                                                                                                      |
| `PREST_CORS_ALLOWMETHODS`            | `GET HEAD POST PUT DELETE OPTIONS` | space-separated methods a preflight may ask for. `PATCH` is not in the default                                                                                                                                                                                                                                     |
| `PREST_CORS_ALLOWCREDENTIALS`        | `true`                             | send `Access-Control-Allow-Credentials: true`. See [CORS Support — Credentials](https://docs.prestd.com/get-started/cors-support.md#credentials)                                                                                                                                                                   |
| `PREST_GUARD_ENABLED`                | `false`                            | prest `main` (unreleased): turn on request security (rate limits, payload inspection, IP lists). See [Request security](https://docs.prestd.com/get-started/request-security.md)                                                                                                                                   |
| `PREST_GUARD_PASSIVE`                | `false`                            | prest `main` (unreleased): log what the guard would refuse, refuse nothing. See [Passive mode](https://docs.prestd.com/get-started/request-security.md#passive-mode)                                                                                                                                               |
| `PREST_GUARD_RATE_LIMIT`             | `0`                                | prest `main` (unreleased): requests each client IP may send per window; `0` turns rate limiting off. See [Rate limits](https://docs.prestd.com/get-started/request-security.md#rate-limits)                                                                                                                        |
| `PREST_GUARD_RATE_LIMIT_WINDOW`      | `60`                               | prest `main` (unreleased): rate limit window in seconds                                                                                                                                                                                                                                                            |
| `PREST_GUARD_PENETRATION_DETECTION`  | `true`                             | prest `main` (unreleased): inspect the path, query, headers and body for attack payloads. See [Payload inspection](https://docs.prestd.com/get-started/request-security.md#payload-inspection)                                                                                                                     |
| `PREST_GUARD_MAX_BODY_BYTES`         | `8192`                             | prest `main` (unreleased): leading bytes of a request body that are inspected                                                                                                                                                                                                                                      |
| `PREST_GUARD_BLACKLIST`              |                                    | prest `main` (unreleased): **comma-separated** IP addresses and CIDR ranges refused with 403                                                                                                                                                                                                                       |
| `PREST_GUARD_WHITELIST`              |                                    | prest `main` (unreleased): comma-separated allowlist; when set, every other client gets 403. See [IP allow and block lists](https://docs.prestd.com/get-started/request-security.md#ip-allow-and-block-lists)                                                                                                      |
| `PREST_GUARD_EXCLUDE_PATHS`          |                                    | prest `main` (unreleased): comma-separated paths, with everything below them, that skip every guard check                                                                                                                                                                                                          |
| `PREST_GUARD_TRUSTED_PROXIES`        |                                    | prest `main` (unreleased): comma-separated proxy IPs or CIDR ranges whose `X-Forwarded-For` names the client. See [Clients behind a proxy](https://docs.prestd.com/get-started/request-security.md#clients-behind-a-proxy)                                                                                         |
| `PREST_GUARD_AUTO_BAN`               | `false`                            | prest `main` (unreleased): ban a client for an hour after 10 attack payloads of the same kind. See [Auto-ban](https://docs.prestd.com/get-started/request-security.md#auto-ban)                                                                                                                                    |
| `PREST_GUARD_BLOCK_CLOUD_PROVIDERS`  |                                    | prest `main` (unreleased): comma-separated providers whose ranges are refused: `AWS`, `GCP`, `Azure`, `DigitalOcean`, `Linode`, `Vultr`                                                                                                                                                                            |
| `PREST_GUARD_REDIS_URL`              |                                    | prest `main` (unreleased): Redis URL that shares rate-limit and ban state across instances. See [Several instances](https://docs.prestd.com/get-started/request-security.md#several-instances)                                                                                                                     |
| `PREST_GUARD_REDIS_PREFIX`           | `prest_guard`                      | prest `main` (unreleased): prefix of the guard's Redis keys                                                                                                                                                                                                                                                        |
| `PREST_GUARD_REDIS_FAIL_OPEN`        | `true`                             | prest `main` (unreleased): keep serving on per-instance state when Redis does not answer; `false` answers 500 instead                                                                                                                                                                                              |
| `PREST_PG_HOST`                      | `127.0.0.1`                        | host used to connect                                                                                                                                                                                                                                                                                               |
| `PREST_PG_USER`                      | `postgres`                         | user used to connect                                                                                                                                                                                                                                                                                               |
| `PREST_PG_PASS`                      | `postgres`                         | password used to connect                                                                                                                                                                                                                                                                                           |
| `PREST_PG_DATABASE`                  | `prest`                            | database name used to connect                                                                                                                                                                                                                                                                                      |
| `PREST_PG_PORT`                      | `5432`                             |                                                                                                                                                                                                                                                                                                                    |
| `PREST_PG_URL` **or** `DATABASE_URL` |                                    | cloud factor, *when declaring this variable all the previous connection fields are overwritten*                                                                                                                                                                                                                    |
| `PREST_PG_SSL_MODE`                  | `disable`                          | Postgres connection SSL mode (`disable`, `require`, `verify-ca`, `verify-full`). Sample default matches `[pg.ssl]` when no config is set.                                                                                                                                                                          |
| `PREST_PG_SSL_CERT`                  |                                    | Postgres connection SSL certificate                                                                                                                                                                                                                                                                                |
| `PREST_PG_SSL_KEY`                   |                                    | Postgres connection SSL key                                                                                                                                                                                                                                                                                        |
| `PREST_PG_SSL_ROOTCERT`              |                                    | Postgres connection SSL root certificate                                                                                                                                                                                                                                                                           |
| `PREST_PG_TIMEZONE`                  |                                    | v2.6.0: PostgreSQL session time zone, an IANA name such as `America/Sao_Paulo`. Also `PREST_DB_TIMEZONE`. See [Session time zone](#session-time-zone)                                                                                                                                                              |
| `PREST_PG_APPLICATION_NAME`          | `prestd`                           | v2.6.0: name pREST's PostgreSQL connections report in `pg_stat_activity`. Also `PREST_DB_APPLICATION_NAME`, which wins. An empty value turns it off. See [Application name](#application-name)                                                                                                                     |
| `PREST_PG_ALLOWED_DATABASES`         |                                    | v2.5.2: comma-separated extra databases on the `[pg]` host, served with the `[pg]` credentials when no registry is configured. Also `PREST_DB_ALLOWED_DATABASES`. Replaces `PREST_PG_SINGLE`, which is ignored. See [Multi-database](https://docs.prestd.com/get-started/multi-database.md#no-registry-mode-v252). |
| `PREST_ENGINE`                       | `postgres`                         | v2.5.0: `postgres` or `mysql`. Any other value fails startup. See [MySQL](https://docs.prestd.com/databases/mysql.md).                                                                                                                                                                                             |
| `PREST_MYSQL_PREPARE`                | `false`                            | MySQL only: `true` uses the binary prepare protocol instead of interpolated parameters.                                                                                                                                                                                                                            |
| `DATABASE_ALIAS_N`                   |                                    | Multi-database registry alias (1-based index). Also `PREST_DATABASE_ALIAS_N`. See [Multi-database](https://docs.prestd.com/get-started/multi-database.md).                                                                                                                                                         |
| `DATABASE_URL_N`                     |                                    | Connection URL for `DATABASE_ALIAS_N`. Also `PREST_DATABASE_URL_N`. Env wins over TOML.                                                                                                                                                                                                                            |
| `PREST_CACHE_ENABLED`                | false                              | embedded cache system                                                                                                                                                                                                                                                                                              |
| `PREST_CACHE_TIME`                   | 10                                 | TTL in minute (time to live)                                                                                                                                                                                                                                                                                       |
| `PREST_CACHE_STORAGEPATH`            | ./                                 | path where the cache file will be created                                                                                                                                                                                                                                                                          |
| `PREST_CACHE_SUFIXFILE`              | .cache.prestd.db                   | suffix of the name of the file that is created                                                                                                                                                                                                                                                                     |
| `PREST_JWT_DEFAULT`                  | `false`                            | v2+: enable default JWT middleware on all routes (except whitelist)                                                                                                                                                                                                                                                |
| `PREST_STUDIO_ENABLED`               | `true`                             | v2.2.0+: serve embedded pREST Studio at `/_studio/` (set `false` to disable; returns 404)                                                                                                                                                                                                                          |
| `PREST_JWT_KEY`                      |                                    | HMAC secret. v2.4.2+ requires ≥32 bytes for HS256, ≥48 for HS384, ≥64 for HS512                                                                                                                                                                                                                                    |
| `PREST_JWT_ALGO`                     | HS256                              | v2.4.2+: the only signature algorithm accepted for verification (case-sensitive). Ignored before v2.4.2                                                                                                                                                                                                            |
| `PREST_JWT_WELLKNOWNURL`             |                                    | URL of .wellknown config of IDP used to fetch the JWKS used to verify token signature. Ignored if PREST\_JWT\_JWKS is set                                                                                                                                                                                          |
| `PREST_JWT_JWKS`                     |                                    | JWKS used to verify token signature. If set, PREST\_JWT\_WELLKNOWNURL is ignored                                                                                                                                                                                                                                   |
| `PREST_JWT_WHITELIST`                | `^\/auth$`                         | **Space-separated** regex patterns for endpoints that skip JWT verification, e.g. `"^/auth$ ^/_health$ ^/_ready$"`. Do not use commas or JSON-array syntax — see [Whitelist](https://docs.prestd.com/api-reference/auth.md#whitelist)                                                                              |
| `PREST_AUTH_ENABLED`                 | `false`                            | enables `/auth` and requires a token on CRUD, `/_QUERIES`, `/_mcp`, and — from v2.5.2 — the catalog routes, `/show`, and `/_PLUGIN`. See [Auth](https://docs.prestd.com/api-reference/auth.md#routes-that-require-auth-v252)                                                                                       |
| `PREST_AUTH_ENCRYPT`                 | `bcrypt`                           | v2 default; v1 used `MD5`                                                                                                                                                                                                                                                                                          |
| `PREST_AUTH_TYPE`                    | `body`                             |                                                                                                                                                                                                                                                                                                                    |
| `PREST_AUTH_SCHEMA`                  | `public`                           | on MySQL, defaults to the connection database                                                                                                                                                                                                                                                                      |
| `PREST_AUTH_TABLE`                   | `prest_users`                      | reserved from v2.5.2: never reachable through REST, `_join`, or MCP. See [Permissions](https://docs.prestd.com/get-started/permissions.md#reserved-tables-v252)                                                                                                                                                    |
| `PREST_AUTH_USERNAME`                | `username`                         |                                                                                                                                                                                                                                                                                                                    |
| `PREST_AUTH_PASSWORD`                | `password`                         |                                                                                                                                                                                                                                                                                                                    |
| `PREST_AUTH_TOKEN_TTL`               | `6h`                               | v2.6.0: lifetime of tokens issued by `/auth`, as a duration (`30m`, `12h`) or a number of seconds. See [Auth](#auth)                                                                                                                                                                                               |
| `PREST_SSL_MODE`                     | `require`                          | **v1 only (removed in v2)** — use `PREST_PG_SSL_MODE` instead                                                                                                                                                                                                                                                      |
| `PREST_SSL_CERT`                     |                                    | **v1 only (removed in v2)** — use `PREST_PG_SSL_CERT` instead                                                                                                                                                                                                                                                      |
| `PREST_SSL_KEY`                      |                                    | **v1 only (removed in v2)** — use `PREST_PG_SSL_KEY` instead                                                                                                                                                                                                                                                       |
| `PREST_SSL_ROOTCERT`                 |                                    | **v1 only (removed in v2)** — use `PREST_PG_SSL_ROOTCERT` instead                                                                                                                                                                                                                                                  |
| `PREST_LOG_LEVEL`                    |                                    | v2 only: log verbosity (`debug`, `info`, `warn`, `error`)                                                                                                                                                                                                                                                          |
| `PREST_PLUGINPATH`                   | `./lib`                            | path to plugin storage `.so`. See [Plugins](https://docs.prestd.com/plugins.md)                                                                                                                                                                                                                                    |
| `PREST_BUILD_PLUGINS`                | `1` (Docker)                       | container entrypoint only: `1` compiles `/app/lib/src` into `.so` files at start; `0` in `-noplugins` images. See [Plugins in Docker](https://docs.prestd.com/plugins.md#plugins-in-docker)                                                                                                                        |
| `PREST_ACCESS_ALLOW_UNSCOPED_WRITES` | `false`                            | v2.5.3: `true` lets `DELETE`, `PUT`, and `PATCH` run with no filter, touching every row of the table. Off, such requests are **400**. See [Permissions — Unscoped writes](https://docs.prestd.com/get-started/permissions.md#unscoped-writes-v253)                                                                 |
| `PREST_EXPOSE_ENABLED`               | `false`                            | when `true`, disables all listing endpoints (`/databases`, `/schemas`, `/tables`). See [Expose Data](#expose-data)                                                                                                                                                                                                 |
| `PREST_EXPOSE_TABLES`                | `true`                             | when `false`, disables table listing. See [Expose Data](#expose-data)                                                                                                                                                                                                                                              |
| `PREST_EXPOSE_SCHEMAS`               | `true`                             | when `false`, disables schema listing. See [Expose Data](#expose-data)                                                                                                                                                                                                                                             |
| `PREST_EXPOSE_DATABASES`             | `true`                             | when `false`, disables database listing. See [Expose Data](#expose-data)                                                                                                                                                                                                                                           |
| `PREST_JSON_AGG_TYPE`                | `jsonb_agg`                        | changes how pREST encodes data from the database, can be set also to `json_agg`                                                                                                                                                                                                                                    |

### TOML

Optionally the prestd can be configured by TOML file.

You can follow this sample and create your own `prest.toml` file and put this on the same folder that you run `prestd` command.

```toml
migrations = "./migrations"
# engine = "mysql"   # v2.5.0; default "postgres"
# pluginpath = "./lib"   # top-level key, before any [table]

# debug = true
# enabling debug mode will disable JWT authorization

[http]
port = 3000
# allowed_hosts = ["api.example.com", ".example.org"]   # v2.6.0; see Allowed hosts
# request_id_header = "X-Request-Id"   # v2.6.0; see Request IDs

# Serve pREST itself over HTTPS (see deployment/serving-over-https.md).
# Unrelated to [pg.ssl] below, which is the database connection.
# [https]
# mode = true
# cert = "/etc/prest/certs/fullchain.pem"
# key = "/etc/prest/certs/privkey.pem"

# Browser access from other origins (see get-started/cors-support.md).
# [cors]
# alloworigin = ["https://app.example.com"]
# allowheaders = ["Content-Type", "Authorization"]
# allowmethods = ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
# allowcredentials = true

# Rate limits, payload inspection and IP lists (see get-started/request-security.md).
# [guard]   # prest main (unreleased)
# enabled = true
# rate_limit = 100   # requests per client IP per window; 0 turns rate limiting off
# rate_limit_window = 60
# exclude_paths = ["/_health", "/_ready"]
# trusted_proxies = ["10.0.0.0/8"]   # proxies whose X-Forwarded-For names the client

[jwt]
default = false
key = "secret"
algo = "HS256"

[auth]
enabled = true
type = "body"
encrypt = "bcrypt"
table = "prest_users"
username = "username"
password = "password"

[pg]
host = "127.0.0.1"
user = "postgres"
pass = "mypass"
port = 5432
database = "prest"
# allowed_databases = ["reporting"]   # v2.5.2; pg.single was removed
# timezone = "America/Sao_Paulo"   # v2.6.0; see Session time zone
# application_name = "prestd"   # v2.6.0; see Application name
## or used cloud factor
# URL = "postgresql://user:pass@localhost/mydatabase/?sslmode=disable"

[pg.ssl]
mode = "disable"
cert = "./PATH"
key = "./PATH"
rootcert = "./PATH"

[expose]
enabled = false
databases = true
schemas = true
tables = true

# Table permissions (see get-started/permissions.md)
[access]
restrict = false
# allow_unscoped_writes = false   # v2.5.3; true allows DELETE/PUT/PATCH with no filter

# Middleware plugin (see plugins/middleware-plugin.md); only the first entry that loads is used
# [[pluginmiddlewarelist]]
# file = "hello"
# func = "Hello"
```

### Configuration as JSON

Available from v2.6.0 ([#1100](https://github.com/prest/prest/pull/1100)).

Flat `PREST_*` variables cannot express arrays of tables such as `[[access.tables]]`, `[[queries.scripts]]` or `[[cache.endpoints]]`. To run a container without mounting a `prest.toml`, put the application config in one JSON document in `PREST_CONFIG_JSON`, and keep the listener and database settings in their own variables.

`prestd config export-json` converts a TOML file into that document:

```sh
prestd config export-json -f prest.toml > app-config.json
```

| Flag              | Effect                                                                                   |
| ----------------- | ---------------------------------------------------------------------------------------- |
| `-f`, `--file`    | TOML file to read. Defaults to `PREST_CONF`, else `./prest.toml`                         |
| `--pretty`        | Indent the output                                                                        |
| `--include-infra` | Also export the sections pREST never reads from the document (below). For debugging only |

Only the keys the file sets are exported: defaults and `PREST_*` variables are not baked in. For a file with an `[access]` section, the output is:

```json
{"access":{"restrict":true,"tables":[{"fields":["id","name"],"name":"employees","permissions":["read"]}]}}
```

Pass it to pREST as is, or base64-encoded where multi-line values get mangled:

```sh
export PREST_PG_URL='postgres://user:pass@db:5432/prest'
export PREST_CONFIG_JSON="$(cat app-config.json)"
# or
export PREST_CONFIG_JSON_B64="$(base64 < app-config.json | tr -d '\n')"
```

On Kubernetes, store the document in a Secret and reference it with `valueFrom.secretKeyRef`, as the [deployment manifest](https://github.com/prest/prest/blob/main/install-manifests/kubernetes/deployment.yaml) shows.

**How it is merged.** pREST reads its defaults, then `prest.toml`, then the document, then the `PREST_*` variables:

* The document overrides the file key by key. An array replaces the file's array whole: a document with `access.tables` replaces every `[[access.tables]]` entry of the file, it does not add to them.
* A `null` value is skipped: the file's value, or the default, stays.
* A `PREST_*` variable still overrides the document. For example, `PREST_ACCESS_RESTRICT=false` turns off a `restrict = true` that came from the document.
* When both variables are set, `PREST_CONFIG_JSON` is used and `PREST_CONFIG_JSON_B64` is ignored with a warning.

**Never read from the document:** `http`, `https`, `engine`, `pg`, `mysql`, `databases` and `queries.location`. Each of these is ignored with a warning such as `config json: ignoring infrastructure key (use env vars) key=http`, so a stale export cannot move the port or point pREST at another database. Set them with their own variables.

**Startup fails** instead of falling back to defaults when the document cannot be applied. prestd logs `ERROR loading config` with one of these errors and exits:

| Problem                                                                  | Error                                                                                                |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
| Is not valid JSON                                                        | `parse PREST_CONFIG_JSON: invalid character …`                                                       |
| Is valid JSON but not an object, such as `[1]`                           | `parse PREST_CONFIG_JSON: document must be a JSON object`                                            |
| Is over 1 MiB (a warning is logged above 256 KiB)                        | `parse PREST_CONFIG_JSON: document is … bytes, the limit is 1048576`                                 |
| Uses a dotted key                                                        | `parse PREST_CONFIG_JSON: key "access.restrict": use nested objects, not dotted keys`                |
| Puts a value where the defaults or the file have a table, or the reverse | `parse PREST_CONFIG_JSON: key "jwt" must be an object`, `… key "auth.enabled" must not be an object` |
| Is in `PREST_CONFIG_JSON_B64` but is not valid base64                    | `decode PREST_CONFIG_JSON_B64: …`                                                                    |

A document read from `PREST_CONFIG_JSON_B64` reports the same errors with `parse PREST_CONFIG_JSON_B64:`.

{% hint style="danger" %}
The document can hold secrets such as `jwt.key`. Store it as a secret, not in a ConfigMap or a committed file. pREST logs only its top-level key names (at `debug` level), never the values.
{% endhint %}

### Authorization

#### JWT

JWT middleware is controlled by `jwt.default`. In **v2+**, the default is **`false`**; you must set `jwt.default = true` (or `PREST_JWT_DEFAULT=true`) to enable JWT enforcement. Enabling debug mode disables JWT at runtime.

`/_mcp` (v2.1.0+) uses the same auth stack as other HTTP routes — when JWT or auth is enabled, MCP clients must send the same credentials. See [MCP over HTTP](https://docs.prestd.com/get-started/mcp-over-http.md) and [Auth](https://docs.prestd.com/api-reference/auth.md).

```toml
[jwt]
default = true
key = "a-secret-of-at-least-32-bytes!!!"
```

**HMAC key length (v2.4.2+):** `jwt.key` must meet the RFC 7518 minimum for its algorithm — **32 bytes** for `HS256` (the default), **48** for `HS384`, **64** for `HS512` ([#1017](https://github.com/prest/prest/pull/1017)). A shorter key is **discarded at startup**; pREST keeps serving with `/auth` unregistered and the auth middleware passing requests through unauthenticated. Full detail and the log lines to grep for: [Auth — HMAC key requirements](https://docs.prestd.com/api-reference/auth.md#hmac-key-requirements-v242).

**JWT configuration (v2+):** when `jwt.default = true` and no verification material is provided (`jwt.key`, `jwt.jwks`, or `jwt.wellknownurl`), pREST **auto-disables** the JWT middleware and logs an error — the server continues to start ([#974](https://github.com/prest/prest/pull/974), shipped in v2.0.0). When `auth.enabled = true` without `jwt.key`, the auth endpoint is also auto-disabled. This prevents authentication bypass via an empty HMAC key ([GHSA-fj7v-859r-2fm4](https://github.com/prest/prest/security/advisories/GHSA-fj7v-859r-2fm4)).

> **v2.0.0-rc6 tagged binary:** the [v2.0.0-rc6](https://docs.prestd.com/releases/v2.0.0-rc6.md) release **refuses to start** in the same situations. See [Changes since rc6](https://docs.prestd.com/releases/main-since-rc6.md) for the difference.

Debug mode bypasses JWT enforcement at runtime.

See [Upgrading to v2](https://docs.prestd.com/get-started/upgrading-to-v2.md) for migration guidance from v1.

Since **v2.4.2** ([#1017](https://github.com/prest/prest/pull/1017)), the token is validated against the algorithm configured in `jwt.algo` — not the one declared in the token's own header. A token signed with a different `alg` is rejected with `401`. Earlier v2 releases accepted the header's algorithm, which is what makes this a behavior change on upgrade.

Supported values, matched **case-sensitively**:

* The [HMAC signing method](https://en.wikipedia.org/wiki/HMAC): `HS256`, `HS384`, `HS512`
* The [RSA signing method](https://en.wikipedia.org/wiki/RSA_\(cryptosystem\)): `RS256`, `RS384`, `RS512`, and `PS256`, `PS384`, `PS512`
* The [ECDSA signing method](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm): `ES256`, `ES384`, `ES512`
* `EdDSA`

{% hint style="warning" %}
A value outside that set — including `hs256` in lowercase or an explicit `algo = ""` — makes **every request return HTTP 500** with `unsupported JWT signature algorithm`. Leave `jwt.algo` unset to get the `HS256` default.
{% endhint %}

The provided `jwt.key` or JWKS is then used to verify the signature.

Instead of the key, you could provide the URL of a .well-known OpenID configuration or the JWKS directly through `PREST_JWT_WELLKNOWNURL` or `PREST_JWT_JWKS` as environment variables or by using the TOML configuration file:

```toml
[jwt]
wellknownurl = https://accounts.google.com/.well-known/openid-configuration
jwks = {"keys": [{"kty": "RSA", "alg": "RS256", "kid": "93b495162af0c87cc7a51686294097040daf3b43", "n": "3NXwASNf_7-9hOWDKyZ39qgz-yl_npuIsBgxnhNoE7WyQQl-muajPsQRdFqM-HWsAAbS_WtLrmf2aRSmjXBm8wXHIeJjcrZiWeUnSyfZLDr13jxXhN0rDvdiZEsAlaKuh-iCgwC_pXd0TtWpaYlv5FFguuSitKTOiDR6z3eSZUd0XNxr8POCDQ7VlG_4HyzhsO7nOwgivO-PzekDEbcoLI93U8uzKZXYHSRxYWhoSp47PbM9D5WbuwXqbmXRp9TjiJUy6GqEOJ4K2FNvqe-g6C3BnpPVuHZNaVf8QGP806rWrWPdJ0irGBhg-EasC-sdFSrH3kxMxBFfVsuj69U-7Q", "use": "sig", "e": "AQAB" }]}
```

***prestd*** will parse the JWKS to find the corresponding key from the token and fail if it does not find it.

### White list

By default the `/auth` endpoint does not require JWT. The **whitelist** option configures which endpoints skip JWT verification. In v2, entries are **regular expressions**.

```toml
[jwt]
default = true
whitelist = ["^\\/auth$", "^\\/ping$", "^\\/ping\\/.*"]
```

### Auth

pREST has support in jwt token generation based on two fields (example user and password), being possible to use an existing table from your database to login configuring some parameters in the configuration file (or environment variable), *by default this feature is* **disabled**.

```toml
[auth]
enabled = true
type = "body"
encrypt = "bcrypt"
table = "prest_users"
username = "username"
password = "password"
token_ttl = "6h"
```

| Name        | Description                                                                                                                                                                                                                                                                        |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enabled`   | **Boolean** field that activates or deactivates token generation endpoint support                                                                                                                                                                                                  |
| `type`      | Type that will receive the login, support for **body and http basic authentication**                                                                                                                                                                                               |
| `encrypt`   | Type of encryption used in password field. v2 default is `bcrypt`; also supports `MD5` and `SHA1`                                                                                                                                                                                  |
| `table`     | Table name we will consult *(query)*                                                                                                                                                                                                                                               |
| `username`  | User **field** that will be consulted - if your software uses email just abstract name username (at prestd code level it was necessary to define an internal standard)                                                                                                             |
| `password`  | Password **field** that will be consulted                                                                                                                                                                                                                                          |
| `token_ttl` | How long a token issued by `/auth` stays valid (its `exp` claim), default `6h`. A Go duration such as `30m` or `12h`, or a number of seconds. A value under one second, or one that does not parse, fails startup. From v2.6.0 ([#1097](https://github.com/prest/prest/pull/1097)) |

> to validate all endpoints with generated jwt token must be activated jwt option

### Expose Data

The expose data settings control access to **discovery**, as opposed to `[access]`, which controls whether data can be read or written. They cover the REST listing routes:

* `/databases`
* `/schemas`
* `/tables`

and, since **v2.4.1** ([#1016](https://github.com/prest/prest/pull/1016)), the catalog surface of the [MCP endpoint](https://docs.prestd.com/get-started/mcp-over-http.md) — `/_mcp` previously bypassed these settings entirely, so a deployment that hid its catalog over REST still exposed it to any MCP client.

By default, all listing endpoints are **enabled** (`expose.enabled = false` means listings are allowed).

{% hint style="warning" %}
`enabled` is the master switch: the three per-listing flags **only take effect while `enabled = true`**. Setting `databases = false` on its own does nothing, because the default `enabled = false` allows every listing regardless.
{% endhint %}

To disable all listings:

```toml
[expose]
enabled = true
databases = false
schemas = false
tables = false
```

To disable just the database listing:

```toml
[expose]
enabled = true      # required
databases = false
schemas = true
tables = true
```

| Name        | Description                                                                        |
| ----------- | ---------------------------------------------------------------------------------- |
| `enabled`   | Set to `true` to activate exposure control. While `false`, everything is listable. |
| `databases` | With `enabled = true`, set to `false` to **disable** *databases* listing.          |
| `schemas`   | With `enabled = true`, set to `false` to **disable** *schemas* listing.            |
| `tables`    | With `enabled = true`, set to `false` to **disable** *tables* listing.             |

Environment overrides: `PREST_EXPOSE_ENABLED`, `PREST_EXPOSE_DATABASES`, `PREST_EXPOSE_SCHEMAS`, `PREST_EXPOSE_TABLES`.

**On MCP (v2.4.1+):** a denied listing removes the matching `prest.list_*` tool from discovery and makes `tools/call` return `400` with `unauthorized listing` (REST returns `401` for the same message). If **any** listing is denied, the per-table `prest.select.{database}.{schema}.{table}` tools are withheld too — their names and descriptions disclose table and column names. `prest.describe_table` and `prest.select_table` remain available, subject to [permissions](https://docs.prestd.com/get-started/permissions.md). See [MCP over HTTP — Safety and limits](https://docs.prestd.com/get-started/mcp-over-http.md#safety-and-limits).

#### Default values for Exposure Settings

| Name      | Default Value |
| --------- | ------------- |
| enabled   | `false`       |
| databases | `true`        |
| schemas   | `true`        |
| tables    | `true`        |

### SSL

PostgreSQL connection SSL is configured via `[pg.ssl]` in TOML or `PREST_PG_SSL_*` environment variables (v2). The legacy `[ssl]` block and `PREST_SSL_*` variables were removed in v2. See [Upgrading to v2](https://docs.prestd.com/get-started/upgrading-to-v2.md).

These settings only cover the connection from pREST to the database. To serve pREST's own API over HTTPS, use `[https]`. See [Serving over HTTPS](https://docs.prestd.com/deployment/serving-over-https.md).

There are 4 options to set on ssl mode:

| Name          | Description | Comment                                                                                                                       |
| ------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `require`     | Always SSL  | skips SSL verification step; v1 default                                                                                       |
| `disable`     | SSL off     | v2 default when no config file is found                                                                                       |
| `verify-ca`   | Always SSL  | verifies that the certificate presented is signed by a trusted CA                                                             |
| `verify-full` | Always SSL  | verifies that the certificate presented is signed by a trusted CA and the server host name matches the one in the certificate |

### Session time zone

Available from v2.6.0 ([#1106](https://github.com/prest/prest/pull/1106)).

`timestamptz` values come back in the session time zone of the connection, and `now()` and date arithmetic use it too. By default that is the server's `TimeZone` setting. To choose it, set `pg.timezone` to an [IANA time zone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones):

```toml
[pg]
timezone = "America/Sao_Paulo"
```

Every pooled connection starts in that zone, with no `SET` per request. A row stored as `2026-11-13T15:14:26Z` is then returned as:

```json
[{"at": "2026-11-13T12:14:26.485542-03:00", "id": 1}]
```

| Where                   | Setting                                                    | Wins over                                                                       |
| ----------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------- |
| Default connection      | `pg.timezone`, `PREST_PG_TIMEZONE`, `PREST_DB_TIMEZONE`    | `PREST_DB_TIMEZONE` wins over `PREST_PG_TIMEZONE`, which wins over the TOML key |
| Default connection URL  | `?timezone=` on `pg.url`, `PREST_PG_URL` or `DATABASE_URL` | `pg.timezone` and its variables                                                 |
| A `[[databases]]` entry | `timezone` in the entry                                    | `pg.timezone`, which the entry inherits when it sets none                       |
| A registry URL          | `?timezone=` on the entry `url` or `DATABASE_URL_N`        | The entry's `timezone`                                                          |

* Only IANA names are accepted, such as `UTC`, `Europe/Berlin` or `America/Sao_Paulo`. `Local`, a path, and any other value are logged (`config key invalid, using default key=pg.timezone`) and ignored, and the connection keeps the server default. Startup does not fail.
* If PostgreSQL itself does not know a zone pREST accepted (the server ships its own time zone data), pREST logs `postgres rejected session timezone, using server default` and reconnects without it.
* Postgres and TimescaleDB only. MySQL ignores the setting, and MySQL registry entries do not inherit `pg.timezone`.

### Application name

Available from v2.6.0 ([#1091](https://github.com/prest/prest/pull/1091)).

pREST names its PostgreSQL connections `prestd` by default, so you can tell them apart from other clients in `pg_stat_activity` and in the server log. Set `pg.application_name` to choose another name:

```toml
[pg]
application_name = "prestd-orders"
```

Or set it in the environment. `PREST_DB_APPLICATION_NAME` is read first, then `PREST_PG_APPLICATION_NAME`, then the TOML key.

* An empty value turns the name off. An empty variable counts as set, so `PREST_PG_APPLICATION_NAME=` turns it off even when `prest.toml` sets a name.
* pREST sends the name as libpq's `fallback_application_name`, so a name you already give the connection wins: `application_name` (or `fallback_application_name`) in `pg.url`, `DATABASE_URL` or a registry URL, or `PGAPPNAME` in the environment of `prestd`.
* The name is added each time pREST opens a connection, so every pooled connection carries it, including reconnects.
* PostgreSQL `[[databases]]` entries use the same name, even when the root `engine` is `mysql`. There is no per-entry key. MySQL connections do not use it.

To see it, query `pg_stat_activity`:

```sql
SELECT application_name, count(*)
FROM pg_stat_activity
GROUP BY application_name;
```

To show it in the PostgreSQL log, add `%a` to `log_line_prefix`, for example `log_line_prefix = '%m [%p] %a '`.

### Debug Mode

Set environment variable `PREST_DEBUG` or `debug=true` in `prest.toml`.

```toml
debug = true
```

Debug mode disables JWT middleware at runtime and bypasses startup JWT validation.

### Logging

v2 uses Go's `slog` package for structured logging. JSON logs are emitted to stdout on **every** startup.

Database credentials are redacted in error logs ([#972](https://github.com/prest/prest/pull/972)).

**Since v2.4.2** ([#1023](https://github.com/prest/prest/pull/1023)), logs no longer carry caller-influenced SQL or parameter values:

| Path                                        | What is logged                                                                                                                                                   |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Custom query scripts (`/_QUERIES`)          | **No SQL at any level**, on both the read and write paths — the statement is composed from a template the caller feeds. Use PostgreSQL statement logging instead |
| CRUD routes                                 | The statement at `debug`, with parameter **values** replaced by a count: `msg="generated SQL" parameter_count=2`                                                 |
| Script headers rejected by the value screen | A `warn` line naming the header only — never its value. Expect these on script endpoints hit by browsers                                                         |

Set the `PREST_LOG_LEVEL` environment variable to control verbosity:

| Level   | Description                                                               |
| ------- | ------------------------------------------------------------------------- |
| `debug` | CRUD SQL and detailed diagnostics                                         |
| `info`  | General operational messages                                              |
| `warn`  | Warnings such as public mode, config fallbacks, or auto-disabled features |
| `error` | Errors only                                                               |

### Custom queries storage

Filesystem scripts under `PREST_QUERIES_LOCATION` / `[queries] location` are the default. In **v2.2.0+**, database-backed storage and the `/_QUERIES/registry` admin API are also available — see [Custom Queries](https://docs.prestd.com/api-reference/custom-queries.md) and [v2.2.0](https://docs.prestd.com/releases/v2.2.0.md). The commented sample in [`samples/prest.sample.toml`](https://github.com/prest/prest/blob/v2.2.0/samples/prest.sample.toml) lists every `[queries]` key.

### pREST Studio

Embedded UI at `/_studio/` (v2.2.0+, enabled by default):

```toml
[studio]
enabled = true
```

Or `PREST_STUDIO_ENABLED=false` to disable. See [pREST Studio](https://docs.prestd.com/get-started/prest-studio.md).

### Configuration resilience

Since **v2.0.0** ([#974](https://github.com/prest/prest/pull/974)), pREST does not abort startup because of configuration problems. Instead it logs warnings and applies safe fallbacks:

| Problem                                                                                              | Fallback                                                                                                                                                                        |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Missing, unreadable, or malformed TOML                                                               | Viper defaults and environment overrides                                                                                                                                        |
| Invalid structured keys (`access.tables`, `cache.endpoints`, `databases`)                            | Zero/empty values + warning                                                                                                                                                     |
| Queries path unavailable                                                                             | Retry `~/queries`; if that fails, disable custom queries                                                                                                                        |
| Cache storage path unavailable                                                                       | Retry `./`; if that fails, disable cache                                                                                                                                        |
| Invalid database registry entry                                                                      | Entry skipped with warning                                                                                                                                                      |
| Unreachable registry entry (v2.5.2)                                                                  | Served lazily; answers `503` `database unavailable` until it connects                                                                                                           |
| `pg.single` / `PREST_PG_SINGLE` set (v2.5.2)                                                         | Ignored with a warning — see [Multi-database](https://docs.prestd.com/get-started/multi-database.md#migrating-from-pgsingle)                                                    |
| Unsafe JWT/auth config                                                                               | JWT or auth auto-disabled with error log                                                                                                                                        |
| HMAC `jwt.key` below the RFC 7518 minimum (v2.4.2+)                                                  | Key discarded, then auth/JWT auto-disabled with error log — see [Auth](https://docs.prestd.com/api-reference/auth.md#hmac-key-requirements-v242)                                |
| Invalid `pg.timezone` or `?timezone=` (v2.6.0+)                                                      | Ignored with a warning; the server default zone is used — see [Session time zone](#session-time-zone)                                                                           |
| `http.allowed_hosts` with entries but no host name in them (v2.6.0+)                                 | Error log; every request gets 400 instead of the check being turned off — see [Allowed hosts](#allowed-hosts)                                                                   |
| Invalid `http.request_id_header` (v2.6.0+)                                                           | Ignored with a warning; request IDs stay off — see [Request IDs](#request-ids)                                                                                                  |
| Invalid `[guard]` value (prest `main`, unreleased); for a boolean or number, even with the guard off | Error log; every request gets 500 instead of the guard being turned off — see [Request security](https://docs.prestd.com/get-started/request-security.md#invalid-configuration) |

Startup still fails on a few errors that cannot fall back safely: an unknown `engine` value, a MySQL connection without a user or database (v2.5.0), a registry where **every** entry is unreachable (v2.5.2), and, from v2.6.0, a `PREST_CONFIG_JSON` document that cannot be applied (see [Configuration as JSON](#configuration-as-json)).

### Multi-database

pREST supports routing to multiple databases or clusters via a database registry: configure `[[databases]]` entries or `DATABASE_ALIAS_N` / `DATABASE_URL_N` environment pairs. Without a registry, list extra databases on the `[pg]` host in `pg.allowed_databases`. `pg.single` was removed in v2.5.2 and is ignored with a warning.

See the [Multi-database guide](https://docs.prestd.com/get-started/multi-database.md) for URL routing, TOML examples, Kubernetes setup, and connection pooling. Full sample: [examples/multi-database-config.toml](https://github.com/prest/docs/tree/main/get-started/examples/multi-database-config.toml).

Since **v2.3.0** ([#999](https://github.com/prest/prest/pull/999)), each alias can auto-select a **Postgres or Timescale** adapter. **v2.5.0** adds an explicit `engine = "mysql"` dialect ([#1048](https://github.com/prest/prest/pull/1048)). SQLite is still roadmap.

### Observability (OpenTelemetry) (v2.4.0)

Since **v2.4.0** ([#1003](https://github.com/prest/prest/pull/1003)), pREST supports **opt-in** OTLP/gRPC push telemetry — HTTP, Postgres, and MCP traces; `http.server.*` / `db.client.operation.duration` / `db.sql.connection.*` metrics; and a `slog` → OTel logs bridge that still writes to stdout. No new HTTP route is added — there is no `/metrics` scrape endpoint.

```toml
[otel]
enabled = false
service_name = "prestd"
# endpoint = "otel-collector:4317"
protocol = "grpc"
sample_ratio = 1.0
metrics_interval = "15s"
insecure = false
db_statement = false
```

| Key                | Env override                  | Default   | Purpose                                                            |
| ------------------ | ----------------------------- | --------- | ------------------------------------------------------------------ |
| `enabled`          | `PREST_OTEL_ENABLED`          | `false`   | Master switch — zero overhead and no outbound connections when off |
| `service_name`     | `PREST_OTEL_SERVICE_NAME`     | `prestd`  | Resource `service.name`                                            |
| `endpoint`         | `PREST_OTEL_ENDPOINT`         | *(unset)* | OTLP gRPC collector `host:port`                                    |
| `protocol`         | `PREST_OTEL_PROTOCOL`         | `grpc`    | Only `grpc` for now                                                |
| `sample_ratio`     | `PREST_OTEL_SAMPLE_RATIO`     | `1.0`     | Trace head sampling, clamped `0.0–1.0`                             |
| `metrics_interval` | `PREST_OTEL_METRICS_INTERVAL` | `15s`     | Metric export period                                               |
| `insecure`         | `PREST_OTEL_INSECURE`         | `false`   | Disable TLS to collector (local/dev)                               |
| `db_statement`     | `PREST_OTEL_DB_STATEMENT`     | `false`   | Record SQL text on DB spans (trusted environments only)            |

If the exporter can't be built at startup, pREST logs a warning and keeps serving with telemetry disabled — setup fails closed. A self-contained SigNoz stack lives under `dev/signoz/` in the pREST repo (`make signoz-up` / `make signoz-down`) for local viewing. See [v2.4.0 release notes](https://docs.prestd.com/releases/v2.4.0.md).

### Allowed hosts

Available from v2.6.0 ([#1107](https://github.com/prest/prest/pull/1107)).

By default pREST answers a request whatever its `Host` header says. Anything that builds a URL or a cache entry from that header can then be pointed at a host you never meant to serve (an HTTP Host header attack). `http.allowed_hosts` lists the host names pREST serves:

```toml
[http]
allowed_hosts = ["api.example.com", ".example.org", "10.0.0.12"]
```

Or as a comma-separated variable: `PREST_HTTP_ALLOWED_HOSTS=api.example.com,.example.org,10.0.0.12`.

A request for any other host gets **400** `{"error": "invalid Host header"}` before routing, auth, or CORS run, so preflight requests are refused too. The rejection is logged as `request rejected: host not in http.allowed_hosts`.

| Entry             | Matches                                                                |
| ----------------- | ---------------------------------------------------------------------- |
| `api.example.com` | That host, in any case and on any port: `API.example.com:3000` matches |
| `.example.org`    | `example.org` and every subdomain, such as `a.b.example.org`           |
| `*`               | Every host, including a request with no `Host` header                  |
| `::1` or `[::1]`  | The IPv6 loopback, written either way                                  |

* Unset or empty serves every host, as before.
* Entries are host names: a port is dropped with a warning, so `127.0.0.1:3000` is read as `127.0.0.1`. A trailing dot is ignored.
* If the setting has entries but none is a host name (such as `.` or `:8080`), every request gets 400. pREST logs an error instead of turning the check off.
* An HTTP/1.0 request without a `Host` header only matches `*`.

{% hint style="warning" %}
`/_health` and `/_ready` are checked too. Add the host your load balancer and probes send, often the pod or instance IP, or the probes fail with 400. A Kubernetes `httpGet` probe sends the pod IP unless you set `httpHeaders` with a `Host`.
{% endhint %}

### Request IDs

Available from v2.6.0 ([#1114](https://github.com/prest/prest/pull/1114)).

A request ID ties a client's error report to the access-log line of the same request. Set `http.request_id_header` to the header that carries it:

```toml
[http]
request_id_header = "X-Request-Id"
```

Or as a variable: `PREST_HTTP_REQUEST_ID_HEADER=X-Request-Id`. Unset, or empty in `prest.toml`, pREST adds no request ID and the access log keeps its usual format.

| Incoming header value                                                                                             | Request ID pREST uses                         |
| ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| 1 to 200 printable ASCII characters, no spaces                                                                    | The client's value, unchanged                 |
| Missing, empty, longer than 200 characters, or containing a space, a control character or any non-ASCII character | 32 lowercase hex characters (128 random bits) |

A value that does not qualify is replaced, never rejected.

* The header name is canonicalised, so `x-request-id` is used as `X-Request-Id`. A name that is not a valid header field name logs `http.request_id_header is not a valid header name, request IDs are disabled` and turns the feature off. Startup still succeeds.
* pREST sets the ID on the response before routing, auth or the host check run, so error responses carry it too: `400`, `404`, a request refused by [Allowed hosts](#allowed-hosts), and the `500` from a panic pREST recovers before it starts the response.
* Each access-log line ends with `|` and the request ID.
* When CORS is on, pREST lists the header in `Access-Control-Expose-Headers`, so browser scripts can read it. A browser that sends its own ID still needs the header in `cors.allowheaders`. See [CORS Support](https://docs.prestd.com/get-started/cors-support.md).
* Handlers get the ID in the request header. Plugins read it with `middlewares.RequestIDFromContext(r.Context())`, which returns `""` when request IDs are off.
* A client chooses its own ID, so request IDs are neither authenticated nor guaranteed unique.

### Request security

{% hint style="warning" %}
**Requires prest `main` (unreleased)** — [#1044](https://github.com/prest/prest/pull/1044).
{% endhint %}

`[guard]` is an opt-in middleware for per-client rate limits, attack payload inspection, IP allow and block lists, auto-bans and cloud provider range blocking, with optional shared state in Redis. It is off by default. See [Request security](https://docs.prestd.com/get-started/request-security.md).

### CORS support

**Cross-Origin Resource Sharing**

`[cors]` sets which browser origins, request headers and methods may call pREST. The defaults allow every origin but only the `Content-Type` header and no `PATCH`, so a browser app that sends `Authorization` needs `allowheaders` changed. See [CORS Support](https://docs.prestd.com/get-started/cors-support.md).

### Health check endpoints

| Endpoint       | Purpose   | Behavior                                                                                                                                      |
| -------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /_health` | Liveness  | Pings the default database. Returns 503 when unhealthy.                                                                                       |
| `GET /_ready`  | Readiness | Pings the default database and every registered alias ([#973](https://github.com/prest/prest/pull/973)). Use for Kubernetes readiness probes. |

For multi-database deployments, prefer `/_ready` over `/_health` as the readiness probe. See [Deploying with Docker](https://docs.prestd.com/deployment/deploying-with-docker.md).

## Related

* [Multi-database](https://docs.prestd.com/get-started/multi-database.md)
* [examples/multi-database-config.toml](https://github.com/prest/docs/tree/main/get-started/examples/multi-database-config.toml)
* [MCP over HTTP](https://docs.prestd.com/get-started/mcp-over-http.md)
* [pREST Studio](https://docs.prestd.com/get-started/prest-studio.md)
* [Custom Queries](https://docs.prestd.com/api-reference/custom-queries.md)
* [Auth](https://docs.prestd.com/api-reference/auth.md)
* [Request security](https://docs.prestd.com/get-started/request-security.md)
* [v2.6.0 release notes](https://docs.prestd.com/releases/v2.6.0.md)
* [v2.4.2 release notes](https://docs.prestd.com/releases/v2.4.2.md)
* [v2.4.1 release notes](https://docs.prestd.com/releases/v2.4.1.md)
* [v2.4.0 release notes](https://docs.prestd.com/releases/v2.4.0.md)
* [Acronyms](https://docs.prestd.com/readme/acronyms.md) · [JWT](https://docs.prestd.com/readme/acronyms.md#jwt) · [MCP](https://docs.prestd.com/readme/acronyms.md#mcp)
