Skip to content

Configuration

StoryOS is configured with environment variables in a .env file next to docker-compose.yml (Compose reads it automatically). Two values are required, BETTER_AUTH_SECRET and CONNECTIONS_MASTER_KEY: docker compose up stops and names the one that is missing.

Variable Default Notes
BETTER_AUTH_SECRET — (required) Generate with openssl rand -hex 32.
CONNECTIONS_MASTER_KEY — (required) Generate with openssl rand -hex 32 (exactly 64 hex characters). Encrypts every saved Connections credential at rest. docker compose and the API refuse to start without it, and say which variable is missing. Keep it and back it up with your database: changing it makes saved connections unreadable.
POSTGRES_PASSWORD storyos Change for anything internet-facing.
API_URL / WEB_URL http://localhost (port 80) Set both to your public URL (same origin), e.g. https://os.example.com. Auth only accepts requests whose Origin is exactly WEB_URL, otherwise sign-up fails with “Invalid origin”; if you change HTTP_PORT, set both to http://localhost:<port>. WEB_URL is also passed to the mcp service (the origin used to build the url field on MCP record responses) and to web itself (metadataBase, so shared-link previews resolve images against your real domain instead of localhost).
NEXT_PUBLIC_API_URL empty (same-origin) Only for split-origin setups (API on a different host). Set at build time.
CSP_MODE empty (enforced) Exactly report-only makes browsers log Content-Security-Policy violations instead of blocking them; any other value enforces. Read by the web container on every request, so changing it needs a restart, not a rebuild. See Security headers.
ACTIVITY_EVENTS_RETENTION_DAYS unset (keep everything) Days of record-level activity (edits, comments, links, an agent’s outward log) to keep before a daily job deletes it, so the activity table and your backups stop growing. A whole number, or 0 / never / unset to keep everything. Events not about one record are never deleted. Even when this is set, nothing is deleted before 27 December 2026. See how long the audit log keeps record events.
API_INTERNAL_URL http://api:3001 The web container’s own server-side route to api over the compose network, used when a page resolves data before rendering (e.g. a shared view’s link-preview metadata). Change only if you’ve renamed the api service.
HTTP_PORT / HTTPS_PORT 80 / 443 Host ports of the Caddy proxy.
SMTP_HOST / SMTP_PORT / SMTP_USER / SMTP_PASS, MAIL_FROM unset Invites, mentions, verification, and resets. Without SMTP, invite links are copyable in the UI and other emails are logged. Any SMTP provider works.
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET unset Enables “Continue with Google”. Redirect URI: {API_URL}/api/v1/auth/callback/google.
META_APP_ID / META_APP_SECRET unset Enables connecting Facebook & Instagram for publishing. Redirect URI: {API_URL}/api/v1/connections/oauth/callback. Needs Meta’s own app review for pages_manage_posts and instagram_content_publish.
META_ACTIONS_ENABLED / META_GRAPH_VERSION unset / v21.0 true allows posts to Facebook Pages and Instagram; the Graph API version StoryOS calls.
YOUTUBE_CLIENT_ID / YOUTUBE_CLIENT_SECRET unset Enables connecting YouTube for uploading videos. A separate Google OAuth client from the sign-in one above. Redirect URI: {API_URL}/api/v1/connections/oauth/callback. Google has to verify the app for the upload permission before anyone outside its test users can connect.
YOUTUBE_ACTIONS_ENABLED unset true allows uploading a record’s video to a YouTube channel. Off until Google has cleared the app.
YOUTUBE_MAX_UPLOAD_BYTES / YOUTUBE_UPLOAD_CHUNK_BYTES 8 GB / 8 MiB The largest video one upload sends, and the size of each piece (a multiple of 256 KiB). A video is also limited by ATTACHMENT_MAX_BYTES.
STORAGE_DRIVER local s3 for MinIO/S3/R2 — see attachments.
S3_ENDPOINT / S3_BUCKET / S3_ACCESS_KEY / S3_SECRET_KEY keys: none (required) Used when STORAGE_DRIVER=s3. S3_ACCESS_KEY / S3_SECRET_KEY must be set to your own values; the API refuses to boot otherwise.
PDF_RENDERER_URL unset Base URL of the optional PDF renderer. Unset = PDF export unavailable — see PDF export.
ATTACHMENT_MAX_BYTES 20971520 (20 MB) Per-file upload cap.
RATE_LIMIT_PER_MINUTE 300 Per token/session.

