# Self-hosting

> Keep the map only as files, or run the Cases server yourself.

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

For agents: Two ways without Sypnia Cloud: (1) files only: the map in cases/, `npx @sypnia/cases check` in CI, reviews as pull requests; (2) the Cases server with Docker: docker compose up (server + Postgres 16), env CASES_DATABASE_URL, CASES_AUTH_ISSUER (any OIDC issuer, e.g. your Sypnia Data project), CASES_PUBLIC_URL, CASES_SMTP_URL, and optional CASES_MAIL_FROM, CASES_APP_DATABASE_URL (deliveries and dead letters), CASES_SECRET_KEY, CASES_AUTH_AUDIENCE, CASES_MCP_URL, CASES_CORS_ORIGINS, CASES_RATE_LIMIT (600/min), CASES_LINK_BUDGET_MS, CASES_ROLE_CACHE_MS, CASES_ORIGIN_SECRET, CASES_DIRECTORY (self|sypnia), CASES_SYPNIA_API, CASES_TELEMETRY_API, PORT; the compose file runs the server as a role without superuser that owns the database; API on :8070. Running cases needs no server: the runtime is part of @sypnia/cases in each area's service, on your Postgres (LISTEN/NOTIFY + deliveries table) or on AWS through Sypnia Run's engine. No visual editor outside Sypnia Cloud. CASES_SERVICE_KEY (≥ 32 characters): the key shared with a Sypnia Data control plane for calls on behalf of a verified person (Authorization: Service); without it the caller's own token is presented. CASES_SSM: on Lambda, settings read from SSM at start (NAME=/path pairs).

## Files only

Most teams need nothing else: the map in `cases/`, `npx @sypnia/cases check` in CI, and pull requests as reviews. No server, no account.

## The Cases server

When you want the API, proposals with approvals and the MCP server on your own infrastructure:

```bash
git clone https://github.com/sespinosav/sypnia-cases && cd sypnia-cases/deploy
cp .env.example .env
docker compose up -d
```

| Setting                                   | What it is                                                                                                                                                                                                                                                                        |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CASES_DATABASE_URL`                      | any Postgres 14+; the server creates its `cases` schema on first start. The compose file creates the database owned by a role without superuser, `cases_server`                                                                                                                   |
| `CASES_AUTH_ISSUER`                       | the OIDC issuer that signs your users' tokens: a Sypnia Data project, or any other                                                                                                                                                                                                |
| `CASES_PUBLIC_URL`                        | the address people use (HTTPS in production); DPoP proofs and links are checked against it                                                                                                                                                                                        |
| `CASES_SMTP_URL`                          | for review e-mails (optional): `smtp://user:password@host:587` (STARTTLS) or `smtps://…:465`                                                                                                                                                                                      |
| `CASES_MAIL_FROM`                         | the sender of those e-mails (default `Sypnia Cases <cases@localhost>`)                                                                                                                                                                                                            |
| `CASES_APP_DATABASE_URL`                  | your app's database, to read deliveries and dead letters from its `sypnia_cases` schema; one app database per server                                                                                                                                                              |
| `CASES_SECRET_KEY`                        | 32 bytes (64 hex characters, or base64) to keep tokens of other products, such as a map's Telemetry token, encrypted; without it they are not kept                                                                                                                                |
| `CASES_AUTH_AUDIENCE`                     | the accepted `aud` of tokens, comma-separated; `*` accepts any. Default: `authenticated`, the public address, its `/mcp`, and `CASES_MCP_URL`                                                                                                                                     |
| `CASES_MCP_URL`                           | the MCP endpoint's own public address, when it is not `CASES_PUBLIC_URL` plus `/mcp`                                                                                                                                                                                              |
| `CASES_CORS_ORIGINS`                      | the browser origins allowed to call the API, comma-separated                                                                                                                                                                                                                      |
| `CASES_RATE_LIMIT`                        | requests a minute per credential (600 by default; `0`: no limit)                                                                                                                                                                                                                  |
| `CASES_LINK_BUDGET_MS`                    | how long a link waits for another product (2000 by default)                                                                                                                                                                                                                       |
| `CASES_ROLE_CACHE_MS`                     | how long a role read from Sypnia is kept (60000 by default)                                                                                                                                                                                                                       |
| `CASES_ORIGIN_SECRET`                     | when set, the server answers only requests with this value in the `x-origin-secret` header (behind a CDN)                                                                                                                                                                         |
| `CASES_DIRECTORY`                         | `self` (the default: workspaces and members live in the server) or `sypnia` (workspaces are Sypnia organizations)                                                                                                                                                                 |
| `CASES_SYPNIA_API`, `CASES_TELEMETRY_API` | Sypnia's control plane (`https://data.api.sypnia.com`) and Telemetry's API (`https://telemetry.api.sypnia.com`), for links                                                                                                                                                        |
| `CASES_SERVICE_KEY`                       | the key this server shares with a Sypnia Data control plane (at least 32 characters), for calls on behalf of a person it verified, both ways. Empty by default: the server then presents each person's own token to the other product, so a session bound to a key cannot read it |
| `CASES_SSM`                               | on AWS Lambda: settings read from SSM Parameter Store when the function starts, as `NAME=/parameter/path` pairs separated by commas                                                                                                                                               |
| `PORT`                                    | the port to listen on (8070)                                                                                                                                                                                                                                                      |

The server answers on port `8070`: the API at `/v1`, MCP at `/mcp`, health at `/health`. It applies its own migrations at every start, safely from several replicas at once. The visual editor is part of Sypnia Cloud and is not included.

With `CASES_APP_DATABASE_URL`, members see each listener's deliveries and dead letters, and owners, editors and approvers send them again or drop them (with a reason) through the API. Without it, those endpoints answer `409 no_app_database`.

## Running your cases without Sypnia Cloud

Running cases needs neither the Cases server nor Sypnia Cloud. The runtime is part of `@sypnia/cases` in each area's service: point every service at the same Postgres and events flow between them through the `sypnia_cases` tables, with the same retries, dead letters and loop guard ([Delivery](https://cases.docs.sypnia.com/runtime/delivery#in-sypnia-cloud-and-without-aws)). On your own AWS account, Sypnia Run's open-source engine sets up EventBridge and a queue per listener from the map.
