Playbook: Public endpoints, scoped invites, and subdomain routing
How to build products with unauthenticated public endpoints (public status pages, docs, webhooks), external single-project collaborators, and tenant subdomains (acme.api.example.com) — all through the same Plat5 gateway.
1. Config (plat5.yml & services/portal.yml)
Section titled “1. Config (plat5.yml & services/portal.yml)”Declare your kinds and roles in plat5.yml:
kinds: organization: path: /orgs/{organization} list_permission: organization:read project: parent: organization path: /projects/{project} list_permission: project:read bind_creator: false
roles: admin: permissions: ["*"] bindable_at: [organization, project] member: permissions: [organization:read] bindable_at: [organization] editor: permissions: [project:read, project:write] bindable_at: [organization, project]creator_role: adminPut unauthenticated endpoints under scopes.public, and authenticated tenant endpoints under the kind scope in services/portal.yml:
portal: url: http://portal:3000 scopes: public: routes: - path: /public/roadmaps/{slug} methods: [GET] project: upstream_prefix: /projects/{project.id} routes: - path: /roadmap methods: GET: { permissions: project:read } POST: { permissions: project:write }Kind-scoped routes always require an authenticated member of the tree (X-Plat5-Member-Id is always present). Truly unauthenticated endpoints use scope: public, where the gateway skips auth/admit and your service decides which published records to expose.
2. Subdomain routing at your TLS edge
Section titled “2. Subdomain routing at your TLS edge”Plat5 routes strictly by path (/orgs/{organization}/…). When you want tenant subdomains (acme.api.example.com) or custom white-label domains (roadmap.acme.com), terminate TLS and rewrite the path at your edge proxy (Caddy, nginx, or Cloudflare Workers) before forwarding to the gateway:
- For wildcard subdomains (
*.api.example.com): extract the single-label subdomain{tenant}and prepend/orgs/{tenant}to non-/publicand non-/userpaths (for example,GET https://acme.api.example.com/projects/roadmap/roadmap→GET /orgs/acme/projects/roadmap/roadmap), rejecting any request whose path already starts with/orgs/so a tenant subdomain can never address another tenant. - For custom white-label domains (
roadmap.acme.com): map the verified custom domain to its tenant slug at the edge and prepend/orgs/acmethe same way. - Leave
/user/*,/public/*, and/access/routesunprefixed (or serve them on your baseapi.example.comhost).
Because Plat5 sees a single canonical path format, route matching, audit route names, and POST /access/routes behave identically whether traffic arrived via subdomain or path.
3. Adding single-project external collaborators
Section titled “3. Adding single-project external collaborators”When an org wants to invite an outside contractor to only one project, create a root invite with grants and omit the root role:
POST /orgs/acme/invites{ "grants": [{ "node_id": "<roadmap_project_id>", "role": "editor" }], "expires_in": "7d"}The invitee redeems the token via POST /user/invites/redeem and gets a member_id in acme (visible on GET /orgs/acme/members) with the editor binding on roadmap and no root-level permissions — able to reach only /projects/roadmap (and see it in GET /orgs/acme/projects) and nothing else in acme.