Integrations: what’s available self-hosted

Section titled “Integrations: what’s available self-hosted”

One codebase, no crippled edition — but a handful of integrations genuinely can’t work the same way on your own instance as on StoryOS Cloud, and the Integrations gallery (Settings → Integrations) says so plainly rather than showing a Connect button that fails. Every provider falls into one of three tiers:

Tier Examples Self-hosted
API key / token Apify, Resend, SMTP, a generic HTTP connection, bring-your-own-AI over MCP Works identically everywhere — nothing StoryOS-specific to configure.
OAuth, needs a verified app Google (YouTube, Calendar) Cloud uses StoryOS’s own verified OAuth app. Self-hosted: bring your own OAuth app via GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET (or the matching env pair for other providers) — an operator, one-time setup, never a per-user prompt. Unconfigured, the gallery shows “you can turn this on”, not a broken button.
Cloud-hosted only Managed StoryOS AI, the hosted MCP OAuth connector Genuinely cloud-only — nothing to configure, because the thing being offered (StoryOS’s own infrastructure) doesn’t exist on your instance by definition.

The reason for the middle tier: an OAuth app’s redirect URI and platform verification are tied to one domain. StoryOS’s own verified Google app is scoped to app.storyos.dev — it can’t also work for your instance, so a self-hosted deployment needing that provider registers its own app instead of asking every end user to.

StoryOS uses better-auth mounted inside the API for email/password (with verification and reset) plus env-gated Google OAuth — instances without Google credentials simply hide the button. Sessions are database-backed for instant revocation. Personal access tokens (mn_pat_…) are a separate, workspace-scoped credential; see authentication.

Email is optional. When neither RESEND_API_KEY nor SMTP_HOST is set (the default, and what a plain copy of .env.example gives you), invite links are copyable in the UI and other emails, verification links included, are logged rather than sent: docker compose logs api | grep "Email delivery not configured". A blank RESEND_API_KEY counts as unset. To send mail, set RESEND_API_KEY (Resend’s HTTP API, preferred when both are set) or an SMTP provider. Any SMTP provider works — for example Resend’s relay:

Terminal window
SMTP_HOST=smtp.resend.com
SMTP_PORT=465
SMTP_USER=resend
SMTP_PASS=re_your_resend_api_key_here
MAIL_FROM=Quill from StoryOS <quill@your-domain.com>

Every email opens with a small header card, Quill’s picture and the line “Quill from StoryOS”. The pictures are served from your web app at /brand/email/, so WEB_URL must be reachable from your recipients’ mail apps, or they see the alt text “Quill” instead.

That is the server’s own mail. A workspace can also connect its own SMTP server (Settings → Integrations) for the send-email automation. Such a connection must use port 25, 465, 587 or 2525 and a host that resolves to a public address. If your mail relay runs on your own network, allow its range explicitly:

Terminal window
SMTP_ALLOW_PRIVATE_CIDRS=10.0.5.0/24

Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET, and register the redirect URI {API_URL}/api/v1/auth/callback/google in the Google console. Accounts link by verified email.

To let cloud clients connect the hosted MCP endpoint with a sign-in and an Allow page OAuth connector instead of pasting a token, enable the OAuth authorization server:

Variable Where Notes
MCP_OAUTH api + mcp Set true to turn on OAuth discovery (needs the OIDC tables migrated). Off by default.
MCP_PUBLIC_URL mcp Public URL of the MCP endpoint, e.g. https://mcp.your-domain.com.
MCP_AUTH_SERVER mcp Better Auth’s mounted base URL, e.g. https://app.your-domain.com/api/v1/auth.

