# Configuration

> Every setting of the engine and of a project, with its default, and every command of the engine's binary.

Applies to: the Sypnia engine (open source, self-hosted).  
Source: https://data.docs.sypnia.com/self-hosting/configuration/

For agents: Engine environment: SYPNIA_DATA_MASTER_KEY (required, 32 bytes base64) or SYPNIA_DATA_MASTER_KEY_KMS (+ SYPNIA_DATA_KMS_KEY_ID), SYPNIA_DATA_PUBLIC_URL, DATABASE_URL or DATABASE_URL_AUTHENTICATOR + DATABASE_URL_ADMIN, SYPNIA_DATA_PROJECTS_FILE (projects.toml: [[project]] ref, host/hosts, public_url, database_url, database_url_admin, database_url_authenticator, admin_role, authenticator_role), SYPNIA_DATA_LISTEN (0.0.0.0:8080), SYPNIA_DATA_POOL_MAX (2 Lambda / 10 server), SYPNIA_DATA_TICK (internal|external), SYPNIA_DATA_MAX_ROWS (1000), SYPNIA_DATA_MAIL (smtp|resend|postmark|ses|none) with SYPNIA_DATA_SMTP_URL, _RESEND_API_KEY, _POSTMARK_TOKEN, _SES_REGION, _SES_CONFIGURATION_SET, SYPNIA_DATA_MAIL_FROM, SYPNIA_DATA_MAIL_DEFAULT_REFS, SYPNIA_DATA_MAIL_DEFAULT_HOURLY_CAP (0 = none), SYPNIA_DATA_MAIL_UNCAPPED_REFS, SYPNIA_DATA_LOG (info), SYPNIA_DATA_INSTALL_ON_START, <NAME>_SSM for DATABASE_URL/MASTER_KEY/SMTP_URL/RESEND_API_KEY/POSTMARK_TOKEN/ORIGIN_SECRET, SYPNIA_DATA_DATABASE_SECRET_ARN + _HOST/_PORT/_NAME, SYPNIA_DATA_ORIGIN_SECRET, SYPNIA_DATA_MCP_URL, SYPNIA_DATA_ACCOUNT_PROJECT, SYPNIA_DATA_CONTROL_PLANE_URL, SYPNIA_DATA_ROLE=events, SYPNIA_DATA_OFFLINE, SYPNIA_DATA_NEW_PASSWORD; Sypnia Cloud's: SYPNIA_DATA_REGISTRY_URL(_SSM), SYPNIA_DATA_PROJECT_DOMAIN, SYPNIA_DATA_PROJECTS_SSM, SYPNIA_DATA_MASTER_URL / SYPNIA_DATA_PROVISIONER_URL_SSM. Commands: sypnia-data serve [--install], health, install [--print-sql] [--ref], provision <ref>, keys rotate|api-key, users create, registry seal, tick. Events function actions: provision, install_byo, deprovision, api_key, protect_key, rotate_protected_key, upgrade. Project settings in sypnia_data.settings via GET/PATCH /auth/v1/admin/settings: session_policy, require_email_confirmation, signup_open, password_policy, site_url, redirect_urls, providers, mail, templates, captcha, exposed_schemas, rate_limits, dynamic_client_registration, cross_subdomain, otp_ttl, project_name, device_verification_uri, consent_url, cors_origins.

Two kinds of settings: the **engine's**, from the environment, and each **project's**, kept in its database and changed with the admin API (`/auth/v1/admin/settings`) or the console.

## The engine

