Skip to content

Provisioning and internals

How tenants come to exist and what holds them up, from docs/runbooks/tenant-lifecycle.md and customer-onboarding.md. The executable companion is the New-tenant checklist.

Requirement Detail
Membership PRESH org-1 membership
Role platform_ops in org 1 (membership alone is insufficient)
UI surface /admin/tenants
API surface /api/v1/admin/*, guarded by requirePlatformOps
API org scope Calls require org_id=1; owner email derived server-side

Org 1 is the PreshAI control plane. It provisions and governs; it is not a customer tenant:

  • Org 1 cannot be suspended or deprovisioned. Any suspend/deprovision tooling must exclude it. A missing exclusion is a bug, not an edge case.
  • Object defaults are published from the org-1 Object Manager to tenants via /api/v1/admin/object-defaults/*. Preview first, then apply.

Provisioning runs: PRESH org 1 (platform_ops) creates the tenant in /admin/tenants, which yields the tenant and hostname. The provision-tenant Inngest workflow runs, gated by evaluateTenantReadiness for core-ready. Readiness covers environments with seed_default_agents, mint_workos_org, and the required vercel_alias. Partner admins reach the tenant via Members enrollment. Environments lead to the first governed session on the tenant hostname.

Steps run in this order: registry, branding, hostname, config, RBAC, then mint_workos_org, link_registry, attach_domains, vault_placeholders, ai_gateway_key (token-gated/overridable, skippable without blocking core-ready), verify_defaults, seed_default_agents, seed_owner and send_invite (may precede vercel_alias; the invited owner waits on /preparing until core-ready), converge_post_owner, then vercel_alias (required for core-ready).

  • Poll GET /api/v1/admin/tenants/[id]/provisioning; gate on evaluateTenantReadiness.
  • vercel_alias needs VERCEL_ARCHER_TOKEN and VERCEL_TENANT_PROJECT_ID (names only; values in secret management). Re-verify the alias after every redeploy that moves traffic.
  • Tenant host: <slug>.preshos.com (or custom hostname entered at Create; blank defaults to the slug form). presh slug reserved.
  • Wildcard *.preshos.com; WorkOS redirect https://*.preshos.com/callback; NEXT_PUBLIC_APP_URL=https://preshos.com.
  • Tenant contract (OAuth/webhooks canonical host, HMAC state, allowlist): SDK auth.

Enroll PRESHai internal emails via /admin/tenants/[id] Members. They reach customer tenants through My tenants (/my-tenants). Review the posture at handoff. Keep only what implementation vs. managed-ops needs.

Publish from org-1 Object Manager: /api/v1/admin/object-defaults/*, preview then apply. Applying unpreviewed defaults to tenants is the kind of mistake this rule exists to prevent.

  • Preparing: /preparing (until core-ready)
  • Wizard: app/(onboarding)/onboarding to /onboarding/*
  • Customer APIs: /api/v1/orgs/[id]/*
  • Dashboard after onboarding

Passwords, API keys, tokens (including VERCEL_ARCHER_TOKEN values), connection strings, private keys. Names of env vars where source names them, values never. Customer-identifiable data beyond operational need. Anything flagged not in pasted sources stays flagged until confirmed.