> ## Documentation Index
> Fetch the complete documentation index at: https://arcmira.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Arcmira has three API capabilities: Search (entities, mentions, appearances, commercial intelligence), Monitors (trackers plus alert delivery), and Transcripts (read, generate, correct). Community Review is the cross-surface correction layer.
> Discover pages at https://arcmira.com/docs/llms.txt, then fetch the matching page's .md export. Each capability has a self-contained '<capability> for coding agents' page; prefer it.
> Auth: Authorization: Bearer arc_sk_... or x-api-key: arc_sk_... (x-api-key wins if both are sent). Never put keys in browser code. Check GET /v1/me for tier, scopes, and remaining rows before metered pulls.
> Search: resolve names with GET /v1/entities/lookup and pin ent_* IDs before pulling metered rows. Only person entities have appearances. Mention and recommendation rows carry canonical numeric timestamps in start_seconds/end_seconds (integer seconds; 0 means full episode); the MM:SS string fields are deprecated. Commercial routes need Pro+ tier AND the recommendations:read scope and bill 10 rows per row.
> Monitors: a tracker watches one entity; a monitor groups trackers with shared delivery (email, Slack, HMAC-signed webhooks). Create trackers with POST /v1/trackers, then attach by id: POST /v1/monitors/{id}/trackers { trackerIds: [...] }. Each fired alert occurrence debits 100 rows. Poll GET /v1/monitors/{id}/alerts?n= for recent deliveries. Send Idempotency-Key on every POST/PATCH.
> Transcripts: switch on the access field (unlocked, locked, premium_pending, not_transcribed, unauthenticated). Honor Retry-After when polling POST /v1/transcriptions jobs. Corrections (POST /v1/videos/{video_id}/corrections; kinds line_edit, speaker_reassign, speaker_identify, add_person, entity_tag, segment_rewrite) cost 0 rows; anchored kinds need revision + anchor.contentHash (djb2 base-36); handle 409 (re-anchor) and 412 (expectedSeq). segment_rewrite replaces an inclusive segment range with new segments (empty replacements array deletes; timestamps repaired server-side).
> Community Review is free (0 rows) and surface-typed: POST /v1/feedback with a type matching the surface you called, the reproducing query, and corrections targeting public IDs (ent_*, men_*, com_*). Nothing auto-applies. Do not send untyped notes.
> Errors: switch on error.code, follow doc_url, quote X-Request-Id to support. Honor Retry-After on 429. Retries of POST/PATCH must reuse the same Idempotency-Key; replays return Idempotency-Replayed: true.
> Teams Admin API: GET /v1/team/members, /v1/team/spend, /v1/team/usage-events (cursor-paginated, 90-day bound) are read-only and require a team-scoped API key created by a team admin; personal keys get 403 team_key_required.

# Teams docs spec (for the docs-writing agent)

> Specification for the six public Teams documentation pages, mirroring Cursor's teams docs structure with explicit Arcmira deltas. Not user-facing.

## Pages to write

Mirror Cursor's `cursor.com/docs/account/teams/*` structure 1:1 where our
functionality is congruent. Six pages:

1. `teams/setup`
2. `teams/pricing`
3. `teams/members`
4. `teams/sso`
5. `teams/dashboard`
6. `teams/analytics`

## Global deliberate deltas from Cursor (apply on every page)

* **Usage is denominated in rows, not tokens or model requests.** There is no
  Cursor "Token Rate" analog. The on-demand rate is a flat **\$0.004/row** for
  every tier and seat type. Never invent per-model pricing.
* **No client-version or AI-code-tracking analytics.** Our analytics are
  feature-level row consumption (Search / Monitors / Transcripts), API
  requests, and monitor pings. There is no "tab acceptance" or editor metric.
* **No marketplace, Bedrock, or MDM sections.** Cursor's device/model
  governance suite (MDM, model access control, repo blocklist, auto-run
  policy) has no Arcmira analog and is skipped entirely, not "coming soon."
* **Analytics are available on Teams** with no client-version gating.
* **The audit log is positioned as Enterprise.** Events are recorded for all
  teams from day one (backfill-safe), but the viewer is Enterprise-only.