| Variable                                                   | Default                        | What                                                                                                                                                                                                                                      |
| ---------------------------------------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SYPNIA_DATA_MASTER_KEY`                                   | — (required unless KMS)        | 32 bytes, base64; encrypts signing keys and credentials                                                                                                                                                                                   |
| `SYPNIA_DATA_MASTER_KEY_KMS`                               | —                              | instead of the master key: the master key encrypted with AWS KMS (`aws kms generate-data-key`, ciphertext blob, base64); the engine decrypts it at start-up                                                                               |
| `SYPNIA_DATA_KMS_KEY_ID`                                   | —                              | the KMS key that seals each project's database connection in the registry (Sypnia Cloud)                                                                                                                                                  |
| `SYPNIA_DATA_PUBLIC_URL`                                   | `http://localhost:8080`        | the address people reach; used in e-mail links and token `iss`                                                                                                                                                                            |
| `DATABASE_URL`                                             | —                              | one project's database, as a user that can install                                                                                                                                                                                        |
| `DATABASE_URL_AUTHENTICATOR`, `DATABASE_URL_ADMIN`         | —                              | instead of `DATABASE_URL`, after a manual install                                                                                                                                                                                         |
| `SYPNIA_DATA_PROJECTS_FILE`                                | —                              | `projects.toml`: several projects ([below](#several-projects))                                                                                                                                                                            |
| `SYPNIA_DATA_LISTEN`                                       | `0.0.0.0:8080`                 | server mode                                                                                                                                                                                                                               |
| `SYPNIA_DATA_POOL_MAX`                                     | 2 on Lambda, 10 otherwise      | connections per project per instance                                                                                                                                                                                                      |
| `SYPNIA_DATA_TICK`                                         | `external`                     | `internal`: run e-mail retries and cleanup every minute in-process; `external`: run `sypnia-data tick` yourself, or the events function                                                                                                   |
| `SYPNIA_DATA_MAX_ROWS`                                     | `1000`                         | rows per Data API response                                                                                                                                                                                                                |
| `SYPNIA_DATA_MAIL`                                         | `none`                         | the engine's own sender: `smtp`, `resend`, `postmark`, `ses`, `none`                                                                                                                                                                      |
| `SYPNIA_DATA_SMTP_URL`                                     | —                              | `smtps://user:pass@host:465`                                                                                                                                                                                                              |
| `SYPNIA_DATA_RESEND_API_KEY`, `SYPNIA_DATA_POSTMARK_TOKEN` | —                              | HTTP providers                                                                                                                                                                                                                            |
| `SYPNIA_DATA_SES_REGION`                                   | the instance's region          | SES with the instance's AWS credentials                                                                                                                                                                                                   |
| `SYPNIA_DATA_SES_CONFIGURATION_SET`                        | —                              | the SES configuration set whose bounces and complaints reach the events function                                                                                                                                                          |
| `SYPNIA_DATA_MAIL_FROM`                                    | —                              | `Name <address>`; the project's name replaces `Name`                                                                                                                                                                                      |
| `SYPNIA_DATA_MAIL_DEFAULT_REFS`                            | all projects                   | the projects that may send through the engine's own sender, comma-separated (`*` = all). The others need [their own provider](https://data.docs.sypnia.com/auth/email-providers-and-templates#without-a-provider). Sypnia Cloud: `sypnia` |
| `SYPNIA_DATA_MAIL_DEFAULT_HOURLY_CAP`                      | `0` (no cap)                   | e-mails per hour per project through the engine's own sender; past it, `429 rate_limited`                                                                                                                                                 |
| `SYPNIA_DATA_MAIL_UNCAPPED_REFS`                           | —                              | projects exempt from that cap, comma-separated                                                                                                                                                                                            |
| `SYPNIA_DATA_LOG`                                          | `info`                         | `debug`, `info`, `warn` (JSON lines on stdout)                                                                                                                                                                                            |
| `SYPNIA_DATA_INSTALL_ON_START`                             | `false`                        | `true`: `serve` installs or upgrades the schema in `DATABASE_URL` first, waiting for the database (the Docker and AWS setups use it)                                                                                                      |
| `<NAME>_SSM`                                               | —                              | for `DATABASE_URL`, `SYPNIA_DATA_MASTER_KEY`, `SYPNIA_DATA_SMTP_URL`, `SYPNIA_DATA_RESEND_API_KEY`, `SYPNIA_DATA_POSTMARK_TOKEN`, `SYPNIA_DATA_ORIGIN_SECRET`: the name of an SSM SecureString read at start instead of the value         |
| `SYPNIA_DATA_DATABASE_SECRET_ARN`                          | —                              | a Secrets Manager secret `{username, password}` (the RDS format); with `SYPNIA_DATA_DATABASE_HOST`, `_PORT` (5432) and `_NAME` (postgres) it becomes `DATABASE_URL` with TLS                                                              |
| `SYPNIA_DATA_ORIGIN_SECRET`                                | —                              | when set, requests must carry `X-Sypnia-Origin` with this value, or get `403 direct_access` (put it on your CDN, so nobody can skip it)                                                                                                   |
| `SYPNIA_DATA_MCP_URL`                                      | `<SYPNIA_DATA_PUBLIC_URL>/mcp` | where the [MCP server](https://data.docs.sypnia.com/machines/mcp) answers; also its OAuth resource indicator                                                                                                                              |
| `SYPNIA_DATA_ACCOUNT_PROJECT`                              | —                              | the project whose users are accounts with organizations (`cloud.*` tables), so their tokens reach their organizations' projects through MCP (Sypnia Cloud: `sypnia`)                                                                      |
| `SYPNIA_DATA_CONTROL_PLANE_URL`                            | —                              | the control plane MCP's `create_project` calls (Sypnia Cloud: `https://data.api.sypnia.com`)                                                                                                                                              |
| `SYPNIA_DATA_ROLE`                                         | —                              | `events`: on Lambda, this function handles the minute tick, SES bounces from SNS and the [control actions](#the-events-function) instead of HTTP                                                                                          |
| `SYPNIA_DATA_OFFLINE`                                      | —                              | set: skip the breached-password lookup (an engine without internet access)                                                                                                                                                                |
| `SYPNIA_DATA_NEW_PASSWORD`                                 | —                              | read only by `sypnia-data users create`: the new user's password                                                                                                                                                                          |

### Sypnia Cloud's own

The same binary runs Sypnia Cloud with a few more settings. You do not need them to self-host:

| Variable                                                    | What                                                                                                                                                   |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `SYPNIA_DATA_REGISTRY_URL` (or `_SSM`)                      | the database that holds `cloud.projects`, the registry of hosted projects (read every 60 s)                                                            |
| `SYPNIA_DATA_PROJECT_DOMAIN`                                | `<ref>.<domain>` is a project: `data.sypnia.com`                                                                                                       |
| `SYPNIA_DATA_PROJECTS_SSM`                                  | an SSM SecureString with a JSON array of projects outside the registry, with the fields of `projects.toml` (Sypnia's own project at `auth.sypnia.com`) |
| `SYPNIA_DATA_MASTER_URL`, `SYPNIA_DATA_PROVISIONER_URL_SSM` | the shared Postgres server where `provision` creates managed databases                                                                                 |

## Several projects

A self-hosted engine serves one project, `default`, from `DATABASE_URL`, on any host. To serve several, list them in `projects.toml`:

`projects.toml`

```toml
[[project]]
ref = "shop"
host = "api.laespiga.co"
database_url = "postgres://sypnia_admin:…@db.example.com:5432/shop?sslmode=verify-full"

[[project]]
ref = "admin"
hosts = ["admin-api.laespiga.co", "admin-api.internal"]
public_url = "https://admin-api.laespiga.co"
database_url_admin = "postgres://sypnia_admin:…@db.example.com:5432/admin"
database_url_authenticator = "postgres://sypnia_authenticator:…@db.example.com:5432/admin"
```

| Field                                              | What                                                                                           |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `ref`                                              | the project's name: a slug, used in keys (`syp_pk_<ref>_…`) and tokens                         |
| `host`, `hosts`                                    | the hosts that reach it                                                                        |
| `public_url`                                       | its address; by default `https://` and its first host                                          |
| `database_url`                                     | a user that can install; or the two below                                                      |
| `database_url_admin`, `database_url_authenticator` | after a [manual install](https://data.docs.sypnia.com/data/any-postgres#locked-down-databases) |
| `admin_role`, `authenticator_role`                 | role names other than `sypnia_admin` and `sypnia_authenticator`                                |

Each project keeps its own database, keys and settings.

## The engine's commands

The binary is `sypnia-data`. Every command reads the environment above.

### `sypnia-data serve`\[Engine]Serves HTTP on `SYPNIA_DATA_LISTEN`, or the Lambda runtime when it runs in AWS Lambda. It is also what the binary does with no command.

**Flags:**

None.

### `sypnia-data health`\[Engine]Exits 0 when the local server answers `/health` with 200. The container's healthcheck (the image has no `curl`).

### `sypnia-data install`\[Engine]Installs or upgrades the engine's schemas and roles in `DATABASE_URL`. Safe to run again: it applies only what is missing.

**Flags:**

None.

### `sypnia-data provision`\[Engine]`sypnia-data provision <ref>` creates a managed project's database and roles on the server of `SYPNIA_DATA_MASTER_URL` and prints its sealed registry value. With `--static-ssm <parameter> --host <host> [--public-url <url>]` it registers the project in that SSM parameter instead.

### `sypnia-data keys rotate`\[Engine]Publishes a new signing key; it signs 24 hours later.

**Flags:**

None.

### `sypnia-data keys api-key`\[Engine]Creates an API key and prints it once.

**Flags:**

None.

### `sypnia-data users create`\[Engine]`sypnia-data users create <email>` creates a confirmed user, with the password in `SYPNIA_DATA_NEW_PASSWORD`, or «e-mail first» when it is not set.

**Flags:**

None.

### `sypnia-data registry seal`\[Engine]`sypnia-data registry seal <ref>` reads a value from stdin and prints it sealed for that project's registry row.

### `sypnia-data tick`\[Engine]Runs the minute's work once for every known project: e-mail retries and the cleanup of expired tokens, assertion ids and old audit rows.

## The events function

On AWS, the function with `SYPNIA_DATA_ROLE=events` runs the minute tick and the SES bounce handling, and answers these actions when invoked directly (IAM decides who may invoke it):

| `action`               | Takes                                | Does                                                   |
| ---------------------- | ------------------------------------ | ------------------------------------------------------ |
| `api_key`              | `ref`, `kind`, `name?`, `protected?` | creates an API key: `{ id, key, protected }`           |
| `protect_key`          | `ref`, `id`                          | marks an existing key protected                        |
| `rotate_protected_key` | `ref`, `id`                          | replaces a protected key: `{ id, key }`                |
| `upgrade`              | `ref`                                | applies the engine's pending migrations to the project |
| `provision`            | `ref`                                | creates a managed database on the shared server        |
| `install_byo`          | `ref`, `url`                         | installs the engine in your own Postgres               |
| `deprovision`          | `ref`                                | drops a managed project's database and roles           |

```bash
aws lambda invoke --function-name my-data-events --cli-binary-format raw-in-base64-out \
  --payload '{"action":"api_key","ref":"default","kind":"publishable"}' /dev/stdout
```

## A project

Kept in `sypnia_data.settings`, one row per key. Read them with `GET /auth/v1/admin/settings` and change any of them with `PATCH /auth/v1/admin/settings` and a secret key; an object is merged into the stored one, and credentials come back as `"[redacted]"`. Changes apply within a minute.

| Setting                       | Default                                                                                                                           | What                                                                                                                                                             |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `session_policy`              | `{ access_token_ttl: 3600, session_lifetime: null, inactivity_timeout: null, single_session: false, refresh_reuse_interval: 10 }` | [how long sessions live](https://data.docs.sypnia.com/auth/sessions-and-tokens#how-long-a-session-lives); `null` is never                                        |
| `require_email_confirmation`  | `true`                                                                                                                            | sign-up needs a confirmed e-mail                                                                                                                                 |
| `signup_open`                 | `true`                                                                                                                            | `false` closes sign-ups (`403 signup_disabled`); admins still create and invite users                                                                            |
| `password_policy`             | `{ min_length: 10, require: [], breached_check: true }`                                                                           | `require`: any of `lower`, `upper`, `digit`, `symbol`                                                                                                            |
| `site_url`                    | —                                                                                                                                 | your app's address: the default return of e-mail links                                                                                                           |
| `redirect_urls`               | `[]`                                                                                                                              | allowed `redirect_to` values: exact addresses or patterns such as `https://*.myapp.com/**`                                                                       |
| `providers`                   | e-mail on                                                                                                                         | `email` (`true` or `false`), `google` and `github` (`{ enabled, client_id, client_secret }`)                                                                     |
| `mail`                        | no provider                                                                                                                       | the [e-mail provider](https://data.docs.sypnia.com/auth/email-providers-and-templates#choosing-a-provider)                                                       |
| `templates`                   | the engine's                                                                                                                      | [e-mail templates](https://data.docs.sypnia.com/auth/email-providers-and-templates#templates) per type and language                                              |
| `captcha`                     | none                                                                                                                              | `{ provider: "turnstile" \| "hcaptcha", secret }`                                                                                                                |
| `exposed_schemas`             | `["public"]`                                                                                                                      | the schemas the Data API serves                                                                                                                                  |
| `rate_limits`                 | see [protections](https://data.docs.sypnia.com/auth/protections#rate-limits)                                                      | `signup_per_hour_per_ip`, `otp_per_hour_per_email`, `otp_per_hour_per_ip`, `password_per_5min`, `refresh_per_hour_per_session`, `oauth_token_per_min_per_client` |
| `dynamic_client_registration` | `false`                                                                                                                           | open [dynamic client registration](https://data.docs.sypnia.com/machines/mcp#how-it-signs-in)                                                                    |
| `cross_subdomain`             | none                                                                                                                              | `{ domain: ".example.com" }`: [one session across your apps](https://data.docs.sypnia.com/auth/users-and-your-data#several-apps-one-sign-in)                     |
| `otp_ttl`                     | `3600`                                                                                                                            | lifetime of links and codes, 300 to 86 400 seconds                                                                                                               |
| `project_name`                | the ref                                                                                                                           | the name e-mails show                                                                                                                                            |
| `device_verification_uri`     | the engine's `/auth/v1/device`                                                                                                    | your page where a person approves a device code (Sypnia Cloud: `https://data.app.sypnia.com/device`)                                                             |
| `consent_url`                 | the engine's `/auth/v1/oauth/consent`                                                                                             | your page where a person approves an OAuth client                                                                                                                |
| `cors_origins`                | `[]`                                                                                                                              | origins that may use the session cookie, patterns such as `https://*.example.com`                                                                                |

An unknown key answers `400 unknown_setting`; a session policy out of range, `400 invalid_session_policy`.
