ObjectStackObjectStack

Self-hosting — run your own deployment

Run a compiled ObjectStack app on your own servers with the official Docker image, Compose and Postgres, or Kubernetes — health checks and secrets too.

This guide takes the artifact produced by os build / os compile and runs it on infrastructure you operate. Docker is the standard path — the platform publishes an official runtime image on every release, and Compose and Kubernetes are shapes of that same path rather than alternatives to it. Bare Node.js under systemd is the minority path, kept for hosts where a container runtime is not available or not permitted. It assumes you have read Deployment Overview.

The deployment model is deliberately simple:

objectstack.config.ts ──(os build, CI)──▶ dist/objectstack.json ──(os start, server)──▶ running app
  • The artifact (dist/objectstack.json) is a portable, self-describing JSON file — your entire app. Build it once in CI; the host needs no TypeScript and no build step.
  • os start boots a production server directly from that artifact (reference).
  • Deployment config stays outside the artifact. Database URL, secrets, and environment identity are injected via OS_* environment variables or flags.

The minimum viable production environment

Four values every self-hosted deployment must pin — everything else has a workable default:

VariableWhy it must be set
OS_DATABASE_URLWithout it, data lands in a SQLite file under the ObjectStack home directory (~/.objectstack, or <cwd>/.objectstack next to a project config) — fine for one box, wrong for containers. Use postgres://…, mysql://…, mongodb://…, libsql://…, or a mounted file:… path (postgres://…'s driver is an optional package too — npm install pg, or the boot fails loudly rather than degrading to SQLite; libsql:// / Turso is inferred, but its driver is an optional package — npm install @objectstack/driver-turso, or the boot fails loudly rather than degrading to SQLite; see Drivers). mysql://… is a supported deployment target that carries three dialect caveats — two of them integrity guarantees MySQL cannot enforce at the database — see Drivers → MySQL dialect caveats before choosing it; its driver is likewise an optional package — npm install mysql2, or the boot fails loudly rather than degrading to SQLite. mongodb://… is single-tenant only: the MongoDB driver has no row-level tenant isolation and refuses to boot unless the tenancy posture is single — see Drivers → Multi-tenancy.
OS_AUTH_SECRETSession secret for the auth plugin (AUTH_SECRET is the legacy alias). Without it, os start generates one and keeps it in auth-secret under the ObjectStack home directory, reused on restart: lose that file (a replaced container) and everyone is signed out. Several replicas declared over the redis cluster driver need one value set on every replica: there os start refuses to generate one.
OS_SECRET_KEY32-byte master key encrypting every stored secret (openssl rand -hex 32). On a container's ephemeral filesystem the auto-minted key is lost on restart, making previously-encrypted secrets undecryptable.
OS_PORTos start fails loudly if the port is busy (it never auto-shifts like os dev). Pin it and keep your reverse-proxy upstream in sync.

Generate strong values once and store them in your secret manager:

OS_AUTH_SECRET=$(openssl rand -hex 32)
OS_SECRET_KEY=$(openssl rand -hex 32)

When the three are not set

The official image refuses to start unless OS_DATABASE_URL, OS_AUTH_SECRET and OS_SECRET_KEY are all set explicitly. It exits naming the ones that are missing, before it writes a database file or a secret: a container's disk is the part that gets replaced, so booting on it would lose the data, sign everyone out and leave every saved credential unreadable. The image turns the check on with OS_DEPLOYMENT_DURABILITY_CHECK_ENABLED=true in its ENV.

  • An explicit OS_DATABASE_URL=file:/path/on/a/volume/app.db passes: SQLite on a mounted volume stays a choice (below).
  • Already running on values the image generated? Carry them over before you set new ones, or the saved credentials stop decrypting and every session ends. They are files in the old container's home, /home/node/.objectstack (docker exec <container> cat <file>, or read them from its volume): OS_AUTH_SECRET is the contents of auth-secret, OS_SECRET_KEY the contents of dev-crypto-key, and the data is data/objectstack.db (OS_DATABASE_URL=file:… on a kept volume, or migrate it to your database). The refusal prints these paths and says which of them the container holds.

Every other os start keeps booting. In production mode, when it keeps any of the three on its own disk, it prints a warning block naming each file and the variable that moves it off that disk. Administrators also see it in the Console: a standing notice on the home page and at the top of Setup's System Overview, listing the same files with a button that copies the variables to set, plus a lower-severity line when uploads are stored on the local disk. Mail is optional and is not one of them: a deployment without an email service gets no line for it. Members never see it, and it is not on the public auth config (it is read from GET /api/settings/deployment/notice, which needs manage_platform_settings). An administrator can hide it: the hide is written to the audit log as a config_change (and refused where no audit log is mounted), it lasts for that administrator in that browser until the findings change, and System Overview keeps one small line saying the notice is hidden.

The full catalog is in Environment Variables.

Docker (official image) — the standard path

The artifact model maps cleanly onto containers, and this is how the platform itself ships: ObjectStack builds and publishes an official runtime image on every framework release — ghcr.io/objectstack-ai/objectstack, Node 22 + @objectstack/cli + os start, running as a non-root user with a built-in health check and OS_ARTIFACT_PATH / OS_PORT=8080 preset. Image tags mirror @objectstack/cli versions: a stable publish pushes that exact version as X.Y.Z and moves latest and the matching X.Y / X tags onto it, while a prerelease gets only its exact tag. The image is published multi-arch (amd64/arm64). Only the exact tag is immutable — a rolling tag stops moving as soon as no later publish matches it, so X.Y freezes when the next minor ships and X when the next major does. Pin the exact version in production, matching the CLI version in your package.json.

