From b78d79ce31646f7af1e58fddd758604f71a86c0c Mon Sep 17 00:00:00 2001 From: Andrew Curry Date: Fri, 16 Oct 2026 14:57:47 -0400 Subject: [PATCH] docs: rename team to sub-org in the embed library [ENG-11255] Co-Authored-By: Claude Opus 5.5 --- .changeset/rename-team-to-sub-org.md | 5 +++++ packages/embed/USAGE.md | 16 ++++++++-------- packages/embed/openapi/README.md | 4 ++-- packages/embed/openapi/embed.openapi.yaml | 18 +++++++++--------- packages/embed/src/connect/index.ts | 2 +- packages/embed/src/connect/lifecycle.ts | 4 ++-- packages/embed/src/connect/protocol.ts | 2 +- 7 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 .changeset/rename-team-to-sub-org.md diff --git a/.changeset/rename-team-to-sub-org.md b/.changeset/rename-team-to-sub-org.md new file mode 100644 index 0000000..4ff74a6 --- /dev/null +++ b/.changeset/rename-team-to-sub-org.md @@ -0,0 +1,5 @@ +--- +'@monad-inc/embed': patch +--- + +Docs: refer to Monad "teams" as "sub-orgs" (sub-organizations) in the README, USAGE guide, OpenAPI spec and JSDoc. No API changes. diff --git a/packages/embed/USAGE.md b/packages/embed/USAGE.md index a333beb..7b465af 100644 --- a/packages/embed/USAGE.md +++ b/packages/embed/USAGE.md @@ -22,7 +22,7 @@ Zero runtime dependencies. ## How it works Two pieces of code: a **session-mint endpoint on your backend** mints -a short-lived, team-scoped token from your long-lived Monad API key, +a short-lived, sub-org-scoped token from your long-lived Monad API key, and a **`createConnectorFrame()` call on your frontend** mounts the iframe using that token. Both shown below. @@ -31,14 +31,14 @@ iframe using that token. Both shown below. ## Step 1 — Mint a session token from your backend Your backend exchanges its long-lived Monad API key for a short-lived, -team-scoped session token, then hands that token to your frontend. +sub-org-scoped session token, then hands that token to your frontend. Example (any HTTP framework — shown here as a Next.js Route Handler): ```ts // app/api/monad/session/route.ts export async function POST(req: Request) { - const { teamId } = await req.json(); // your tenant → Monad team mapping + const { subOrgId } = await req.json(); // your tenant → Monad sub-org mapping const r = await fetch('https://app.monad.com/api/v3/sessions', { method: 'POST', @@ -47,12 +47,12 @@ export async function POST(req: Request) { Authorization: `ApiKey ${process.env.MONAD_API_KEY}` }, body: JSON.stringify({ - organization_id: teamId, + organization_id: subOrgId, ttl_seconds: 1800 }) }); const { session_token, expires_at } = await r.json(); - return Response.json({ session_token, expires_at, organizationId: teamId }); + return Response.json({ session_token, expires_at, organizationId: subOrgId }); } ``` @@ -79,7 +79,7 @@ import { createConnectorFrame } from '@monad-inc/embed/connect'; // Fetch a fresh session from your own backend. const { session_token, organizationId } = await fetch('/api/monad/session', { method: 'POST', - body: JSON.stringify({ teamId: currentUser.teamId }) + body: JSON.stringify({ subOrgId: currentUser.subOrgId }) }).then((r) => r.json()); const frame = createConnectorFrame({ @@ -109,7 +109,7 @@ controls the surrounding chrome. | ----------------------- | ---------------------------- | -------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | `container` | `HTMLElement \| string` | ✅ | — | Element (or CSS selector) the iframe is appended to. | | `sessionToken` | `string` | ✅ | — | Short-lived token from `POST /v3/sessions` (your backend mints this). | -| `organizationId` | `string` | ✅ | — | Monad team org id the session is scoped to. Same value you passed to `/v3/sessions`. | +| `organizationId` | `string` | ✅ | — | Monad sub-org id the session is scoped to. Same value you passed to `/v3/sessions`. | | `kind` | `'input' \| 'output'` | ✅ | — | Which catalog the connector belongs to. | | `typeId` | `string` | ✅ | — | Connector type slug, e.g. `'aws-cloudtrail'`, `'okta-systemlog'`. | | `existingId` | `string` | ⛔ | — | Pass to edit an existing connector. Omit to create a new one. | @@ -231,7 +231,7 @@ that's a change to the connector itself; file an issue. on your domain. Browser same-origin policy means your JavaScript cannot read the iframe's DOM or any value the user types. - **Session tokens are short-lived.** Default 30 min, scoped to a - single team. Compromise of a session token is bounded; compromise + single sub-org. Compromise of a session token is bounded; compromise of the long-lived API key is not — keep it on your backend. - **postMessage with strict origin checks.** Every message between your page and the iframe is validated against the expected origin diff --git a/packages/embed/openapi/README.md b/packages/embed/openapi/README.md index dfad6ed..03737ae 100644 --- a/packages/embed/openapi/README.md +++ b/packages/embed/openapi/README.md @@ -26,7 +26,7 @@ to scaffold servers. It is used to: - **camelCase everywhere.** Backends normalize the Monad API's mixed casing at their boundary so this host-facing contract stays uniform. - **Auth is the host's.** Routes run inside the host app behind its existing - auth. The backend derives the Monad team (`organizationId`) from the request + auth. The backend derives the Monad sub-org (`organizationId`) from the request via its own `getCustomerOrgID` hook; the browser never sends a tenant id. - **The pre-provisioned side is server-resolved.** Ingress's store output, egress's source input, and the delete cleanup policy are decided server-side, @@ -40,7 +40,7 @@ to scaffold servers. It is used to: | Method · path | operationId | Purpose | | ------------------------------- | ---------------------- | ----------------------------------------------- | | `GET /embed/config` | `getConfig` | Non-secret iframe config (public). | -| `POST /embed/session` | `createSession` | Mint a short-lived, team-scoped token. | +| `POST /embed/session` | `createSession` | Mint a short-lived, sub-org-scoped token. | | `GET /embed/catalog` | `listCatalog` | Offered connector types for a kind. | | `GET /embed/connectors` | `listConnectors` | A tenant's configured connectors. | | `POST /embed/pipelines/ingress` | `buildIngressPipeline` | Wire a configured input → the tenant's store. | diff --git a/packages/embed/openapi/embed.openapi.yaml b/packages/embed/openapi/embed.openapi.yaml index bc52d8b..ea31ad1 100644 --- a/packages/embed/openapi/embed.openapi.yaml +++ b/packages/embed/openapi/embed.openapi.yaml @@ -23,7 +23,7 @@ info: contract stays uniformly camelCase. - **Auth is the host's.** These routes run inside the host app and are protected by its existing session/auth. The backend derives the Monad - team (`organizationId`) from the authenticated request via its own + sub-org (`organizationId`) from the authenticated request via its own `getCustomerOrgID` hook — the browser never sends a tenant id. - **The pre-provisioned side is server-resolved.** For ingress the store output, for egress the source input, and the delete cleanup policy are @@ -50,7 +50,7 @@ tags: - name: Config description: Non-secret configuration the browser needs to mount the iframe. - name: Session - description: Minting short-lived, team-scoped tokens for the iframe. + description: Minting short-lived, sub-org-scoped tokens for the iframe. - name: Catalog description: Which connector types are offered, and what a tenant has configured. - name: Pipelines @@ -90,12 +90,12 @@ paths: summary: Mint an embed session token description: > Trades the host's long-lived Monad API key for a short-lived, - team-scoped session token. The tenant is derived from the authenticated + sub-org-scoped session token. The tenant is derived from the authenticated request server-side (never sent by the browser). The returned token is the only credential that crosses into the iframe. responses: '200': - description: A freshly minted session, scoped to the caller's tenant team. + description: A freshly minted session, scoped to the caller's tenant sub-org. content: application/json: schema: @@ -390,7 +390,7 @@ components: The host application's own session/auth. These routes are mounted inside the host app and protected by its existing middleware; the cookie shown here is illustrative — use whatever your app already uses. The backend - derives the Monad team (`organizationId`) from this authenticated request + derives the Monad sub-org (`organizationId`) from this authenticated request via its `getCustomerOrgID` hook. `GET /embed/config` is the only unauthenticated route. @@ -439,10 +439,10 @@ components: properties: sessionToken: type: string - description: Short-lived, team-scoped token. Pass to the iframe; never log or persist. + description: Short-lived, sub-org-scoped token. Pass to the iframe; never log or persist. organizationId: type: string - description: The Monad team (org) id the token is scoped to. + description: The Monad sub-org id the token is scoped to. expiresAt: type: string format: date-time @@ -623,7 +623,7 @@ components: Forbidden: description: > Authenticated, but not permitted for the requested tenant or resource — - for example the host's `getCustomerOrgID` could not map the caller to a Monad team. + for example the host's `getCustomerOrgID` could not map the caller to a Monad sub-org. content: application/json: schema: @@ -651,7 +651,7 @@ components: $ref: '#/components/schemas/Error' example: code: conflict - message: A connector with that name already exists in this team. + message: A connector with that name already exists in this sub-org. UpstreamError: description: The Monad API returned an error or was unreachable. content: diff --git a/packages/embed/src/connect/index.ts b/packages/embed/src/connect/index.ts index a58d606..4177ba5 100644 --- a/packages/embed/src/connect/index.ts +++ b/packages/embed/src/connect/index.ts @@ -84,7 +84,7 @@ export interface ConnectorFrameOptions { /** Short-lived embed session token (host backend mints it). */ sessionToken: string; /** - * Team org id the session is scoped to. The host backend already knows + * Sub-org id the session is scoped to. The host backend already knows * this — it's the same value passed to `/v1/embed/sessions` when minting * the token. Forwarded into the iframe so it can build `/v1//*` and * `/v2//*` URLs. diff --git a/packages/embed/src/connect/lifecycle.ts b/packages/embed/src/connect/lifecycle.ts index 4638805..d1d5800 100644 --- a/packages/embed/src/connect/lifecycle.ts +++ b/packages/embed/src/connect/lifecycle.ts @@ -53,8 +53,8 @@ interface PipelineNode { * * The pipelines list is slim (no node wiring), so this fetches each * pipeline's detail and scans for the input node. Fine for the modest - * pipeline counts a single tenant team has; a host managing many - * pipelines per team should instead persist the `pipelineId` + * pipeline counts a single tenant sub-org has; a host managing many + * pipelines per sub-org should instead persist the `pipelineId` * buildDevNullPipeline returns and skip the lookup. * * Returns null when the input has no pipeline. diff --git a/packages/embed/src/connect/protocol.ts b/packages/embed/src/connect/protocol.ts index d1d4a38..ec41d7e 100644 --- a/packages/embed/src/connect/protocol.ts +++ b/packages/embed/src/connect/protocol.ts @@ -145,7 +145,7 @@ export interface InitMessage { /** Monad API base, e.g. "https://api.monad.com" or dev "http://localhost/api". */ apiBase: string; /** - * Team org id the session token is scoped to. The iframe uses this to + * Sub-org id the session token is scoped to. The iframe uses this to * build `/v1//*` and `/v2//*` URLs. Must match the token's * `org` claim — server-side `org_access.Middleware` will 403 if not. */