* Em dashes are forbidden in user-facing copy (site rule). Use periods,
  commas, or colons.

## Teams vs Enterprise gating table (docs must never promise Enterprise features on Teams)

| Capability                                                                                 | Teams                       | Enterprise |
| ------------------------------------------------------------------------------------------ | --------------------------- | ---------- |
| Roles: Member / Admin / Unpaid Admin                                                       | Yes                         | Yes        |
| Seat types: Standard $40, Premium $120 (5x), Free (Unpaid Admin)                           | Yes                         | Yes        |
| Email invites, invite links, domain matching, invite-domain restriction                    | Yes                         | Yes        |
| SAML 2.0 / OIDC SSO + JIT provisioning + enforcement (no extra cost)                       | Yes                         | Yes        |
| Centralized per-active-seat billing, prorated mid-cycle adds                               | Yes                         | Yes        |
| Team-wide spend limit, on-demand toggle, admin-only usage controls, default per-user limit | Yes                         | Yes        |
| Team analytics dashboard with CSV export                                                   | Yes                         | Yes        |
| Teams Admin API (`/v1/team/*`: members, spend, usage events)                               | Yes                         | Yes        |
| SCIM / directory sync                                                                      | No ("Contact sales")        | Yes        |
| Pooled usage across the team                                                               | No                          | Yes        |
| Audit log viewer UI                                                                        | No (recorded, not viewable) | Yes        |
| Per-member spend overrides and group-based limits                                          | No                          | Yes        |
| Analytics API (programmatic chart data)                                                    | No                          | Yes        |
| Invoice/PO billing, volume discounts, priority support, dedicated AM                       | No                          | Yes        |

## Page 1: `teams/setup`

Mirror Cursor's setup page: creating a team, upgrading from an individual
plan, and domain-based joining.

* Creation flow: `/team/new-team` collects team name, Standard and Premium
  seat counts (minimum 2 seats total), and monthly/yearly interval, then goes
  through Stripe Checkout. The team is created by the Stripe webhook after
  payment.
* Entry points: the always-visible **Members** tab in the dashboard shows an
  "Upgrade to Teams" state for users without a team (feature grid: Team
  Management, Usage Analytics, Admin Controls, Shared API Keys) plus a
  "Need enterprise features?" contact-sales banner.
* Individual-plan holders who join a team keep their personal subscription
  until they cancel it themselves (document this explicitly).
* Domain join opt-in: when a team has verified a domain and enabled Domain
  matching, users with a matching email see a "Join your team" banner on the
  Members tab and can self-serve join (Standard seat, Member role).

## Page 2: `teams/pricing`

* **Standard seat: \$40/user/month** with 5,000 rows/month included.
* **Premium seat: \$120/user/month** with 25,000 rows/month included (5x).
* **Unpaid Admin seats are free**, unlimited, and have no product access.
* Yearly billing: 20% off ($32 and $96 per seat per month, billed annually).
  Monthly-to-yearly switching is immediate and prorated; yearly-to-monthly is
  not available mid-plan.
* Billing is per active seat and centralized on the team. Mid-cycle seat adds
  and Standard-to-Premium upgrades are prorated immediately.
  Premium-to-Standard downgrades apply at the next renewal.
* Removal rule: removing a member who consumed included rows this cycle keeps
  the seat billed until the end of the cycle; otherwise the seat is released
  immediately with a prorated credit.
* On-demand usage: \$0.004/row after included seat rows, controlled by the
  team on-demand toggle and the team-wide monthly spending limit.
* Minimums/invariants: 2 seats at purchase; every team keeps at least one
  admin and at least one paid member.

## Page 3: `teams/members`

* Roles and the capability matrix (Cursor parity):
  * All roles (including Members) can invite new members (Members can invite
    Standard-seat Members only).
  * Only Admins and Unpaid Admins can remove members, change roles or seat
    types, access team settings sections, configure SSO/domains, manage
    billing, and view team analytics (full spend columns).
  * Unpaid Admins are free, non-billable, and have no product access.
* Seat type is independent of role (except Unpaid Admin, which is always the
  free seat).