The fastest path needs no image build at all — hand the official image your compiled artifact:

os build   # → dist/objectstack.json (or in CI)

docker run -p 8080:8080 \
  -v "$PWD/dist/objectstack.json:/srv/app/objectstack.json:ro" \
  -e OS_DATABASE_URL="postgres://user:pass@db-host:5432/myapp" \
  -e OS_AUTH_SECRET \
  -e OS_SECRET_KEY \
  ghcr.io/objectstack-ai/objectstack:18.6.0

(OS_ARTIFACT_PATH also accepts an https:// URL, so the artifact can come straight from release storage instead of a mount.)

Artifact-pinned boot (OS_ARTIFACT_URL)

The image above carries no app. OS_ARTIFACT_URL names one by reference, so a fixed runtime image plus one environment variable is a running app — and upgrading the app is an env change plus a restart, never an image rebuild. The runtime image and the app artifact become two independent release axes.

docker run -p 8080:8080 \
  -e OS_ARTIFACT_URL="https://releases.example.com/hotcrm-2.2.2.json#sha256=<64 hex chars>" \
  -e OS_DATABASE_URL="postgres://user:pass@db-host:5432/myapp" \
  -e OS_AUTH_SECRET -e OS_SECRET_KEY \
  ghcr.io/objectstack-ai/objectstack:18.6.0

Both schemes work: https://… is fetched at boot, file:///… is read directly (the volume-mount workflow above, spelled as a URL). The variable overrides the image's preset OS_ARTIFACT_PATH and any objectstack.config.ts in the working directory.

The integrity pin lives in the URL fragment. #sha256=<64 hex chars> is SRI-style and there is deliberately no companion OS_ARTIFACT_SHA256: a fragment is client-side by standard and is never sent to the server, so the pin travels with the reference as a single value to copy and a single value to rotate. Two variables would make "URL updated, hash not" a state you can reach.

SituationWhat the runtime does
No #sha256= fragmentBoots without verification. A fetch or read failure fails the boot so your orchestrator retries — there is no cache fallback, because there is nothing to authenticate a cached copy with.
#sha256= present, content matchesBoots, and keeps the verified copy under <home>/artifacts.
#sha256= present, content differsRefuses to boot, naming the expected and the actual digest.
#sha256= present, artifact host unreachableFalls back to the cached copy only if it still hashes to the pin, with a loud warning that the instance is running on cached content.
Artifact's engines.protocol excludes this runtimeRefuses to boot — the safety belt of the two-axis split. Repoint the reference, or run a matching image version.
The artifact needs a destructive schema changeSafe migrations run at boot; a destructive one refuses to boot and names each change. Run os migrate apply --allow-destructive deliberately, then restart. Never skipped in silence.
The app's stack lists code plugins (plugins: [new XPlugin()])Boots without them: an artifact carries the app's metadata and hook handlers, not its code plugins, so nothing those plugins register exists. The boot warns once, naming each listed plugin the kernel does not run. To run them, boot a host config that loads the artifact and lists the plugins in its own plugins, or package them as a plugin (os plugin build, then os plugin install).

Recommended production discipline (convention, not enforced by the runtime): publish immutable, version-named objects; give only CI write access to the artifact host; and pin the digest in the fragment. Together these make "which bytes is this instance running?" a question with one answer.

Pre-signed URLs are safe to use. The reference may carry auth material — a signature query parameter, or user:token@host — and it is never echoed into logs or HTTP responses. Userinfo is sent as an Authorization: Basic header rather than in the request line (so it does not land in your artifact host's access log), and remote bytes are materialised to a local file before the boot continues, so the URL does not reach any downstream surface at all.

For a self-contained deployable image, extend it. The Dockerfile below (plus the compose stack in the next section and a .dockerignore) ships ready-made in the project scaffold — create-objectstack (npm create objectstack) writes all three into your new project's root.

Dockerfile
# ── Build stage: compile TypeScript metadata to the artifact ─────────
FROM node:22-slim AS build
WORKDIR /app
# Installs from the lockfile this project carries, so commit it: scaffolding
# writes pnpm-lock.yaml when it installs with pnpm, package-lock.json with npm.
# pnpm runs through Corepack at the major .github/workflows/ci.yml pins; keep
# the two in step (unpinned, Corepack takes the registry's newest major).
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml* package-lock.json* ./
RUN if [ -f pnpm-lock.yaml ]; then corepack pnpm@10 install --frozen-lockfile; \
    elif [ -f package-lock.json ]; then npm ci; \
    else echo "No lockfile: run pnpm install or npm install, then commit it." >&2; exit 1; fi
COPY . .
RUN npx os build              # → dist/objectstack.json

# ── Runtime: the official ObjectStack runtime image ──────────────────
FROM ghcr.io/objectstack-ai/objectstack:18.6.0
COPY --from=build --chown=node:node /app/dist/objectstack.json /srv/app/objectstack.json
docker build -t my-app .
docker run -p 8080:8080 \
  -e OS_DATABASE_URL="postgres://user:pass@db-host:5432/myapp" \
  -e OS_AUTH_SECRET \
  -e OS_SECRET_KEY \
  my-app

Prefer to build the runtime yourself (air-gapped registry, custom base image)? The official image is nothing more than:

Dockerfile (self-built runtime, equivalent)
FROM node:22-slim
# Installs under a pinned npm 11, deleted in the same layer, as the official
# image does. node:22-slim's own npm 10 installs the CLI too.
RUN npm install --prefix /tmp/os-installer-npm --no-save --no-audit --no-fund "npm@11.21.0" \
 && export PATH="/tmp/os-installer-npm/node_modules/.bin:$PATH" \
 && test "$(npm --version)" = "11.21.0" \
 && npm install -g @objectstack/cli@18.6.0 "pg@^8.0.0" "mysql2@^3.0.0" \
 && npm cache clean --force \
 && rm -rf /tmp/os-installer-npm

WORKDIR /srv/app
RUN chown node:node /srv/app
USER node
COPY --chown=node:node dist/objectstack.json ./objectstack.json

ENV NODE_ENV=production \
    OS_ARTIFACT_PATH=/srv/app/objectstack.json \
    OS_PORT=8080
EXPOSE 8080

HEALTHCHECK --interval=30s --timeout=3s --start-period=15s \
  CMD node -e "fetch('http://localhost:'+(process.env.OS_PORT||8080)+'/api/v1/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"

CMD ["os", "start"]

Never bake OS_AUTH_SECRET / OS_SECRET_KEY into the image. Pass them at runtime from your orchestrator's secret store. And never rely on the auto-minted dev crypto key inside a container — it lives on the ephemeral filesystem and dies with it.

Docker Compose with Postgres

The same path with a database attached — build: . is the Dockerfile from the section above, so the app container is still the official runtime image with your artifact on top. A complete single-host production stack:

docker-compose.yml
services:
  app:
    build: .
    ports:
      - "8080:8080"
    environment:
      OS_DATABASE_URL: postgres://objectstack:${POSTGRES_PASSWORD}@db:5432/myapp
      OS_AUTH_SECRET: ${OS_AUTH_SECRET}
      OS_SECRET_KEY: ${OS_SECRET_KEY}
    depends_on:
      db:
        condition: service_healthy
    restart: unless-stopped

  db:
    image: postgres:17
    environment:
      POSTGRES_USER: objectstack
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: myapp
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U objectstack -d myapp"]
      interval: 5s
      timeout: 3s
      retries: 10
    restart: unless-stopped

volumes:
  pgdata:
# .env next to docker-compose.yml (never committed)
POSTGRES_PASSWORD=…
OS_AUTH_SECRET=…
OS_SECRET_KEY=…

docker compose up -d
curl -fsS http://localhost:8080/api/v1/health

Prefer SQLite on a single small host? Skip the db service, mount a volume, and point OS_DATABASE_URL at it: file:/srv/data/app.db (with - appdata:/srv/data on the app service). Set it explicitly even then: the official image refuses to start on its default database file, which lives in the container layer (When the three are not set). See Drivers for when to reach for which database.

Health checks & orchestration

Every runtime exposes two probe endpoints — wire them into Docker HEALTHCHECK, Kubernetes probes, or your load balancer:

EndpointMeaningUse as
GET /api/v1/healthProcess is up and serving HTTPLiveness probe
GET /api/v1/readyKernel booted and the data drivers answerReadiness probe

Wire each to the probe it is named for — they answer deliberately different questions:

  • /health checks nothing but the process. It never touches the database, on purpose: a failing liveness probe makes the orchestrator restart the pod, which cannot fix an unreachable database but would put every replica into a restart storm for the length of the outage.
  • /ready pings the data drivers (bounded, and cached ~1s so frequent polling costs no extra round-trips). A replica whose driver is down fails 100% of its requests, so it returns 503 with the failing driver names and leaves the load-balancer rotation until the database comes back. If the check is inconclusive — no data engine at all, or the probe itself errors — the replica stays ready rather than black-holing a working deployment.

A configuration fault never restarts the pod. The split above is enforced one step earlier than the two handlers: /health is served before the request pipeline resolves an identity, so it evaluates nothing that depends on configuration or credentials — a misconfigured or unbuildable security service leaves it answering 200 for as long as the process can serve HTTP. /ready keeps the whole pipeline and answers 503 for exactly that class of fault, with the body it has always returned. So wire path: /api/v1/health to livenessProbe and path: /api/v1/ready to readinessProbe — never the other way round, and never the same path to both. Crossed over, a configuration fault makes the orchestrator kill and recreate the pod; the new one reads the same configuration and fails the same way, and the operator sees CrashLoopBackOff instead of the fault. Withholding traffic is the response that helps; restarting is not.

Kubernetes

The same image works unchanged. A minimal reference Deployment — secrets from a Secret, probes on the two endpoints above:

deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 1            # >1 requires OS_CLUSTER_DRIVER — see below
  selector:
    matchLabels: { app: my-app }
  template:
    metadata:
      labels: { app: my-app }
    spec:
      containers:
        - name: app
          image: registry.example.com/my-app:latest
          ports:
            - containerPort: 8080
          envFrom:
            - secretRef:
                name: my-app-secrets   # OS_DATABASE_URL, OS_AUTH_SECRET, OS_SECRET_KEY
          livenessProbe:
            httpGet: { path: /api/v1/health, port: 8080 }
            periodSeconds: 30
          readinessProbe:
            httpGet: { path: /api/v1/ready, port: 8080 }
            initialDelaySeconds: 5
            periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
  name: my-app
spec:
  selector: { app: my-app }
  ports:
    - port: 80
      targetPort: 8080

/api/v1/ready returns 503 while the kernel is booting, during graceful shutdown, and whenever a data driver stops answering — so rolling restarts drain cleanly and a replica that lost its database stops receiving traffic instead of serving 500s. Before setting replicas > 1, read the multi-node note below.

A replica does recover on its own once the database returns — client libraries re-establish connections without help (the MongoDB driver's topology monitor; knex/pg opening a fresh connection per acquire, verified in #3759). So a transient outage — a failover, a maintenance window — needs no restart: the readiness probe drains the replica while the database is away and re-admits it afterwards. Restart only when the process is genuinely stuck, and note that a replica which booted without its database never re-runs its schema sync.

Bare Node.js (systemd) — without containers

The minority path, and a deliberate one: reach for it when the host has no container runtime available or permitted, when an existing systemd / configuration-management estate already owns process supervision, or when you are debugging directly on the box. It needs Node 22+ and the CLI on a Linux host, and nothing else.

The npm that Node 22 ships installs the CLI. If the install stops with Cannot read properties of null (reading 'edgesOut'), see Troubleshooting.

# On the host — no repo clone, just the CLI and your artifact
npm install -g @objectstack/cli
npm install -g pg   # Postgres driver is an optional peer of @objectstack/driver-sql —
                    # install it next to the CLI, or the boot fails loudly (use mysql2 for OS_DATABASE_URL=mysql://…)
scp dist/objectstack.json server:/opt/my-app/objectstack.json
/etc/systemd/system/my-app.service
[Unit]
Description=My ObjectStack App
After=network.target postgresql.service

[Service]
Type=simple
User=objectstack
WorkingDirectory=/opt/my-app
Environment=NODE_ENV=production
Environment=OS_ARTIFACT_PATH=/opt/my-app/objectstack.json
Environment=OS_PORT=8080
EnvironmentFile=/opt/my-app/secrets.env   # OS_DATABASE_URL, OS_AUTH_SECRET, OS_SECRET_KEY
ExecStart=/usr/bin/os start
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl enable --now my-app
curl -fsS http://localhost:8080/api/v1/health

Upgrades are atomic: replace the artifact file and restart the service. Roll back by restoring the previous artifact.

Reverse proxy & TLS

Terminate TLS in front of the app (Caddy, nginx, Traefik, or your cloud LB) and keep three things in sync with the public origin:

OS_AUTH_URL=https://app.example.com          # auth callbacks / cookie origin
OS_TRUSTED_ORIGINS=https://app.example.com   # auth callback / CSRF allow-list
OS_PORT=8080                                 # must match the proxy upstream

CORS needs no entry here: the Console and the API share the public origin, and with no OS_CORS_ORIGIN the server admits no cross-origin caller. Only a front-end served from another origin needs one, listed explicitly (OS_CORS_ORIGIN=https://portal.example.com, comma-separated for several) — never *, which the server refuses at boot while credentials are on. See Environment variables → CORS.

Caddyfile
app.example.com {
    reverse_proxy localhost:8080
}

A drifted port or origin is the classic self-hosting failure: the app runs, but logins bounce and browsers block API calls. Enable HSTS and tune security headers only after TLS is confirmed — see Production Readiness.

Serve HTTP/2 to browsers

Serve the public origin over HTTP/2 (HTTP/3 too, if your front offers it). The runtime itself speaks HTTP/1.1 on OS_PORT, and that is fine for the hop from the proxy; it is the hop to the browser that matters. A Console page requests well over a hundred script files before it can paint its first screen (about 120 on every page, more on a list or record page). Over HTTP/1.1 a browser opens at most six connections to one origin and queues the rest, so those files arrive in 20–25 rounds, one network round trip each; over HTTP/2 they are all requested at once on one connection, and only bandwidth paces them. Measured with Lighthouse's desktop profile (40 ms round trips), the same build painted its first screen about 1.4–2 s later over HTTP/1.1; the gap grows with the round-trip time.

Caddy and most cloud load balancers serve HTTP/2 over TLS by default. nginx needs it switched on (http2 on; in the server block from nginx 1.25.1, listen 443 ssl http2; before that). To check a deployment, open the Console, then in the browser's DevTools Network panel show the Protocol column (it is hidden by default: right-click the column headers) and read it for the page's scripts: it should say h2 (or h3), not http/1.1.

Scaling beyond one node

The default in-process coordination (locks, queues, schedules) is single-node. Before running replicas, set OS_CLUSTER_DRIVER — the runtime then treats the deployment as multi-node and refuses to boot without an explicit OS_SECRET_KEY rather than minting per-node keys that can't decrypt each other's secrets. All replicas must share the same OS_SECRET_KEY, OS_AUTH_SECRET, and database. See Cluster. A database local to each replica cannot be shared — SQLite (the default when OS_DATABASE_URL is unset), sqlite-wasm, or libSQL over a file: URL — so once several replicas are declared over the redis cluster driver, os serve refuses to start on one, exits 1 and names a Postgres OS_DATABASE_URL instead. A libSQL server URL (libsql://…) is one shared database and is not refused.

Uploads need S3 or one shared volume once replicas are declared. The default local storage adapter writes uploads to the replica's own disk, so a file uploaded through one replica would be missing on the others. When the deployment declares several replicas (OS_EXPECT_MULTI_NODE=true or OS_CLUSTER_REPLICAS greater than 1) over the redis cluster driver, a boot on the local adapter is refused, and a storage settings change onto it is not applied. Either use S3 — OS_STORAGE_ADAPTER=s3 with OS_STORAGE_S3_BUCKET and OS_STORAGE_S3_REGION (plus the endpoint and keys your store needs), or Setup → Settings → File Storage — or, when every replica mounts the same volume at OS_STORAGE_LOCAL_ROOT (several Compose replicas on one host sharing a named volume), set OS_STORAGE_LOCAL_ROOT_SHARED=true. That variable is a declaration, not a check. A ReadWriteOnce volume, as on Kubernetes, cannot be shared across replicas: use S3 there.

An S3 bucket needs a CORS rule for browser uploads and file previews. With S3 or an S3-compatible store (R2, MinIO), the browser talks to the bucket directly: an upload PUTs the file to a presigned URL, and the in-page preview of a text or CSV file reads it with a GET on its signed download link. Both are cross-origin requests from the Console's origin, so the bucket's CORS configuration must allow them:

CORS fieldValue
AllowedOriginsthe Console's public origin, exactly (https://app.example.com) — never *
AllowedMethodsGET, HEAD, PUT
AllowedHeaderscontent-type (or *)
ExposeHeadersContent-Length, Content-Type, Content-Disposition, ETag
MaxAgeSeconds3000

A PDF preview needs no CORS: the Console shows it in a frame, and its content-security-policy already allows frames from the bucket's origin, the same origin it allows uploads to. Without the rule, uploads to the bucket fail, and a text or CSV preview cannot read the file: the preview then offers to open the file in a new tab, which needs neither CORS nor a frame source.

/ready reports the cluster driver's health once replicas are declared. When the deployment declares itself multi-node — OS_EXPECT_MULTI_NODE=true or OS_CLUSTER_REPLICAS greater than 1; OS_CLUSTER_DRIVER alone is not a declaration — and runs the redis cluster driver, /api/v1/ready adds a cluster entry to its 200 body. While Redis answers it reads { driver: "redis", reachable: true } and status stays "ready". While it does not, the probe still answers 200, with status: "degraded" and cluster: { driver: "redis", reachable: false, reason }, where reason is one of timeout, ping-failed, unexpected-reply or no-probe; the store's address never appears in the body. It is not a 503 on purpose: every replica loses a shared Redis at the same moment, so draining on it would take every replica out of the load balancer while the database can still serve. Wire your alerting to status: "degraded" (or cluster.reachable: false) rather than to the status code. The check is one PING bounded at 500 ms and cached ~1s, like the data-driver check, and recovery needs no restart. A single-node deployment sees no change: its body and status code are exactly what they were, and its Redis, if any, is never probed.

/ready reports whether the boot seed has landed. When the app declares seed data, the 200 body carries seed: "pending" while the boot seed is still writing (past its budget it continues in the background after the kernel runs), then "settled", or "failed" when a source dropped records or references. It never changes the status code, so a replica stays in rotation while it seeds. A setup script or test that needs the seed rows polls /api/v1/ready until seed is not "pending"; a deployment without seed data sees no seed key.

Scheduled jobs' leader election has a window, not a deadline. cron / interval / once schedules dedupe across replicas by holding a lock for the duration of each fire — the mutual-exclusion window is the handler's runtime, not the scheduling deadline. Exactly-once per deadline holds only when replica clocks agree to within that window, which an NTP-synced deployment gives you. A replica whose clock lags past the window finds the lock already released and reruns the job; once schedules are the sharpest case, since a one-shot has no later tick to self-correct on.

First boot: create the admin

How the first administrator is created depends on the deployment's tenancy posture, and the two paths are not interchangeable.

single (the default) — the first account wins. On a fresh production database there are no users yet — fresh meaning zero human sys_user rows, not merely zero logins (why that distinction decides this). Open the deployment's root URL and sign up — the very first account to register becomes the bootstrap admin (this works even with OS_DISABLE_SIGNUP=true, which only blocks sign-ups after that first account exists). Do this immediately after the first deploy, before sharing the URL; then create your real user accounts and lock sign-up down via OS_AUTH_SIGNUP_ENABLED / SSO as policy dictates.

Walled postures (group / isolated) — you name the administrators in configuration. First-registrant promotion is removed there: with self-registration reachable, whoever posts to the sign-up endpoint first would otherwise receive cross-tenant access. No grant row is written on those postures, ever. Declare the administrators before first boot instead:

# one address, or a comma-separated list
OS_PLATFORM_OWNER_EMAIL=ops@example.com,backup-admin@example.com

Then have each of those people register with exactly that address and verify their email. Standing is recomputed on every request from the configured list and the account's own stored record, so it appears the moment verification completes — there is nothing to grant and nothing to click. That registration is admitted by the first-account carve-out, so it works only while the deployment's user directory is still empty; on a database that already carries human rows it is refused, and the recovery is out of band.

The rules below are enforced by the runtime, not advisory:

  • Declare more than one address. A single mailbox is a single point of human failure; losing it leaves the deployment with no administrator and no in-product recovery.
  • Verified only. An account that holds a declared address but whose email is not verified is not an administrator. A record that predates the verification column, or that arrived through an import without it, reads unverified rather than verified.
  • Case and spacing do not matter. Entries are trimmed and lower-cased on both sides of the comparison, duplicates collapse, and a trailing separator or a blank entry is ignored.
  • One bad entry refuses the whole variable. If any entry is not an email address, the deployment gets zero configured administrators — not the remaining good ones. Dropping just the bad entry would leave a narrower administrator set than you declared with nothing anywhere to notice, which is the more dangerous failure. The runtime names the offending entry in the log; fix or remove it, then reload.
  • Empty is fail-closed, and a walled boot refuses it. Unset or blank under a walled posture aborts startup, naming the variable, rather than silently reverting to promoting the first registrant. A value that is set but refused for a bad entry gets past that startup check — it is not blank — so the process starts and then has no administrators. Confirm from the boot log, not from the fact that the process came up.
  • Revocation is a configuration change plus a reload. No endpoint, UI action or API call adds or removes a platform administrator; that surface deliberately does not exist. Edit the variable and roll the process — the next resolution reads the new value.
  • You cannot quietly remove the last one through the user record, either. Changing the last remaining administrator's email address, or clearing their verified flag, is refused, and the refusal points at the configuration as the remedy — the same guard that refuses deleting or banning the last administrator.

On a walled boot the runtime logs the resolved list: per declared address, whether an account exists, whether it is verified, and which account holds standing. That line is the fastest check that the configuration and the real accounts agree. The same answer is available read-only to Setup, discovery and health surfaces; see who holds admin_full_access.

Note the production server seeds no dev credentials — the admin@objectos.ai / admin123 account you may know from os dev exists only on empty development databases. That seed is hard-gated to NODE_ENV=development: it is a development convenience, never a production recovery path.

Nor does a server outside development mode accept a development seed credential. A sign-in with the development seed password is refused on every account, and an account os dev seeded (its admin and the stack's demoStaff) opens no session while it still has the password it was seeded with. If you serve a database os dev wrote, set each seeded account's password on the server with os user set-password first; the refusal names that command.

Nothing the development seed issued keeps acting once the deployment leaves development mode. At every boot outside development mode, before the server serves a request, it retires what each seeded account still on its seed password was issued: its sessions, including any it opened acting as another account, its API keys, the apps authorized to it and its device sign-ins, its outstanding password-reset links, any sign-in account linked to it, the OAuth applications it registered (disabled) and the SCIM credentials it minted (revoked). A retired session or key answers exactly as a revoked one does, and the log names each account and what was retired. When the host supplies a secondaryStorage that holds the sessions, the server ends them there too, which os user set-password cannot reach. An account whose password was set since the seed (by os user set-password, by an administrator, or by its own reset) holds a credential the seed did not issue and is untouched, as is every account the seed did not create. A boot in development mode retires nothing. There is no switch.

If the retirement cannot complete (the database refuses a read or a write), the server does not start, and the error names the accounts; fix the database access, or run os user set-password on each of them, and start it again. os user set-password itself ends the account's own sessions, keys and grants when it sets the password, and from then on the boot leaves that account alone.

A seeded directory opens no bootstrap window

Both paths above assume the deployment's first login is still ahead of it. An app that declares people in defineStack({ data }) — or any provisioning job that writes sys_user rows — creates a directory, not logins: those rows carry no sys_account, and the platform counts them as a populated deployment. Measured on a real kernel with three human sys_user rows, zero sys_account rows, outside development, under the default invite_only audience posture:

Operator actionMeasured outcome
A seeded person registers with exactly their declared address403 SELF_REGISTRATION_CLOSED
Anyone else registers403 SELF_REGISTRATION_CLOSED
A seeded person signs in401 INVALID_EMAIL_OR_PASSWORD

The first-account carve-out counts humans, not logins — humans already exist, so it does not fire, and the door stays shut by decision rather than by oversight. No administrator exists to send an invitation. The deployment cannot be recovered from inside, and it keeps looking healthy: its only symptom is a 401 on credentials nobody holds.

The runtime says so at boot. When human sys_user rows exist and no sys_account row does, kernel:ready reports at error level under the grep token no_sign_in_account_at_boot, naming both the consequence and the remedy. If you are handed a deployment nobody can sign in to, that line is the first thing to look for — and note that it asks only whether an account row exists, so a row you wrote yourself silences it whether or not anyone can actually authenticate with it.

The same shape is logged at debug instead, under the same token and naming the reason, when the deployment has a sign-in path that needs no sys_account row of its own: SSO-only mode (OS_AUTH_SSO_ONLY or ssoOnlyMode), a configured social or OIDC provider, enterprise SSO with at least one registered identity provider, or a host that constructs AuthPlugin with hostSignInHandoff: true because it signs people in through a handoff route of its own. A deployment with none of these still reports at error. hostSignInHandoff is a statement by the code that serves such a route, not a way to quiet the report: set on a deployment without one, it hides exactly the dead end this section describes.

The recovery is out of band, and it is one row. Write a pending invitation directly against the store the deployment reads, then have that person register through the ordinary sign-up endpoint, sending the row's id as invitationId beside the email — under invite_only a sign-up is admitted only by the invitation it presents. That one creation is admitted under every posture — by the invitation under invite_only and off an email_domain list, by the posture's own rule, read first, under open and on the list — so the invite_only default stays where it is. One sys_invitation row:

ColumnValue
ida long random value of your own: it is what the sign-up presents
emailthe address you intend to administer — one the directory does not already hold
statuspending
expires_atany future timestamp
inviter_idthe id of any existing sys_user row

Measured on that population: sign-up 200 and sign-in 200 for the invited address, with no mail transport wired. On the single posture the next boot then promotes that account — measured adminPromoted: true, with the grant landing on the invited account holder and never on a credential-less directory row. On a walled posture the invited address must also be declared in OS_PLATFORM_OWNER_EMAIL and read verified: the operator-provisioning verified stamp fires only for a bootstrap or admin/SCIM creation, never for an invitation-admitted one, so that address needs a mailbox it can receive the verification at.

Invite an address the directory does not already hold. A sign-up for an address that already carries a sys_user row is refused 422 USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL, invitation or not — the seeded people get their logins from the recovered administrator afterwards, not from this step.

Two remedies that look like they work, measured:

  • Opening the audience posture is not enough on its own. With the posture widened to email_domain, a seeded person's own registration writes nothing and buys them no login. It is refused explicitly, as the invite_only default already refuses an address the directory holds — or, while the mail transport is live, it gets the same answer a new registration gets and the address is mailed that it already has an account (see the next section). Either way their sign-in still fails. A fresh address does get an account, but every posture other than invite_only forces email verification on (unless an open deployment has itself declared it off — see Email verification under each posture), so its first sign-in is refused 403 EMAIL_NOT_VERIFIED until a mail transport delivers the link.
  • A hand-written credential row authenticates nothing. The sys_account row shape is public; the format of the secret stored in its password column is the platform's own. A row carrying a plaintext password is refused 401 INVALID_EMAIL_OR_PASSWORD — while silencing the boot diagnostic above.

The cheap prevention: have whatever seeds the people directory seed their logins too, or leave the directory empty until the first administrator exists. A deployment that boots with zero human rows is the case both paths above describe, and it needs none of this.

No sign-in method left

Accounts are not enough if nothing serves a way to use them. With email and password sign-in off, the deployment depends on its other sign-in methods: a social or OIDC provider with a client ID and secret, enterprise SSO with at least one registered identity provider, phone-number sign-in, or a host sign-in handoff. Three doors used to remove the last of them without a word; each now answers:

DoorWhat happens now
The auth settings save turns email and password off, or removes Google, leaving nothingRefused 400 SETTINGS_VALIDATION at the field
Setup's Delete SSO Provider on the last identity provider (POST /api/v1/auth/sso/delete-provider)Refused 409 DELETE_RESTRICTED, nothing deleted; 503 SERVICE_UNAVAILABLE when the provider list cannot be read to tell
A redeploy whose configuration no longer declares the last provider (for example, without the GOOGLE_CLIENT_* pair)Boots, and reports at error under the grep token no_sign_in_method_at_boot

The boot is not refused: a deployment that signs people in through a door the auth plugin cannot see keeps starting. Recovery: set OS_AUTH_EMAIL_PASSWORD_ENABLED=true and restart. The environment override wins over a stored auth.email_password_enabled = false and over the stack config, and email and password sign-in comes back. Or restore the sign-in method the configuration no longer declares.

A cloud-managed runtime (OS_CLOUD_MANAGED=1) whose deployment declares email and password off is the exception. The host refuses every password sign-in there, so the settings never turn it back on: a save of auth.email_password_enabled that reads on is refused 400 SETTINGS_VALIDATION at the field, a value stored on earlier is not applied (the server says so once at error), and GET /api/v1/auth/config keeps answering emailPassword.enabled: false. Turning the switch off or clearing it is accepted there without the checks above, because it removes no way in. OS_AUTH_EMAIL_PASSWORD_ENABLED is the deployment's own declaration and still applies.

Who may sign up — and what each posture tells a stranger

auth.audience.posture is the one declaration answering who may become a user of this deployment: invite_only (the default), email_domain, or open (schema: Auth Config). It also decides what the sign-up endpoint tells someone who is not a user yet. Measured on a populated deployment, posting to /api/v1/auth/sign-up/email:

PostureWhat a stranger learns
invite_only (default)Nothing. A registered address and an unknown one both answer 403 SELF_REGISTRATION_CLOSED — same body bytes, same headers.
email_domainOnly inside a domain you allowlisted. Any address outside the list answers 403 EMAIL_DOMAIN_NOT_ALLOWED, registered or not, so a caller must already hold an address on an allowlisted domain before they learn anything.
openNothing, while the mail transport is live. A registered address gets the same answer as a new sign-up, nothing is written, and the address's holder is mailed that it already has an account. Without a live transport, or with email verification declared off and auto sign-in left on, a registered address is refused explicitly, so the answer tells a caller that the address is registered.

Under invite_only, a sign-up is admitted only by the invitation it presents. The sign-up sends the invitation's id, the last segment of its /accept-invitation/ link, as invitationId beside the email: the Console's register page does this for an invitee who arrived from the link, and os register --invitation does it from a terminal. An address alone gets the same 403 SELF_REGISTRATION_CLOSED as an address nobody invited. The first account of a new deployment needs no invitation. Admission is all the invitation's id grants: the account it admits joins no organization until it accepts the invitation, and accepting needs a verified address.

Under email_domain, an invitation admits an address off the allowlist, and grants nothing more. A pending invitation addressed to an address outside the list admits that address's sign-up. Verification is forced on under this posture, and while the account's address is unverified it joins no organization: it joins by accepting the invitation once the address is verified, and the acceptance writes the membership the invitation names. Verifying the address binds nothing by itself. An address on the list is admitted by its domain, invitation or not: the membership policy binds it at creation as before, it receives the declared selfRegistrationPermissionSet like an uninvited sign-up, and a pending invitation still places it as the invitation names once it accepts. Both admissions have one exception: under this posture a sign-in through a social provider creates an account only when the provider reports the address verified, and is otherwise refused 403 SELF_REGISTRATION_CLOSED, whatever the list or an invitation says (Authentication). Once the provider verifies the address, the next sign-in is admitted. Under open every address is admitted by the posture, invitation or not, so an invited sign-up likewise receives the declared set beside its invitation — except a sign-in through a social provider whose address the provider did not verify while email verification is in force, which is refused 403 SELF_REGISTRATION_CLOSED as above.

A sign-up the posture admits needs its declared set, invited or not. When selfRegistrationPermissionSet cannot be resolved (no such set, or the set is switched off), every sign-up the posture's own rule admits is refused 403 AUTH_CONFIG_ERROR, and the message names the set: any address under open, an address on the list under email_domain, with or without a pending invitation. Nothing is created, and the deployment logs the same reason at error level. Correct the setting, or switch the set on, and the next sign-up is admitted. A pending invitation does not admit such a sign-up without the set. The two admissions an invitation makes alone, under invite_only and for an address off the list under email_domain, ask for no set and are unaffected.

Accepting, declining and listing an invitation need a verified email address, on every deployment. The invitation's id, which its link carries, proves nothing about the mailbox. From a session whose address is not verified, POST /api/v1/auth/organization/accept-invitation and POST /api/v1/auth/organization/reject-invitation answer 403 EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION and write nothing, and GET /api/v1/auth/organization/list-user-invitations answers 403 EMAIL_VERIFICATION_REQUIRED_FOR_INVITATION. Reading one invitation by its id (get-invitation) stays open, so the accept page can show it. A password account verifies through the verification mail; an account a social or SSO sign-in made counts only when its provider verified the address. The Console's accept page sends an unverified person to the verification-mail screen, and the link in that mail brings them back to accept. A visitor who is not signed in and opens the link from the invitation mail itself needs no separate step: the accept page offers the one-step form, which verifies the address as it accepts. No setting relaxes this rule.

A deployment without a live mail transport cannot onboard a password account by invitation link. With no transport configured, or the log transport, no verification mail and no invitation mail reaches anyone, so an invitee who signs up with a password cannot verify the address or accept; a link handed over with the invitation's Copy Invite Link action admits the sign-up and nothing more. The one exception is an invitee who signs in through a social or SSO provider that verifies the address: that account counts as verified, so it can accept a copied link without any mail. To bring anyone else in there, a platform administrator creates the account (POST /api/v1/auth/admin/create-user), or attaches an account that already exists with the member list's Add Member action. Add Member is open to platform administrators only, and it attaches existing accounts only: it creates no account and sends no invitation.

What decides it on open and email_domain. A sign-up for an address that already has an account gets the same answer as a successful new sign-up, and writes nothing, when all three of these hold:

  • The posture is open or email_domain. invite_only is unchanged: the uniqueness question is reached only for a caller the posture has already admitted, so a stranger on the default still learns nothing.
  • Email verification is on, or auto sign-in is off. Only then does a new sign-up's own answer carry no session, so an existing address can get the same answer without a session for someone else's account.
  • The email service's transport is live: IEmailService.isConfigured() answers true. It is asked at every sign-up, so a transport saved from the mail settings applies to the next one. plugin-email's log transport is never live, in any environment, and an email service without that member counts as not live.

The address's holder then receives a mail saying the address already has an account, with links to the sign-in and forgot-password pages and no token. It is the built-in auth.existing_account_sign_up template, overridable like the other auth mails, in the holder's stored language or else the deployment default. The platform wires better-auth's onExistingUserSignUp hook to send it, and decides first, before the auth engine answers, whether that mail can be promised.

Otherwise the refusal stays explicit. With no live transport, on invite_only, or on open with verification declared off and auto sign-in left on, a sign-up for a registered address is refused outright. On open that refusal tells anyone who can reach the endpoint whether an address belongs to a user of this deployment, one address per request — an address-enumeration oracle on an internet-facing deployment. It stays because a success answer is honest only when a mail follows it: what the refusal replaced was a duplicate sign-up answered as a success for a row that was never written, with no mail and a next sign-in that failed with nothing explaining it. To close the oracle on open, keep verification on and connect a mail transport.

Email verification under each posture

  • invite_only follows auth.require_email_verification (OS_AUTH_REQUIRE_EMAIL_VERIFICATION), off by default.
  • email_domain forces verification on, and an explicit false is refused: the domain allowlist is the only gate there, so an unverified sign-up could claim a colleague's address.
  • open forces verification on too, unless the deployment turns it off: set OS_AUTH_REQUIRE_EMAIL_VERIFICATION=false, or emailAndPassword.requireEmailVerification: false in the stack config. A sign-up is then signed in at once and no verification mail is sent.

Under email_domain, and under open while verification is in force, a new account through a social provider is created only when the provider reports the address verified; otherwise the sign-in is refused 403 SELF_REGISTRATION_CLOSED and nothing is written (Authentication).

The open opt-out is for a deployment with no mail transport that trusts whoever can reach it, such as a pre-production environment. It is loud and it has a cost:

  • The boot logs one warning naming the posture and the consequence, and /api/v1/auth/config reports requireEmailVerification: false — the value actually wired.
  • Anyone can register an address they do not control. An organization invitation sent to that address still waits for the address to be verified.
  • It is the deployment's to declare. A false stored only through the settings console is refused under open, and verification stays on.

Go-live

Before pointing real users at the deployment, walk the Production Readiness checklist — security headers, rate limits, metrics, error reporting, backup/restore drills, and data-retention windows.

Your self-hosted app is AI-operable out of the box: every deployment serves an MCP server at /api/v1/mcp under the same permissions and RLS. Disable with OS_MCP_SERVER_ENABLED=false. See Your app as an MCP server.

On this page