---
title: "Platform setup"
description: "Configure and test mail, Stripe, the AI key, proxies, the KMS and off-host backups from the staff console, and what still needs the host."
keywords: ["platform setup", "staff console", "SMTP", "Stripe", "ANTHROPIC_API_KEY", "TRUSTED_PROXIES", "re-encryption", "audit checkpoints", "backups"]
---

**Staff console → Platform setup** (`/staff/setup`) is where a platform admin finishes a
deployment's setup without SSH: each item shows whether it is **done**, **not set** or **failing
its check**, what it is for, and a **Test** or **Verify** button that makes one real call.

## Who can use it

Only the `platform_admin` staff role (capability `platform:setup`). The page sits inside the
[staff console](/deployment/staff-console), so `STAFF_ALLOWED_CIDRS` applies to it: from any other
address it answers `404`. A customer's session, even an organization owner's, reaches nothing on
it (`401`: the staff authenticator never reads a customer credential).

Changing a **secret**, generating the audit checkpoint key, rotating the demo owner's password and
applying a re-encryption also need your second factor from the **last ten minutes**. Signing in
counts; after that the page asks for a code (`POST /api/v1/staff/step-up`) and retries.

## Where values live and which one wins

| | |
|---|---|
| **Environment wins** | A variable set (non-blank) in the process environment is used, and the page shows it as *Set by the environment*, read-only. To manage it here, remove it from the env file and restart. |
| **Otherwise the stored value** | Kept in `platform_config` (migration 181). A secret is encrypted with the platform keyring (`TOKEN_ENCRYPTION_KEY`, purpose `platform-config`) and bound to its row; the table refuses a row that holds both a plaintext and a ciphertext. |
| **Write-only secrets** | The API never returns a secret: only *set / not set*, the last four characters for an API key (never for a password), and who set it when. |
| **Audit** | Every change is in the platform trail as `staff.platform_config_changed` with the key and HMAC fingerprints of the old and new value, never the value. Checks are `staff.setup_check_run`. |

**When a change applies.** Keys marked live apply within seconds on every replica: each replica
caches settings for 15 seconds and a change is announced to the others through Redis. The rest are
read once at startup and say **Applies at the next restart** (and **Restart pending** once
changed): `TRUSTED_PROXIES`, `BILLING_PROVIDER` and every `STRIPE_*`, `KMS_PROVIDER` and
`KMS_KEY_ID`. A stored combination that does not validate at startup (for example
`BILLING_PROVIDER=stripe` with no secret key) is not applied at all: the process logs why and runs
on its environment alone, so a bad value can never keep the API, and with it this page, down.

## AI assistant