The instance operator (PLATFORM_ADMIN_EMAIL)

Section titled “The instance operator (PLATFORM_ADMIN_EMAIL)”

PLATFORM_ADMIN_EMAIL names the one person who operates the instance (the platform /admin area). Unset, nobody is a platform admin. On every boot the API looks for an account with that email and grants it; the grant is only ever added, never removed.

The account’s email must be verified. An account that signed up with the address but has not verified it is skipped, and the API log says so (PLATFORM_ADMIN_EMAIL=… matches an account whose email is not verified yet — not seeded). To finish: open the link in the verification email, then restart the API. Signing in with Google arrives already verified. With no SMTP_* configured, the verification link is written to the API log instead of being mailed. Setting the variable before you have signed up is fine; it takes effect on the first restart after your account is verified.

The mcp service refuses a request body larger than 4 MiB with 413. Normal tool calls are far smaller; a very long document body is the case that can approach it. A request that declares a larger Content-Length is refused before its body is read. Set MCP_MAX_BODY_BYTES (a positive whole number of bytes) in the mcp service’s environment to change the cap. The Compose file does not pass this variable through today, so add it under that service yourself. The service also asks the API whether a bearer token is valid before reading the body, and answers 401 if the API says no; if the API is unreachable or errors, the request carries on and the API checks the token on each tool call.

StoryOS sets these on its responses:

  • Framing is refused. Pages from the web app and every API response are sent with frame-ancestors 'none' and X-Frame-Options: DENY, so another site cannot put your instance in an <iframe>. The exceptions are the share links that are meant to be embedded: public forms (/f/…) and public views (/v/…), which any site may frame, so their Embed snippets keep working.
  • X-Content-Type-Options: nosniff and Referrer-Policy: strict-origin-when-cross-origin.
  • Strict-Transport-Security: max-age=31536000, without includeSubDomains. Browsers ignore it on plain HTTP, so an instance served on port 80 behaves as before; once a browser has seen it over HTTPS it will refuse plain HTTP for that host for a year.
  • A Content-Security-Policy on web pages, enforced. Scripts run only with a fresh per-request nonce ('self' 'nonce-…' 'strict-dynamic'): no 'unsafe-inline' and no 'unsafe-eval' in production, so an injected <script> or inline event handler does not execute. Style elements are nonce-only too (style-src-elem 'self' 'nonce-…' plus the hash of one fixed toast-library sheet, no 'unsafe-inline'). Style attributes keep style-src-attr 'unsafe-inline', because React renders every style={{…}} prop as an attribute and an attribute cannot carry a nonce. Also object-src 'none', base-uri 'self', form-action 'self', and the same frame-ancestors rule as above. The page may connect to its own origin, to the API origin if you set NEXT_PUBLIC_API_URL, and to the PostHog host if you configured one; nothing is hard-coded. Those two origins are build-time values: the web bundle can only call the origins it was built with, so set NEXT_PUBLIC_API_URL (and NEXT_PUBLIC_POSTHOG_HOST) when you build the image, not only on the running container. Only WEB_URL and CSP_MODE are read by the running web container on each request. upgrade-insecure-requests is added only when WEB_URL is https://, so an instance on plain HTTP is unaffected, and images from http: hosts are allowed there.
  • If a page breaks. Set CSP_MODE=report-only for the web service and restart it: the same policy, nonces included, is then only reported. The value must be exactly report-only: any other value (including Report-Only or one with a space) keeps the policy enforced, and the web container logs a [csp] warning at startup so a typo is visible. Clickjacking protection stays enforced either way. Browsers send every violation to /csp-report, which writes one csp_violation JSON line per report to the web container’s log (origins only, never paths or query strings; at most 30 lines a minute). If you put your own proxy in front, let /csp-report through to the web service.

Your instance serves its own interactive docs at {API_URL}/api/docs and the raw spec at {API_URL}/api/v1/openapi.json. Create personal access tokens in the app under API tokens — see authentication.