* Joining paths: email invites (7-day expiry, delivered by email with an
  accept page at `/team/invite/{token}`), revocable long-expiry invite links
  (`/team/join/{token}`, admin-managed, rotate/revoke), SSO auto-join (JIT),
  and domain matching. "Restrict invites to verified domains" blocks invites
  to outside addresses; both domain controls require at least one verified
  domain.
* Removal semantics: seat-hold-until-cycle-end when credits were used, the
  member's team-scoped API keys are revoked, their access tier reverts unless
  they carry a personal subscription, and admins can revoke the removed
  member's active sessions.

## Page 4: `teams/sso`

* SAML 2.0 and OIDC at no extra cost on Teams.
* Prerequisite: verify domain ownership in Settings -> Domains (DNS TXT
  record `_arcmira-verify.{domain}` with value `arcmira-verify={token}`).
* Configuration lives in the dashboard Settings tab (Single Sign-On section):
  provider ID, issuer/entity ID, domain, and either IdP metadata XML (SAML)
  or client ID/secret + discovery endpoint (OIDC).
* Document the SP endpoints (Better Auth SSO plugin paths under
  `https://api.arcmira.com/api/auth/`): SP metadata at
  `sso/saml2/sp/metadata?providerId={id}`, ACS at
  `sso/saml2/sp/acs/{providerId}`.
* JIT provisioning: first SSO sign-in auto-creates the account and enrolls it
  into the team (Standard seat, Member role); seats auto-expand and are
  prorated.
* Enforcement: the "Enforce SSO" toggle blocks password and Google sign-in
  for all verified-domain emails. Sign-in via the "Use single sign-on (SSO)
  instead" link on the sign-in page.

## Page 5: `teams/dashboard`

Document OUR actual layout, not Cursor's separate admin console:

* **Members tab** (always visible, above API Keys in the sidebar): member
  list with role and seat badges, invite modal (email + invite link), pending
  invite management, and the Upgrade-to-Teams state for individual users.
* **Settings tab**: personal settings first, then team sections for admins:
  Usage-Based Pricing (on-demand toggle, admin-only toggle, team spending
  limit, default per-member limit), Domains (add/verify + domain matching +
  invite restriction), Single Sign-On (connection wizard + enforcement),
  Team Profile (rename + delete team danger zone). Invite link management
  lives in the invite modal on the Members tab.
* **Billing tab**: team seat counts by type with prorated adjustments, the
  yearly-switch banner, and the existing invoice portal.
* **Team API keys**: created from the API Keys tab with a team scope
  (admin-only) for the Teams Admin API.
* Audit log: recorded for all teams; the viewer is Enterprise-only (the
  endpoint returns `enterprise_required` on Teams).

## Page 6: `teams/analytics`

* Analytics are integrated into the main dashboard **Overview** tab (not a
  separate analytics page): admins see team spend vs limit tiles, a summary
  stat row (active members, rows consumed, API requests), a team-wide
  rows-per-day chart, and a searchable, sortable, paginated per-member table.
* Visibility rules: all members can see the member table (leaderboard
  semantics via default rows-used sort); spend columns are admin-only.
* Time ranges: 7/30/90 days (bounded at 90).
* CSV export for both the chart and the member table.
* Teams Admin API (read-only, team-scoped API keys):
  * `GET /v1/team/members`
  * `GET /v1/team/spend`
  * `GET /v1/team/usage-events` (cursor-paginated, bounded to 90 days)
  * The analytics chart data itself is NOT exposed via API on Teams
    (Enterprise gating, matching Cursor).

## Implementation references (for fact-checking, do not link publicly)

* Backend: `apps/backend/src/handlers/teams.ts` (consolidated surface),
  `team-analytics.ts`, `team-checkout.ts`, `src/v1/team.ts`,
  `src/services/team.ts`, `team-billing.ts`, `team-sso.ts`, `team-email.ts`.
* Schema: `apps/backend/migrations/jobs/0067_teams_v2.sql`, `0068_sso_provider.sql`.
* Web: `apps/web/components/dashboard/members-tab.tsx`, `team-settings.tsx`,
  `team-overview.tsx`, `team-billing.tsx`, `apps/web/app/team/*`.