`ANTHROPIC_API_KEY` (live). **Test** lists one model with the key, which costs nothing and fails
exactly when a request would (`401` wrong or revoked key, `403` disabled organization). See
[AI assistant](/configuration/environment#ai-assistant).

The same key answers [Ask AI on the docs site](/integrations/ai-assistant#ask-ai-on-the-docs-site),
within two limits set here (both live, whole numbers from 1 to 1,000,000):

| Key | When not set | What it limits |
|---|---|---|
| `DOCS_ASK_HOURLY_PER_IP` | `10` | Questions from one client address per hour |
| `DOCS_ASK_DAILY_LIMIT` | `500` | Questions from everyone per UTC day |

## Email

`SMTP_HOST`, `SMTP_PORT`, `SMTP_USERNAME`, `SMTP_PASSWORD`, `SMTP_FROM`, `SMTP_TLS_MODE` (all
live: the worker builds its relay from the current values on each send). **Send test email** sends
one message to the address you type; this replaces `staffctl mail-test`.

- **Require email verification** (`REQUIRE_EMAIL_VERIFICATION`) can be switched on only after a
  test email succeeded, and changing any `SMTP_*` value resets that check. It applies to the next
  password sign-in.
- **Password reset enabled** (`PASSWORD_RESET_ENABLED`) shows *Forgot password?* on the sign-in and
  account pages. The dashboard reads it from `GET /api/v1/platform/notice`; it is no longer a
  dashboard build argument.

## Stripe

`BILLING_PROVIDER` (`manual` or `stripe`), `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`, every
`STRIPE_PRICE_*` the API reads (Team, Business and Enterprise, the Certificates and Exposure
add-ons, monthly and yearly) and `STRIPE_METER_EVENT_NAME`. The page shows **test** or **live**
from the key's prefix. **Verify prices** asks Stripe for each configured price and lists any that
does not exist, is archived, or is in the other mode than the key. Stripe settings apply at the
next restart of the API and the worker. See [Billing](/configuration/billing).

## Trusted proxies

`TRUSTED_PROXIES`, comma-separated addresses or CIDRs, each validated. The page shows the address
your own request arrived from and warns when it is not covered, which is what a missing or wrong
entry looks like: every client appears to be the proxy. Applies at the next restart.

## Platform admins

The page lists the platform admins. Add or remove one on the console home's **Staff** tab (it
already does this, audited). Nobody can demote or suspend their own account, so the last active
platform admin can never be removed. Keep at least two.

## Audit checkpoints

**Generate key** creates `AUDIT_CHECKPOINT_KEY` (256 bits) on the server, stores it encrypted and
shows it **once**, with a checkbox confirming you stored it off the host. It is refused while a key
is stored, because replacing it would leave the previous checkpoints unverifiable; clear it first
if you mean to. Set `AUDIT_CHECKPOINT_DIR` (for example `/audit-checkpoints`, the Compose volume).
The worker reads both on each run, so no restart, and the page shows the last checkpoint's time and
outcome. See [`auditctl`](/cli-reference/auditctl) for verifying them.

## Encryption

`KMS_PROVIDER` (`local`, `aws`, `gcp`, `vault`) and `KMS_KEY_ID`, applied at the next restart.
Credentials for the KMS (an AWS role, a GCP account, `VAULT_ADDR` and `VAULT_TOKEN`) stay in the
environment. **Test** wraps and unwraps a probe with the stored provider and key.

**Plan re-encryption** runs `reencrypt plan` as a background job and shows its report. **Apply
re-encryption** needs a fresh second factor and typing `RE-ENCRYPT`; it runs `reencrypt apply`,
shows progress per column, and then runs a plan again so the report ends with what is left. One
job runs at a time; a job whose process restarted is closed as interrupted. It is the same code as
the [`reencrypt` command](/deployment/envelope-encryption) and needs the same database role: the
schema owner, or a role covered by its `tenant_isolation_maintenance` policy. A production api
connects as the tenant-confined `trustowl_app_login`, so there both buttons refuse at once and
name the command to run on the host instead:

```bash
docker compose -f infra/docker/docker-compose.prod.yml --env-file <stack env> -p <project> \
  run --rm reencrypt plan    # then: run --rm reencrypt apply
```

## Off-host backups

`BACKUP_S3_ENDPOINT`, `BACKUP_S3_BUCKET`, `BACKUP_S3_REGION`, `BACKUP_S3_ACCESS_KEY_ID`,
`BACKUP_S3_SECRET_ACCESS_KEY` and `BACKUP_PUBLIC_KEY` (the age recipient backups are encrypted
to). **Test** writes, reads back and deletes a probe object with those credentials; a key without
delete permission fails, because retention needs it.

The backup timer runs on the host, so it fetches these each run:
`infra/scripts/backup.sh` calls `staffctl backup-env <stack>` inside the stack's API container,
which prints `BACKUP_PUBLIC_KEY`, `BACKUP_REMOTE` and an rclone remote defined in the environment
(no `rclone.conf`). The script takes only those names, line by line, and never evaluates the
output. A value in the stack's env file still wins.

**Once on the host**, after deploying this version: install the updated units so the timer knows
its stack, and make sure `rclone` and `age` are installed:

```bash
sudo cp /opt/trustivan/src/infra/systemd/trustivan-backup@.* /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start trustivan-backup@app.service    # and demo, play
journalctl -u trustivan-backup@app.service -n 40 --no-pager
```

See [Backup and recovery](/deployment/backup-and-recovery).

## Production alerts

`ALERT_SLACK_WEBHOOK_URL`: the Slack incoming webhook production alerts go to. Only
`https://hooks.slack.com/services/…` is accepted. It is a secret: the URL is the credential,
so it is sealed at rest, never shown again and only fingerprinted in the audit trail, and
changing it needs a recent second factor. **Send test alert** posts a clearly labelled message
to it through the outbound network guard; a revoked webhook fails with the reason.

Two senders use it:

- **The app itself**, within seconds: every server error (HTTP 5xx or a recovered panic), every
  scan that fails for good and every failed background task. **Errors name the affected
  organization** (name and ID, or "no organization"), with the stack, the route or task, an error
  code, the request ID and a short message with anything that looks like a secret, a path or an
  email address removed. Never a request body, header or token. Repeats of the same error for the
  same organization within ten minutes arrive as one "+N more" message. Name the stack with
  `STACK_NAME` (default: the API's host name).
- **The host's Alertmanager**, within five minutes: the monitoring alerts that must arrive when
  the app is down (a stack or container gone, error rates, a stale vulnerability database).
  `trustivan-alert-webhook-sync.timer` asks the app stack's API through
  `staffctl alert-webhook` every five minutes, writes the URL into Alertmanager's secret file
  and reloads it. If the API does not answer it keeps the last URL, so alerts keep flowing
  through an app outage. The URL set here wins over `ALERT_WEBHOOK_URL` in the monitoring env
  file, which stays the fallback.

**Once on the host**, after deploying this version: `infra/scripts/routines.sh enable app`
installs and enables the timer (with the other per-host timers), or by hand:

```bash
sudo cp /opt/trustivan/src/infra/systemd/trustivan-alert-webhook-sync.* /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now trustivan-alert-webhook-sync.timer
journalctl -u trustivan-alert-webhook-sync.service -n 20 --no-pager
```

## Demo account

On a stack with `DEMO_ACCOUNT_EMAIL`, the page shows the read-only visitor (its role, and that it
has no password) and the owner of the organization it views. **Rotate owner password** sets a new
password, shows it once and signs the owner out everywhere.

## NHI alerts

There is no switch: NHI Security publishes its events to the AppSec API, and they reach people
through the notification targets each organization chooses. The go-ahead is a decision; then each
organization adds a target under **Settings → Notifications** and selects the NHI events.

## Outside this app

Some items need an outside account or the host. The page lists them as a checklist, with a probe
where one exists:

- **Release `v0.2.0`**: push the tag and enable Actions billing. **Check GitHub** looks for the
  published release.
- **CI billing**: enable GitHub Actions billing for the organization.
- **Hetzner**: project, token, bucket and `terraform plan` / `apply` from your machine
  (`docs/deployment/hetzner.md` in the repository).
- **Search Console**: trustivan.com is served by Vercel and the docs by their own host, so neither
  can be verified from here.
- **Shared edge Caddy**: the on-demand TLS block whose `ask` points at `/internal/tls/ask`
  ([branding](/configuration/branding)). **Probe** asks the API's own endpoint through
  `API_BASE_URL`.
- **Semgrep licence**: counsel's answer on the LGPL image.
- **AWS test account**: connect it from an organization's **Cloud** page, like any customer.
