openapi: 3.0.3
info:
  title: Easerix Notes API
  description: |
    Docs & wiki with a rich (Tiptap/ProseMirror) document model
    (backend/services/products/notes). Workspaces are org-scoped: any member
    of the active org shares the org's workspaces. Pages store one JSON doc
    plus a plain-text projection that powers ranked full-text search.
    Responds in camelCase (same recorded drift as links — see contracts/README.md).
  version: 1.0.0
  contact:
    name: Perizer Labs
    url: https://easerix.com
servers:
  - url: https://api.easerix.com/notes
    description: Production
tags:
  - name: system
    description: Health and liveness
  - name: workspaces
    description: Org-scoped workspaces and members
  - name: pages
    description: Page tree and rich documents
  - name: blocks
    description: Legacy per-block editing surface (superseded by the doc endpoints)
  - name: collaboration
    description: Versions, comments, presence, links
  - name: sharing
    description: Public share links and attachments
  - name: search
    description: Ranked full-text search
security:
  - bearer: []
paths:
  /health:
    get:
      operationId: health
      tags:
        - system
      summary: Liveness probe
      description: |
        Unauthenticated liveness check used by the platform and monitors, served
        at the root and under the base path (api.easerix.com/notes/health).
        Status only: the weekly integrity check's result is served on the
        service's internal port, and findings alert the staff list.
      security: []
      responses:
        "200":
          description: Service is up
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - service
                properties:
                  status:
                    type: string
                  service:
                    type: string
  /v1/members:
    get:
      operationId: listMembers
      tags:
        - workspaces
      summary: List known members
      description: Members seen by this service (upserted from JWTs), for name lookups.
      responses:
        "200":
          description: Members
          content:
            application/json:
              schema:
                type: object
                required:
                  - members
                properties:
                  members:
                    type: array
                    items:
                      $ref: "#/components/schemas/Member"
  /v1/workspaces:
    get:
      operationId: listWorkspaces
      tags:
        - workspaces
      summary: List the active org's workspaces
      description: |
        Lists workspaces for the caller's active org, adopting legacy pre-org
        rows into a personal org and provisioning the org's first workspace
        when none exists.
      responses:
        "200":
          description: Workspaces
          content:
            application/json:
              schema:
                type: object
                required:
                  - workspaces
                properties:
                  workspaces:
                    type: array
                    items:
                      $ref: "#/components/schemas/Workspace"
    post:
      operationId: createWorkspace
      tags:
        - workspaces
      summary: Create a space
      description: |
        kind follows the platform scoping standard: 'org' (default, every org
        member), 'team' (requires teamId, caller must belong to the team), or
        'personal' (owner only).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                kind:
                  type: string
                  enum:
                    - org
                    - team
                    - personal
                teamId:
                  type: string
                  format: uuid
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                type: object
                required:
                  - workspace
                properties:
                  workspace:
                    $ref: "#/components/schemas/Workspace"
  /v1/workspaces/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
    patch:
      operationId: updateWorkspace
      tags:
        - workspaces
      summary: Rename a space and/or change its audience
      description: |
        Any member with access to the space may rename it (`name` alone).

        Sending `kind` (and `teamId` for a team space) re-targets the space's
        audience — which subject it belongs to, and therefore who can see every
        page inside it. Those rules are the platform's, enforced by
        `authkit.AuthorizeRetarget` (docs/platform/subjects-and-containers.md):

        - the space's creator may re-target their own space; anyone else needs
          `org.data.audience_manage` (owner/admin) — 403 otherwise
        - a personal space is never reclassified (400) — move its pages out
          with `updatePage.workspaceId` instead
        - only the creator may make a space `personal` (403 otherwise), so a
          space can't vanish into another person's private area
        - a space going `personal` may hold only pages the caller wrote,
          trashed ones included (409 `others_pages` otherwise): move other
          people's pages out first (ENT-146)
        - a `team` target must be a team the caller belongs to (403 otherwise)

        Re-submitting the current audience is a no-op and needs no permission.
        Audience changes are written to the platform audit log as
        `notes.space.audience_changed`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              minProperties: 1
              properties:
                name:
                  type: string
                  description: New name. Omit to leave the name unchanged.
                kind:
                  type: string
                  enum:
                    - org
                    - team
                    - personal
                  description: New audience. Omit to leave the audience unchanged.
                teamId:
                  type: string
                  format: uuid
                  nullable: true
                  description: Target team, required when `kind` is `team`.
                internal:
                  type: boolean
                  description: Internal spaces' pages can't be shared publicly without an owner/admin approval. Anyone may set true; false takes the space owner or a workspace owner/admin (403 internal_owner_only).
      responses:
        "200":
          description: Updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - workspace
                properties:
                  workspace:
                    $ref: "#/components/schemas/Workspace"
        "400":
          description: Blank name, unknown audience, or a personal space being reclassified
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "403":
          description: The caller may not change this space's audience, or may not lift its internal flag (code internal_owner_only)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: The space is going personal but holds pages someone else wrote (code others_pages)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    delete:
      operationId: deleteWorkspace
      tags:
        - workspaces
      summary: Delete a space, and say what happens to its pages
      description: |
        An empty space is deleted with no further input. While any pages
        exist — trashed ones included — the request is refused (409
        `space_not_empty`, with the page count in `pages`) unless `pages`
        says what to do with them, so content is never cascade-deleted by
        accident. Personal spaces can't be deleted (400).

        - `pages=move&to=<space id>` moves every page (sub-pages stay under
          their parents, trashed pages stay trashed) and the space's
          templates to the other space, then deletes this space. It takes the
          authority `updatePage.workspaceId` takes: the space's owner or a
          workspace owner or admin (403 `move_refused` otherwise), and
          `confirmWiden=true` when the target space has a wider audience (409
          `confirm_widen` otherwise, 403 `widening_move` for someone who may
          not widen). 400 `move_target_required` when `to` is missing or is
          this space.
        - `pages=delete&confirm=<space name>` deletes the pages forever with
          the space. `confirm` must be the space's exact name (400
          `confirm_name_required`), and the caller needs the authority of
          `deletePage`: the space's owner, a workspace owner or admin, or the
          person who wrote every page (403 `delete_refused` otherwise).

        Either choice is written to the platform audit log as
        `notes.space.deleted`.
      parameters:
        - name: pages
          in: query
          required: false
          description: What to do with the pages of a space that has some.
          schema:
            type: string
            enum:
              - move
              - delete
        - name: to
          in: query
          required: false
          description: The space to move the pages to. Required with `pages=move`.
          schema:
            type: string
            format: uuid
        - name: confirmWiden
          in: query
          required: false
          description: Acknowledges that moving the pages makes them visible to more people.
          schema:
            type: boolean
        - name: confirm
          in: query
          required: false
          description: The space's exact name. Required with `pages=delete`.
          schema:
            type: string
      responses:
        "200":
          description: Deleted. `moved` or `deleted` counts the pages affected, when there were any.
          content:
            application/json:
              schema:
                type: object
                required:
                  - message
                properties:
                  message:
                    type: string
                  moved:
                    type: integer
                  deleted:
                    type: integer
        "400":
          description: A personal space, a missing or invalid choice, or a missing confirmation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "403":
          description: The caller lacks the authority for the chosen option (codes move_refused, widening_move, delete_refused)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: No such space, or it isn't one the caller can see (also a target space that doesn't exist)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: |
            The space still contains pages and no choice was given (code
            `space_not_empty`, with `pages`), moving them needs the widening
            confirmed (code `confirm_widen`, with the target `space`), pages
            were added or removed while the request ran, or the target space
            was deleted meanwhile, so nothing was changed (code
            `space_changed`; ask again), or a page in the target space already
            has the same `sourceRef` as one that would move (code
            `source_ref_taken`; nothing was moved).
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: string
                  code:
                    type: string
                    enum:
                      - space_not_empty
                      - confirm_widen
                      - space_changed
                      - source_ref_taken
                  pages:
                    type: integer
                    description: How many pages the space holds. Present with `space_not_empty`.
                  space:
                    type: object
                    description: The target space. Present with `confirm_widen`.
                    additionalProperties: true
  /v1/pages:
    get:
      operationId: listPages
      tags:
        - pages
      summary: List pages in a workspace
      description: |
        A person's daily pages (EAS-734) are left out of this list, because
        there is one a day and they would swell every refresh. `listDailyPages`
        lists them, and `include_daily=1` brings them back into this list for a
        tool that wants every page. With `archived=1` (the trash) they are
        included, so one can be restored or deleted.
      parameters:
        - name: workspace_id
          in: query
          required: true
          schema:
            type: string
            format: uuid
        - name: include_daily
          in: query
          description: Pass "1" to include daily pages (EAS-734), which are left out by default.
          schema:
            type: string
        - name: archived
          in: query
          description: Pass "1" to include archived (trashed) pages.
          schema:
            type: string
        - name: source
          in: query
          description: Only pages published by this source (tool).
          schema:
            type: string
        - name: source_ref
          in: query
          description: Only the page with this id in its source (unique per space and source).
          schema:
            type: string
      responses:
        "200":
          description: Pages
          content:
            application/json:
              schema:
                type: object
                required:
                  - pages
                properties:
                  pages:
                    type: array
                    items:
                      $ref: "#/components/schemas/Page"
    post:
      operationId: createPage
      tags:
        - pages
      summary: Create a page
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - workspaceId
              properties:
                workspaceId:
                  type: string
                  format: uuid
                title:
                  type: string
                icon:
                  type: string
                parentId:
                  type: string
                  format: uuid
                  nullable: true
                position:
                  type: number
                source:
                  type: string
                  description: The tool publishing this page from an outside source (e.g. notes-import).
                sourceRef:
                  type: string
                  description: The page's stable id in that source. Unique per space and source; requires source.
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                type: object
                required:
                  - page
                properties:
                  page:
                    $ref: "#/components/schemas/Page"
        "400":
          description: The parent is in another space, or is a daily page (`daily_no_children`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: Another page in this space already has this source and sourceRef; the body carries it so the tool can adopt it.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SourceRefTaken"
  /v1/pages/daily:
    post:
      operationId: openDailyPage
      tags:
        - pages
      summary: Open the caller's daily page for a date
      description: |
        Daily notes (EAS-734). Returns the caller's page for a calendar date,
        creating it when there is none, so it is safe to call twice, from two
        tabs or two devices: a space holds one page per date. A page that was
        trashed is restored. The server picks the space and the client never
        names it: the caller's Private space in a team workspace, or the single
        space of a personal workspace. Nobody else can read the page.

        `date` is the date in the caller's own time zone (YYYY-MM-DD) and must
        be within about a day of the server's date (400 `daily_date_out_of_range`
        otherwise). `title` is used only when the page is created. A daily page
        stays in its space on its date: `updatePage` refuses to move it or
        nest it (409 `daily_page_fixed`), and no page can be nested under it
        (400 `daily_no_children`).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - date
              properties:
                date:
                  type: string
                  pattern: ^\d{4}-\d{2}-\d{2}$
                  example: 2026-11-24
                title:
                  type: string
                  maxLength: 200
                  description: The title for a newly created page. Defaults to the date.
      responses:
        "200":
          description: The page already existed (restored from the trash when `restored` is true)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DailyPageResult"
        "201":
          description: The page was created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DailyPageResult"
        "400":
          description: The date is not a calendar date (`bad_daily_date`) or is not today (`daily_date_out_of_range`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DailyPageError"
        "404":
          description: The caller's private space could not be found or created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    get:
      operationId: listDailyPages
      tags:
        - pages
      summary: List the caller's daily pages
      description: |
        The caller's daily pages, newest day first, without their documents, so
        a long run of days is one narrow query. Trashed days are left out. The
        reply names the space. A person who has never opened a day has no space
        yet, so the list is empty and `workspaceId` is null; reading creates
        nothing.
      parameters:
        - name: from
          in: query
          description: Earliest date to include (YYYY-MM-DD, inclusive).
          schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
        - name: to
          in: query
          description: Latest date to include (YYYY-MM-DD, inclusive).
          schema:
            type: string
            pattern: ^\d{4}-\d{2}-\d{2}$
        - name: limit
          in: query
          description: At most this many days (default 100, at most 400).
          schema:
            type: integer
            minimum: 1
            maximum: 400
      responses:
        "200":
          description: Daily pages
          content:
            application/json:
              schema:
                type: object
                required:
                  - workspaceId
                  - pages
                properties:
                  workspaceId:
                    type: string
                    format: uuid
                    nullable: true
                  pages:
                    type: array
                    items:
                      $ref: "#/components/schemas/DailyPageItem"
        "400":
          description: A date or the limit is malformed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DailyPageError"
  /v1/capture:
    post:
      operationId: captureNote
      tags:
        - pages
      summary: Add a quick note to the caller's Inbox or daily page
      description: |
        Quick capture (EAS-735). Adds a note to the end of a page without the
        caller opening it first: their Inbox (`destination: inbox`), or their
        daily page for a date (`destination: daily`, the same page the daily
        notes call opens). The page is made when there is none, in the caller's
        own private space, which the server picks (see `openDailyPage`). A
        trashed Inbox or day is restored. The note is one write on the server,
        so two captures at once both land, and a page open in an editor picks
        the note up. The words are stored as plain text, one paragraph per
        non-blank line, and are searchable straight away.

        A note holds at most 10,000 characters and 200 lines
        (400 `capture_too_long`). For `daily`, `date` is required and follows
        the rules of `openDailyPage`. A locked page is not written to (423).

        A web clip sends the page it came from as `source`. The clip is added
        as the page's title, bold and linked to its address, then the words as
        paragraphs, with a divider above it when the page already has content.
        The title and the address are searchable too. A clip may have no words
        (a bookmark) and may hold up to 60,000 characters and 1,500 lines. The
        address must be an http or https one (400 `bad_capture_source`
        otherwise): a `javascript:` or `data:` link is never stored.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - destination
                - text
              properties:
                destination:
                  type: string
                  enum:
                    - inbox
                    - daily
                text:
                  type: string
                  description: The note. Blank lines are dropped and each line becomes a paragraph.
                date:
                  type: string
                  pattern: ^\d{4}-\d{2}-\d{2}$
                  description: Required for `daily`. The date in the caller's own time zone.
                title:
                  type: string
                  maxLength: 200
                  description: The title for a daily page made by this call.
                source:
                  type: object
                  description: Set by a web clip. Where the words came from.
                  required:
                    - url
                  properties:
                    url:
                      type: string
                      maxLength: 2048
                      description: The page's address. Only http and https are accepted.
                    title:
                      type: string
                      maxLength: 300
                      description: The page's title. Defaults to the address's host.
      responses:
        "200":
          description: The note was added to a page that already existed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaptureResult"
        "201":
          description: The page was made and the note added to it
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaptureResult"
        "400":
          description: Nothing to save (`empty_capture`), too long (`capture_too_long`), an unknown destination (`bad_capture_destination`), or a bad date for a daily page
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CaptureError"
        "404":
          description: The caller's private space could not be found or created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "423":
          description: The page is locked, so nothing was written
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/pages/{id}:
    get:
      operationId: getPage
      tags:
        - pages
      summary: Get a page with its legacy blocks
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: Page + blocks
          content:
            application/json:
              schema:
                type: object
                required:
                  - page
                  - blocks
                properties:
                  page:
                    $ref: "#/components/schemas/Page"
                  blocks:
                    type: array
                    items:
                      $ref: "#/components/schemas/Block"
    patch:
      operationId: updatePage
      tags:
        - pages
      summary: Update page metadata (title, icon, move, archive, change space)
      description: |
        Setting workspaceId moves the page to another space the caller can
        access — the entire subtree moves with it and the page becomes a
        root of the target space unless the same request also names a parent
        inside it.

        A sidebar drag sends all three move fields at once (space, parent,
        position), so parentId is validated:

        - the parent must be a page the caller can see (404 otherwise —
          never a confirmation that an id exists in another org)
        - the parent must be in the space the page ends up in, so a page is
          never nested under a parent that space's readers cannot open (400)
        - the parent must not be the page itself or one of its own
          descendants (400) — a cycle detaches the whole branch from every
          root and it stops appearing in the tree

        archived=true trashes the page and every live sub-page with the same
        timestamp; archived=false restores the page and exactly that batch
        (sub-pages trashed separately stay in the trash). A page restored
        under a parent that is still trashed comes back at the space root.

        `parentId: ""` clears the parent, putting the page at the top level
        of its space. `position` is a float, so a page can be dropped between
        two siblings by writing one row instead of renumbering the list.

        Any move to another space takes the page and its sub-pages with it
        and hands them to the target space's owner, so it needs the person
        who wrote every page that moves, the owner of the space they are
        leaving, or a workspace owner/admin (403 `move_refused` otherwise). Into
        a Private (personal) space only the person who wrote every page that
        moves may move it there (not the source space's owner or an admin).

        A move into a space with a wider audience — Private to a team or
        everyone, a team to everyone, or one team to another — also exposes
        the page and its sub-pages to people who could not read them before.
        It needs the same authority as changing a space's audience: the owner
        of the space the page is leaving, or a workspace owner/admin (403
        `widening_move` otherwise). Callers who have that authority must
        also send `confirmWiden: true` (409 `confirm_widen` otherwise, with
        the target space so the client can name it in a prompt). Narrowing
        and same-audience moves need no confirmation. Every cross-space move
        is written to the platform audit log as `notes.page.moved`.
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                icon:
                  type: string
                parentId:
                  type: string
                  nullable: true
                  description: Parent page id, or "" for the top level of the space.
                position:
                  type: number
                  description: Sort key among siblings; fractional values order a drop between two of them.
                archived:
                  type: boolean
                workspaceId:
                  type: string
                  format: uuid
                internal:
                  type: boolean
                  description: Override the space's internal flag for this page. false takes the space owner or a workspace owner/admin (403 internal_owner_only).
                source:
                  type: string
                  description: Set ("" clears) the publishing source.
                sourceRef:
                  type: string
                  description: Set ("" clears) the page's id in its source. Unique per space and source; requires source.
                confirmWiden:
                  type: boolean
                  default: false
                  description: Confirms a move into a space with a wider audience. Ignored for any other change.
      responses:
        "200":
          description: Updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - page
                properties:
                  page:
                    $ref: "#/components/schemas/Page"
        "400":
          description: The parent is in another space, would nest the page inside itself, or is a daily page (`daily_no_children`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "403":
          description: The caller didn't write every page that moves, doesn't own the space it's leaving and isn't a workspace owner or admin (move_refused); or the move would widen the page's audience and the caller doesn't own its space and isn't a workspace owner or admin (widening_move)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WideningMoveRefused"
        "409":
          description: |
            Another page in the space already has this source and sourceRef
            (`source_ref_taken`), or the move widens the page's audience and
            was not confirmed (`confirm_widen` — resend with `confirmWiden: true`),
            or the page is a daily page, which stays in its space on its date
            (`daily_page_fixed`), or the Inbox, which stays in its space
            (`inbox_page_fixed`).
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/SourceRefTaken"
                  - $ref: "#/components/schemas/ConfirmWiden"
                  - $ref: "#/components/schemas/DailyPageError"
        "423":
          $ref: "#/components/responses/PageLocked"
    delete:
      operationId: deletePage
      tags:
        - pages
      summary: Delete a trashed page permanently
      description: |
        Only a page that is already in the trash (archived) can be deleted
        forever; a live page returns 409. The page goes with its trashed
        sub-pages. A sub-page that is still live is kept and moved up to the
        deleted page's parent (or the space root if that parent is trashed).

        Deleting forever needs the person who wrote every page it removes,
        the owner of the page's space, or a workspace owner or admin (403
        `delete_refused` otherwise; the page stays in the trash). Moving a
        page to the trash (`updatePage` with `archived: true`) stays open to
        anyone who can edit it. Trashing and restoring are written to the
        platform audit log as `notes.page.trashed` and `notes.page.restored`
        (ENT-147).
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          $ref: "#/components/responses/Message"
        "403":
          description: The caller didn't write every page this would delete, doesn't own the space and isn't a workspace owner or admin (code delete_refused)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: The page is not in the trash
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/pages/{id}/lock:
    put:
      operationId: lockPage
      tags:
        - pages
      summary: Lock a page so it can't be edited by accident
      description: |
        While a page is locked it can be read and commented on, but its
        content, title and icon can't change through any route (the editor,
        live sync, the API, edit share links); those writes answer 423
        `page_locked`. Moving, trashing and sharing still work.

        Only the page's creator or a workspace owner/admin may lock or unlock
        it (403 otherwise). Idempotent: locking a locked page keeps the first
        lock. Each real change adds a `locked` / `unlocked` entry to the
        page's version history and the audit log (`notes.page.locked`,
        `notes.page.unlocked`). Open editors switch to read-only within a few
        seconds.
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          $ref: "#/components/responses/PageLockState"
        "403":
          description: The caller may not lock this page
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: Page not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    delete:
      operationId: unlockPage
      tags:
        - pages
      summary: Unlock a page
      description: The reverse of lockPage, with the same permission rule. Idempotent.
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          $ref: "#/components/responses/PageLockState"
        "403":
          description: The caller may not unlock this page
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: Page not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/pages/{id}/doc:
    get:
      operationId: getDoc
      tags:
        - pages
      summary: Get the rich document
      description: Returns the Tiptap JSON doc, converting legacy blocks on first read.
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: The document
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocPayload"
    put:
      operationId: putDoc
      tags:
        - pages
      summary: Save the rich document (optimistic concurrency)
      description: |
        Saves the doc with the revision the client loaded. A rev mismatch
        returns 409 with the current server doc so the editor can merge
        instead of clobbering another writer. Optionally syncs outgoing
        wiki-link edges in the same save.

        A tool publishing from an outside source also sends publishedRev,
        the rev its last publish wrote (easerix#461). If the page has moved
        past it, people edited it in Notes since, and the save is refused
        with 409 code edited_since_publish unless force is true. A save that
        carries publishedRev or force is recorded as a publish
        (publishedRev/publishedAt on the page). Ordinary saves omit both and
        are unaffected.
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - doc
                - rev
              properties:
                doc:
                  type: object
                  description: Tiptap/ProseMirror document JSON.
                docText:
                  type: string
                  description: Plain-text projection for search.
                rev:
                  type: integer
                  format: int64
                links:
                  type: array
                  description: Outgoing page-link ids (replaces the edge set).
                  items:
                    type: string
                    format: uuid
                publishedRev:
                  type: integer
                  format: int64
                  description: Publishing tools only. The rev the tool's last publish wrote (0 on first publish).
                force:
                  type: boolean
                  description: Publishing tools only. Publish even if the page was edited in Notes since.
      responses:
        "200":
          description: Saved
          content:
            application/json:
              schema:
                type: object
                required:
                  - rev
                  - updated
                properties:
                  rev:
                    type: integer
                    format: int64
                  updated:
                    type: string
                    format: date-time
                  publishedRev:
                    type: integer
                    format: int64
                    description: Present when the save was a publish.
        "409":
          description: Rev mismatch (DocConflict, with the current server state) or, for a publish, edited_since_publish (PublishConflict)
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: "#/components/schemas/DocConflict"
                  - $ref: "#/components/schemas/PublishConflict"
        "423":
          $ref: "#/components/responses/PageLocked"
  /v1/pages/{id}/versions:
    get:
      operationId: listVersions
      tags:
        - collaboration
      summary: List version snapshots (newest first)
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: Versions
          content:
            application/json:
              schema:
                type: object
                required:
                  - versions
                properties:
                  versions:
                    type: array
                    items:
                      $ref: "#/components/schemas/VersionMeta"
  /v1/pages/{id}/versions/{versionId}:
    get:
      operationId: getVersion
      tags:
        - collaboration
      summary: Get one snapshot including its doc
      parameters:
        - $ref: "#/components/parameters/PageId"
        - name: versionId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The snapshot
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VersionDetail"
  /v1/pages/{id}/versions/{versionId}/restore:
    post:
      operationId: restoreVersion
      tags:
        - collaboration
      summary: Restore a snapshot (current doc is snapshotted first)
      parameters:
        - $ref: "#/components/parameters/PageId"
        - name: versionId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Restored
          content:
            application/json:
              schema:
                type: object
                required:
                  - rev
                  - doc
                  - updated
                properties:
                  rev:
                    type: integer
                    format: int64
                  doc:
                    type: object
                  updated:
                    type: string
                    format: date-time
        "423":
          $ref: "#/components/responses/PageLocked"
  /v1/pages/{id}/locate:
    get:
      operationId: locatePage
      tags:
        - pages
      summary: Which workspace a page is in, for a link that names no workspace
      description: |
        For an old link (`/notes/p/<id>`, an email from before workspace URLs),
        so the app can send the tab to `/notes/w/<slug>/p/<id>`. It works
        across the caller's workspaces: the token may be for any of them.

        It answers only when Notes would let the caller read the page in its
        own workspace: they are a member with a product seat, Notes is on
        there, and they can see the page's space. Archived pages are located
        too, as the trash opens them.

        Every other case gets the same 404, byte for byte: no such page,
        someone else's page, a space the caller can't see, Notes turned off
        there, a malformed id, or a request made with an API key or an OAuth
        grant (those are bound to one workspace by consent). Both answers
        are `Cache-Control: no-store`. Rate-limited per user and per client IP
        (the edge's CF-Connecting-IP).
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: The page's workspace
          content:
            application/json:
              schema:
                type: object
                required:
                  - workspace_id
                  - slug
                properties:
                  workspace_id:
                    type: string
                    format: uuid
                  slug:
                    type: string
                    description: The workspace's URL slug, or "" when the stored slug isn't URL-shaped (use the id).
        "404":
          description: Not found, or not the caller's to open (the same response either way)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "429":
          description: Too many lookups; retry after the Retry-After seconds
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/attachments/{id}/locate:
    get:
      operationId: locateAttachment
      tags:
        - sharing
      summary: Which workspace an attachment's page is in
      description: |
        The Notes app's image route (`/notes/attachments/<id>`) holds only the
        session's default-workspace token, so an image on a page in another
        workspace would not be found (EAS-271). With this it finds that
        workspace and exchanges the token for one there.

        The same rules and answers as locatePage, applied to the attachment's
        page: it answers only when the caller could read that page in its own
        workspace. Every other case, including an attachment on no page, gets
        the same 404, byte for byte. Shares locatePage's rate limits.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The workspace of the attachment's page
          content:
            application/json:
              schema:
                type: object
                required:
                  - workspace_id
                  - slug
                properties:
                  workspace_id:
                    type: string
                    format: uuid
                  slug:
                    type: string
                    description: The workspace's URL slug, or "" when the stored slug isn't URL-shaped (use the id).
        "404":
          description: Not found, or not the caller's to open (the same response either way)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "429":
          description: Too many lookups; retry after the Retry-After seconds
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/pages/{id}/blocks:
    get:
      operationId: listBlocks
      tags:
        - blocks
      summary: List a page's legacy blocks
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          $ref: "#/components/responses/Blocks"
    post:
      operationId: createBlock
      tags:
        - blocks
      summary: Create a block
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - type
              properties:
                type:
                  type: string
                content:
                  type: string
                properties:
                  type: object
                parentId:
                  type: string
                  nullable: true
                  description: A block on the same page
                position:
                  type: number
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                type: object
                required:
                  - block
                properties:
                  block:
                    $ref: "#/components/schemas/Block"
        "404":
          description: No such page, or parentId is not a block on this page
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "423":
          $ref: "#/components/responses/PageLocked"
  /v1/pages/{id}/blocks/reorder:
    post:
      operationId: reorderBlocks
      tags:
        - blocks
      summary: Reorder a page's blocks
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - orderedIds
              properties:
                orderedIds:
                  type: array
                  items:
                    type: string
                    format: uuid
      responses:
        "200":
          $ref: "#/components/responses/Blocks"
        "423":
          $ref: "#/components/responses/PageLocked"
  /v1/blocks/{id}:
    patch:
      operationId: updateBlock
      tags:
        - blocks
      summary: Update a block
      parameters:
        - $ref: "#/components/parameters/BlockId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                type:
                  type: string
                content:
                  type: string
                properties:
                  type: object
                position:
                  type: number
      responses:
        "200":
          description: Updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - block
                properties:
                  block:
                    $ref: "#/components/schemas/Block"
        "423":
          $ref: "#/components/responses/PageLocked"
    delete:
      operationId: deleteBlock
      tags:
        - blocks
      summary: Delete a block
      parameters:
        - $ref: "#/components/parameters/BlockId"
      responses:
        "200":
          $ref: "#/components/responses/Message"
        "423":
          $ref: "#/components/responses/PageLocked"
  /v1/pages/{id}/backlinks:
    get:
      operationId: getBacklinks
      tags:
        - collaboration
      summary: Pages that link to this page
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: Backlinks
          content:
            application/json:
              schema:
                type: object
                required:
                  - backlinks
                properties:
                  backlinks:
                    type: array
                    items:
                      $ref: "#/components/schemas/PageRef"
  /v1/pages/{id}/links:
    put:
      operationId: setLinks
      tags:
        - collaboration
      summary: Replace this page's outgoing links
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - targetPageIds
              properties:
                targetPageIds:
                  type: array
                  items:
                    type: string
                    format: uuid
      responses:
        "200":
          description: The stored edge set
          content:
            application/json:
              schema:
                type: object
                required:
                  - targetPageIds
                properties:
                  targetPageIds:
                    type: array
                    items:
                      type: string
                      format: uuid
        "423":
          $ref: "#/components/responses/PageLocked"
  /v1/search:
    get:
      operationId: search
      tags:
        - search
      summary: Ranked full-text search
      description: |
        Postgres FTS over titles + doc text (websearch syntax) with an ILIKE
        title fallback. Snippets wrap match runs in **…** markers.
      parameters:
        - name: q
          in: query
          required: true
          schema:
            type: string
        - name: workspace_id
          in: query
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Ranked hits
          content:
            application/json:
              schema:
                type: object
                required:
                  - results
                properties:
                  results:
                    type: array
                    items:
                      $ref: "#/components/schemas/SearchHit"
  /v1/templates:
    get:
      operationId: listTemplates
      tags:
        - pages
      summary: List a workspace's templates
      parameters:
        - name: workspace_id
          in: query
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - templates
                properties:
                  templates:
                    type: array
                    items:
                      $ref: "#/components/schemas/Template"
    post:
      operationId: createTemplate
      tags:
        - pages
      summary: Create a template
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - workspaceId
                - name
              properties:
                workspaceId:
                  type: string
                  format: uuid
                name:
                  type: string
                icon:
                  type: string
                doc:
                  type: object
                docText:
                  type: string
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                type: object
                required:
                  - template
                properties:
                  template:
                    $ref: "#/components/schemas/Template"
  /v1/templates/{id}:
    delete:
      operationId: deleteTemplate
      tags:
        - pages
      summary: Delete a template
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          $ref: "#/components/responses/Message"
  /v1/favorites:
    get:
      operationId: listFavorites
      tags:
        - pages
      summary: The caller's favorite pages
      responses:
        "200":
          description: Favorites
          content:
            application/json:
              schema:
                type: object
                required:
                  - favorites
                properties:
                  favorites:
                    type: array
                    items:
                      $ref: "#/components/schemas/PageRef"
  /v1/pages/{id}/favorite:
    put:
      operationId: addFavorite
      tags:
        - pages
      summary: Favorite a page
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          $ref: "#/components/responses/Message"
    delete:
      operationId: removeFavorite
      tags:
        - pages
      summary: Unfavorite a page
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          $ref: "#/components/responses/Message"
  /v1/pages/{id}/comments:
    get:
      operationId: listComments
      tags:
        - collaboration
      summary: List a page's comments
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: Comments
          content:
            application/json:
              schema:
                type: object
                required:
                  - comments
                properties:
                  comments:
                    type: array
                    items:
                      $ref: "#/components/schemas/Comment"
    post:
      operationId: createComment
      tags:
        - collaboration
      summary: Comment on a page
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - body
              properties:
                body:
                  type: string
                  description: |
                    Plain text. To @mention someone, write
                    "@[Name](mention:<their user id>)": they are told (a
                    notes.mentioned notice) if they are a member of the
                    page's workspace who can read it. The author, people
                    outside the workspace, and anyone on a private page are
                    never told, and are left out of mentions.
                parentId:
                  type: string
                  nullable: true
                  description: A comment on the same page (makes this a reply)
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                type: object
                required:
                  - comment
                properties:
                  comment:
                    $ref: "#/components/schemas/Comment"
        "404":
          description: No such page, or parentId is not a comment on this page
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/comments:
    get:
      operationId: listCommentInbox
      tags:
        - collaboration
      summary: Comments across every page the caller can read
      description: |
        The comment inbox, for people and agents (an MCP/OAuth client or API
        key acting for a user). Covers every page the caller can read; trashed
        pages are left out. Each comment is its own row with its parentId, so
        a thread's replies keep their own authors. Poll with since set to the
        previous answer's next to get only what was created, edited or
        resolved after it, oldest first. The cursor is a keyset on
        (updated_at, id), so comments sharing a timestamp (a bulk resolve)
        are never dropped at a page boundary.
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum:
              - open
              - resolved
              - all
            default: open
        - name: pageId
          in: query
          description: Only this page (404 if the caller can't read it).
          schema:
            type: string
            format: uuid
        - name: under
          in: query
          description: A page and every page below it (404 if the caller can't read it). Not with pageId.
          schema:
            type: string
            format: uuid
        - name: since
          in: query
          description: |
            The previous answer's next, a cursor on (updated_at, id) written
            "<RFC 3339 time>_<id>". A bare RFC 3339 time also works.
          schema:
            type: string
        - name: mentions
          in: query
          description: me keeps only comments that @mention the caller (by the checked mentions, never the text).
          schema:
            type: string
            enum:
              - me
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
      responses:
        "200":
          description: Matching comments, oldest change first
          content:
            application/json:
              schema:
                type: object
                required:
                  - comments
                  - next
                properties:
                  comments:
                    type: array
                    items:
                      $ref: "#/components/schemas/InboxComment"
                  next:
                    type: string
                    description: Pass as since on the next poll (a cursor; don't parse it).
        "400":
          description: A malformed status, since, mentions or limit, or pageId with under
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: pageId is not a page the caller can read
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/comments/{id}:
    patch:
      operationId: updateComment
      tags:
        - collaboration
      summary: Edit (author-only) or resolve a comment
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                body:
                  type: string
                  description: |
                    The new text (author only; not empty). Its @mentions are
                    read again: people it adds are told, people it removes
                    are dropped from mentions and told nothing.
                resolved:
                  type: boolean
      responses:
        "200":
          description: Updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - comment
                properties:
                  comment:
                    $ref: "#/components/schemas/Comment"
    delete:
      operationId: deleteComment
      tags:
        - collaboration
      summary: Delete a comment (author-only)
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          $ref: "#/components/responses/Message"
  /v1/pages/{id}/shares:
    get:
      operationId: listShares
      tags:
        - sharing
      summary: List a page's active public links
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: Shares
          content:
            application/json:
              schema:
                type: object
                required:
                  - shares
                properties:
                  shares:
                    type: array
                    items:
                      $ref: "#/components/schemas/Share"
    post:
      operationId: createShare
      tags:
        - sharing
      summary: Create a public link (view or edit mode)
      description: |
        Internal pages (every space by default) can only be shared by the
        space owner or a workspace owner/admin, with confirmInternal=true;
        every link expires. The public read and save re-check revocation,
        expiry, trash and, for internal pages, the approval on every request,
        and answer 404 for a dead link.

        Anonymous edit links are turned off unless the deployment sets
        NOTES_ALLOW_EDIT_LINKS=true: mode=edit is refused with 403
        edit_links_disabled, and existing edit links serve as view links
        (the public read reports mode=view and the public save returns 403).
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                mode:
                  type: string
                  enum:
                    - view
                    - edit
                  default: view
                confirmInternal:
                  type: boolean
                  description: Required (true) to publish an internal page; recorded as the approval.
                expiresInDays:
                  type: integer
                  minimum: 1
                  maximum: 365
                  description: Link lifetime; defaults to the deployment TTL (30 days).
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                type: object
                required:
                  - share
                properties:
                  share:
                    $ref: "#/components/schemas/Share"
        "403":
          description: Edit links are turned off (code edit_links_disabled), or the page is internal and the caller is neither the space owner nor a workspace owner/admin (code internal_page)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: The page is internal and the request lacks confirmInternal (code confirm_internal)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/shares/{token}:
    delete:
      operationId: revokeShare
      tags:
        - sharing
      summary: Revoke a public link
      parameters:
        - name: token
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          $ref: "#/components/responses/Message"
  /v1/public/pages/{token}:
    get:
      operationId: publicPage
      tags:
        - sharing
      summary: Read a shared page (no auth)
      security: []
      parameters:
        - name: token
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: The shared page
          content:
            application/json:
              schema:
                type: object
                required:
                  - pageId
                  - mode
                  - title
                  - icon
                  - doc
                  - rev
                  - updated
                properties:
                  pageId:
                    type: string
                    format: uuid
                  mode:
                    type: string
                    enum:
                      - view
                      - edit
                  locked:
                    type: boolean
                    description: The page is locked, so even an edit link can't change it.
                  title:
                    type: string
                  icon:
                    type: string
                  doc:
                    type: object
                  rev:
                    type: integer
                    format: int64
                  updated:
                    type: string
                    format: date-time
  /v1/public/pages/{token}/views:
    post:
      operationId: recordPublicPageView
      tags:
        - sharing
      summary: Count a view of a shared page (no auth)
      description: |
        The shared page sends this after it has been on screen a few seconds, so
        a crawler, a link preview or a tab nobody looked at is not counted.
        Reading the page (`GET /v1/public/pages/{token}`) changes nothing.
        Opening again within 10 minutes is the same view, so a repeat is not an
        error: the answer is 204 either way. Nothing that identifies the reader
        is kept, only a one-way hash. The count shows as `publicViews` on the
        page's views (`GET /v1/pages/{id}/views`).
      security: []
      parameters:
        - name: token
          in: path
          required: true
          schema:
            type: string
      responses:
        "204":
          description: Counted, or already counted a moment ago
        "404":
          description: The link does not exist or no longer serves
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "429":
          description: More than 30 views from this address in the last minute (Retry-After says when to retry)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/public/pages/{token}/doc:
    put:
      operationId: publicPutDoc
      tags:
        - sharing
      summary: Save through an edit-mode share link (no auth)
      description: |
        Anonymous save path for edit-mode share links: same optimistic
        rev contract as the authenticated save (409 carries the current
        server doc). View-only links get 403. Wiki-link syncing is skipped
        and last_edited_by is left untouched.
      security: []
      parameters:
        - name: token
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - doc
                - rev
              properties:
                doc:
                  type: object
                docText:
                  type: string
                rev:
                  type: integer
                  format: int64
      responses:
        "200":
          description: Saved
          content:
            application/json:
              schema:
                type: object
                required:
                  - rev
                  - updated
                properties:
                  rev:
                    type: integer
                    format: int64
                  updated:
                    type: string
                    format: date-time
        "403":
          description: The link is view-only
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: Rev mismatch — body carries the current server state
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DocConflict"
        "423":
          $ref: "#/components/responses/PageLocked"
  /v1/pages/{id}/attachments:
    get:
      operationId: listAttachments
      tags:
        - sharing
      summary: List a page's attachments
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: Attachments
          content:
            application/json:
              schema:
                type: object
                required:
                  - attachments
                properties:
                  attachments:
                    type: array
                    items:
                      $ref: "#/components/schemas/Attachment"
    post:
      operationId: createAttachment
      tags:
        - sharing
      summary: Upload a file (multipart, "file" field, ≤15MB)
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
      responses:
        "200":
          description: Uploaded
          content:
            application/json:
              schema:
                type: object
                required:
                  - attachment
                properties:
                  attachment:
                    $ref: "#/components/schemas/Attachment"
        "423":
          $ref: "#/components/responses/PageLocked"
  /v1/attachments/{id}:
    get:
      operationId: getAttachment
      tags:
        - sharing
      summary: Stream an attachment (share link or bearer)
      description: |
        Streams the file for a caller holding a live share token for the
        attachment's page (share, used by share pages) or a bearer that can
        see the page. Anything else is 404, so a URL on its own (an id, or a
        retired exp+sig signed URL) opens nothing. Never redirects to a
        storage URL. Raster images (png, jpeg, gif, webp, avif) are served
        inline; anything else as application/octet-stream to download. Every
        response is Cache-Control private, no-store, Referrer-Policy
        no-referrer, X-Content-Type-Options nosniff. Streams are bounded: a
        deadline sized to the file, and a cap on concurrent downloads per
        caller and overall (429 past it).
      security: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: share
          in: query
          description: A live share token for the attachment's page (share pages).
          schema:
            type: string
      responses:
        "200":
          description: The file bytes
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        "404":
          description: No such attachment, or no live share link or bearer for its page
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "429":
          description: Too many downloads at once for this caller or overall (Retry-After says when to retry)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/attachments/{id}/content:
    get:
      operationId: getAttachmentContent
      tags:
        - sharing
      summary: Stream an attachment's bytes (members)
      description: |
        For an attachment on a page the caller can see, streams the file
        itself, with the same type and header rules as getAttachment. The
        editor shows images from it through blob: URLs, and exports bundle
        images from it.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: The file bytes
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        "404":
          description: No such attachment, or not on a page the caller can see
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "429":
          description: Too many downloads at once for this caller or overall (Retry-After says when to retry)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/link-preview:
    get:
      operationId: getLinkPreview
      tags:
        - collaboration
      summary: Preview a web page for a bookmark block
      description: |
        Fetches the page at `url` on the server and returns its title,
        description, image and site name (Open Graph and Twitter tags, then
        `<title>` and the description meta tag). The editor stores the result
        in the bookmark block, so nothing is kept here and pages never fetch
        the link again.

        The fetch is an SSRF boundary: http and https only, on the default
        ports, with no credentials in the URL; every address the host resolves
        to must be public (private, loopback, link-local, multicast, CGNAT,
        reserved, documentation, NAT64 and 6to4 ranges are refused) and the
        connection goes to the checked address, for every redirect hop too;
        at most 3 redirects, 6 seconds, 768 KB read. Only HTML is parsed; for
        any other type the preview holds the URL and the host as the site
        name. The image is returned only as a public https URL.

        Limited to 30 new links a minute per person (per instance); results
        are cached for 10 minutes.
      parameters:
        - name: url
          in: query
          required: true
          description: The http(s) link to preview, at most 2048 characters
          schema:
            type: string
            maxLength: 2048
      responses:
        "200":
          description: The preview
          content:
            application/json:
              schema:
                type: object
                required:
                  - preview
                properties:
                  preview:
                    $ref: "#/components/schemas/LinkPreview"
        "400":
          description: The link may not be fetched (not http(s), another port, credentials, or a private address)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "422":
          description: The page couldn't be reached or answered with an error; the editor still makes a bookmark named after the host
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "429":
          description: More than 30 new links in the last minute for this person (Retry-After says when to retry)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/pages/{id}/presence:
    post:
      operationId: heartbeat
      tags:
        - collaboration
      summary: Presence heartbeat
      description: Marks the caller as viewing the page; returns other live viewers and the current doc rev (used for soft-realtime refresh).
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: Viewers + current rev
          content:
            application/json:
              schema:
                type: object
                required:
                  - viewers
                  - rev
                  - updated
                properties:
                  viewers:
                    type: array
                    items:
                      $ref: "#/components/schemas/PresenceViewer"
                  rev:
                    type: integer
                    format: int64
                  updated:
                    type: string
                    format: date-time
  /v1/pages/{id}/review:
    put:
      operationId: setPageReview
      tags:
        - pages
      summary: Set who reviews a page and how often
      description: |
        Gives a page a reviewer and a review interval (EAS-739). When a review
        falls due the reviewer is notified, and once more a week after that if
        nothing has happened. `everyMonths` is 0 (never, the default), 1, 3, 6 or 12.
        `ownerId` is the reviewer, and empty means the page's creator. Changing the
        interval restarts the clock from now. Changing only the reviewer keeps
        the page's due date, so reassigning an overdue page does not make it look
        fresh, and the new reviewer is told at the next sweep. Either change
        forgets the reminders sent so far. This is not an edit of the page, so its
        `updated` time does not move.

        A page falls due when the latest of its creation, its last edit, the time
        the interval was set and the last confirmation, plus the interval, has
        passed. Only the page's creator, its reviewer or a workspace owner or
        admin may change this (403 otherwise). A reviewer must be a member of the
        workspace, on the team when the page is in a team's space, and a page in a
        private space can only be reviewed by its creator (400 otherwise). A page
        in the trash can't be reviewed (409). Each real change adds a
        `notes.page.review_changed` entry to the audit log.
      parameters:
        - $ref: "#/components/parameters/PageId"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SetPageReviewRequest"
      responses:
        "200":
          $ref: "#/components/responses/PageReviewState"
        "400":
          description: The interval is not one of 0, 1, 3, 6 or 12 (`bad_interval`), or the reviewer can't review this page (`bad_owner`, `owner_not_member`, `owner_not_on_team`, `private_page_owner`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "403":
          description: The caller may not change this page's review settings
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: Page not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: The page is in the trash (`page_trashed`)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/pages/{id}/review/confirm:
    post:
      operationId: confirmPageReview
      tags:
        - pages
      summary: Say a page is still correct
      description: |
        Restarts the page's review clock and forgets the reminders sent for the
        old cycle, without changing the page (EAS-739). The page then shows who
        confirmed it and when. Only the page's creator, its reviewer or a
        workspace owner or admin may do this (403 otherwise). Answers 409 when the
        page has no review interval (`review_not_set`) or is in the trash
        (`page_trashed`). Adds a `notes.page.reviewed` entry to the audit log.
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          $ref: "#/components/responses/PageReviewState"
        "403":
          description: The caller may not confirm this page
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "404":
          description: Page not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "409":
          description: The page has no review interval, or is in the trash
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/pages/{id}/views:
    post:
      operationId: recordPageView
      tags:
        - collaboration
      summary: Count the caller's view of a page
      description: |
        Counts one view of the page by the caller (EAS-738). The page sends this
        when it opens and does not wait for the answer. Opening the same page
        again within 10 minutes is the same view, so a repeat is not an error:
        the answer is 204 either way. A trashed page is not counted. The page
        sends this only after it has been on screen a few seconds. Views of a
        page through a public link are reported to
        `/v1/public/pages/{token}/views` instead.
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "204":
          description: Recorded, or already counted a moment ago
        "404":
          description: Page not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    get:
      operationId: getPageViews
      tags:
        - collaboration
      summary: How many times a page was viewed in the last 30 days
      description: |
        Total views and the number of different people, from signed-in viewers,
        plus views through public share links counted apart as `publicViews`.
        Counts only by default. The list of who viewed (`viewers`) is included
        only when the workspace owner or an admin has turned `showViewerNames`
        on in the Notes settings; it then shows to everyone who can open the
        page. `canManage` says whether the caller may change that setting.
      parameters:
        - $ref: "#/components/parameters/PageId"
      responses:
        "200":
          description: The counts
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PageViews"
        "404":
          description: Page not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /v1/settings:
    get:
      operationId: getNotesSettings
      tags:
        - system
      summary: The workspace's Notes settings
      description: Settings that apply to the whole workspace. Anyone signed in to the workspace can read them.
      responses:
        "200":
          description: The settings
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NotesSettings"
    put:
      operationId: updateNotesSettings
      tags:
        - system
      summary: Change the workspace's Notes settings
      description: |
        Only a workspace owner or admin may change these (403 otherwise). The
        workspace is the one in the caller's sign-in, never a request field. Each
        change adds a `notes.settings.updated` entry to the audit log. Names are
        kept with every view even while this is off, so turning it on also shows
        earlier views from the last 30 days.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - showViewerNames
              properties:
                showViewerNames:
                  type: boolean
                  description: Show who viewed a page, not only how many.
      responses:
        "200":
          description: The settings after the change
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NotesSettings"
        "400":
          description: showViewerNames is missing
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        "403":
          description: The caller is not an owner or admin of the workspace
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /internal/pages/{id}/sync:
    get:
      operationId: internalGetSyncState
      tags:
        - system
      summary: "Internal: read CRDT state (notes-sync only)"
      description: |
        Service-to-service surface for the notes-sync realtime server, gated
        by the X-Internal-Key shared secret (501 when unconfigured). Returns
        the stored Yjs binary state (base64, empty when none) plus the current
        JSON projection and rev so a fresh Y.Doc can be seeded. With
        rev_only=1 only the rev is returned (notes-sync polls open documents
        for writes made outside collab).
      security: []
      parameters:
        - $ref: "#/components/parameters/PageId"
        - $ref: "#/components/parameters/InternalKey"
        - name: rev_only
          in: query
          description: Pass "1" to return only the rev.
          schema:
            type: string
      responses:
        "200":
          description: CRDT state + projection (only rev when rev_only=1)
          content:
            application/json:
              schema:
                type: object
                required:
                  - rev
                properties:
                  ydoc:
                    type: string
                    description: |
                      Base64 Yjs state that belongs to the current doc (by content
                      hash); empty when none is stored or an outside write has
                      overtaken it.
                  staleYdoc:
                    type: string
                    description: |
                      Base64 Yjs state an outside write has overtaken (set only when
                      ydoc is empty). notes-sync loads it and brings it to doc with
                      ordinary edits, so a browser that kept that history merges
                      into it instead of getting a second copy.
                  staleYdocHash:
                    type: string
                    description: SHA-256 (hex) of staleYdoc's bytes; pass it as expect when storing the refreshed state.
                  seedPersist:
                    type: boolean
                    description: |
                      This build understands a seed store (PUT with seed). notes-sync
                      persists loaded state only when this is true.
                  doc:
                    type: object
                  rev:
                    type: integer
                    format: int64
    put:
      operationId: internalPutSyncState
      tags:
        - system
      summary: "Internal: persist CRDT state (notes-sync only)"
      description: |
        Stores the Yjs binary and projects the JSON doc through the standard
        save path (rev bump, snapshot throttling, wiki-link edges, search
        text). The sync server is authoritative during co-editing, except
        over writes made outside it: when baseRev is sent and the page's rev
        has moved past it (a REST save, version restore or copilot write
        while the page was open), the store is refused with 409 and the
        current doc, so notes-sync applies that write to the live document
        instead of overwriting it. Without baseRev the store is
        unconditional. A locked page refuses a store with 423 (a seed, which
        stores state only, is still taken).
      security: []
      parameters:
        - $ref: "#/components/parameters/PageId"
        - $ref: "#/components/parameters/InternalKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - ydoc
              properties:
                ydoc:
                  type: string
                  description: Base64 Yjs state.
                doc:
                  type: object
                  description: Required for a normal store; never sent with seed.
                docText:
                  type: string
                links:
                  type: array
                  items:
                    type: string
                    format: uuid
                editedBy:
                  type: string
                  format: uuid
                baseRev:
                  type: integer
                  format: int64
                  description: The rev notes-sync last loaded or stored for this page.
                seed:
                  type: boolean
                  description: |
                    Store only the Yjs state the page was loaded with: no rev bump,
                    no version, no projection (doc is ignored). Requires baseRev
                    equal to the page's rev. With expect empty it only inserts;
                    otherwise it replaces the stored state only while that state
                    hashes to expect. A load that loses either race gets 409 with
                    the stored state as winner.
                expect:
                  type: string
                  description: With seed, the SHA-256 (hex) of the stored state being replaced; empty means "only if nothing is stored".
      responses:
        "200":
          description: Saved
          content:
            application/json:
              schema:
                type: object
                required:
                  - rev
                  - updated
                properties:
                  rev:
                    type: integer
                    format: int64
                  updated:
                    type: string
                    format: date-time
        "409":
          description: |
            The page changed outside collab since baseRev; body carries the current
            rev and doc. With seed: the page moved past baseRev (rev only), or
            another load stored its state first (winner is that state).
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                  - rev
                properties:
                  error:
                    type: string
                  rev:
                    type: integer
                    format: int64
                  doc:
                    type: object
                  winner:
                    type: string
                    description: With seed, the base64 Yjs state another load stored first; continue from it.
        "423":
          $ref: "#/components/responses/PageLocked"
  /internal/sync/revocations:
    get:
      operationId: internalSyncRevocations
      tags:
        - system
      summary: "Internal: share links revoked and pages trashed since a time (notes-sync only)"
      description: |
        Revocation feed for the notes-sync realtime server, gated by the
        X-Internal-Key shared secret (501 when unconfigured). notes-sync polls
        it every few seconds and closes the matching share-link connections
        at once, instead of at its per-connection re-check. Share
        links are reported as SHA-256 hashes (hex) of their tokens, never the
        tokens. since is a cursor: pass the previous answer's next. Rows come
        oldest first, at most 1000 of each kind; a full answer's next trails
        the clock by 30 s (so late commits are seen again), a capped answer's
        next is the last row's time (so a burst is read over several polls).
        The feed never looks back more than 10 minutes.

        epochBumps lists identity-epoch rows changed since the cursor (auth
        bumps one on every access change: removal, role, teams, tools, API
        keys, OAuth grants), with the new version. notes-sync asks each live
        connection whose token was minted for that subject and workspace with
        a lower version to re-authenticate (close 4401). At most 5000: past
        that, epochBumps is empty and epochBumpsTruncated is true, and
        notes-sync re-checks every member connection instead. Older notes-sync
        builds ignore both fields.
      security: []
      parameters:
        - $ref: "#/components/parameters/InternalKey"
        - name: since
          in: query
          description: The previous answer's next (RFC 3339). Omitted means 30 s ago.
          schema:
            type: string
            format: date-time
      responses:
        "200":
          description: What changed since the given time
          content:
            application/json:
              schema:
                type: object
                required:
                  - next
                  - revokedShareHashes
                  - trashedPageIds
                  - epochBumps
                  - epochBumpsTruncated
                properties:
                  next:
                    type: string
                    format: date-time
                    description: The cursor to pass as since on the next poll.
                  revokedShareHashes:
                    type: array
                    items:
                      type: string
                      description: SHA-256 of the share token, lowercase hex.
                  trashedPageIds:
                    type: array
                    items:
                      type: string
                      format: uuid
                  lockChanges:
                    type: array
                    description: |
                      Pages locked or unlocked since the cursor, with the time
                      of that change. notes-sync re-checks a page's live
                      connections when its time is newer than the last one it
                      acted on, so the feed's overlap doesn't repeat it.
                    items:
                      type: object
                      required:
                        - pageId
                        - at
                      properties:
                        pageId:
                          type: string
                          format: uuid
                        at:
                          type: string
                          format: date-time
                  epochBumps:
                    type: array
                    items:
                      type: object
                      required:
                        - subject
                        - workspace
                        - version
                      properties:
                        subject:
                          type: string
                          description: The token's sub (a user id, or an API key id).
                        workspace:
                          type: string
                        version:
                          type: integer
                          format: int64
                          description: The new epoch. Tokens minted with a lower one are stale.
                  epochBumpsTruncated:
                    type: boolean
                    description: More bumps than one answer holds; re-check every member connection.
        "400":
          description: since is not an RFC 3339 time
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
  parameters:
    PageId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
    InternalKey:
      name: X-Internal-Key
      in: header
      required: true
      description: Shared service secret (INTERNAL_API_KEY).
      schema:
        type: string
    BlockId:
      name: id
      in: path
      required: true
      schema:
        type: string
        format: uuid
  responses:
    PageReviewState:
      description: The page's review state after the change
      content:
        application/json:
          schema:
            type: object
            required:
              - review
            properties:
              review:
                $ref: "#/components/schemas/PageReview"
    PageLocked:
      description: The page is locked (EAS-730), so its content, title and icon can't change until someone unlocks it. `code` is `page_locked`.
      content:
        application/json:
          schema:
            type: object
            required:
              - error
              - code
            properties:
              error:
                type: string
              code:
                type: string
                description: Always page_locked.
    PageLockState:
      description: The page after the change, with its lock state.
      content:
        application/json:
          schema:
            type: object
            required:
              - page
            properties:
              page:
                $ref: "#/components/schemas/Page"
    Message:
      description: Confirmation
      content:
        application/json:
          schema:
            type: object
            required:
              - message
            properties:
              message:
                type: string
    Blocks:
      description: The page's blocks in order
      content:
        application/json:
          schema:
            type: object
            required:
              - blocks
            properties:
              blocks:
                type: array
                items:
                  $ref: "#/components/schemas/Block"
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
    DailyPageResult:
      type: object
      required:
        - page
        - created
        - restored
      properties:
        page:
          $ref: "#/components/schemas/Page"
        created:
          type: boolean
          description: True when this call created the page.
        restored:
          type: boolean
          description: True when the page was in the trash and this call brought it back.
    DailyPageItem:
      type: object
      required:
        - id
        - workspaceId
        - title
        - icon
        - dailyDate
        - updated
      properties:
        id:
          type: string
          format: uuid
        workspaceId:
          type: string
          format: uuid
        title:
          type: string
        icon:
          type: string
        dailyDate:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
        updated:
          type: string
          format: date-time
    DailyPageError:
      type: object
      required:
        - error
        - code
      properties:
        error:
          type: string
        code:
          type: string
          enum:
            - bad_daily_date
            - daily_date_out_of_range
            - daily_page_fixed
            - daily_no_children
            - inbox_page_fixed
    CaptureResult:
      type: object
      required:
        - page
        - created
        - restored
        - rev
        - added
      properties:
        page:
          $ref: "#/components/schemas/Page"
        created:
          type: boolean
          description: True when this call made the page.
        restored:
          type: boolean
          description: True when the page was in the trash and this call brought it back.
        rev:
          type: integer
          format: int64
          description: The page's document revision after the note was added.
        added:
          type: integer
          description: How many paragraphs the note added.
    CaptureError:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        code:
          type: string
          enum:
            - empty_capture
            - capture_too_long
            - bad_capture_destination
            - bad_capture_source
            - bad_daily_date
            - daily_date_out_of_range
    Member:
      type: object
      required:
        - id
        - userId
        - name
        - email
        - created
      properties:
        id:
          type: string
          format: uuid
        userId:
          type: string
          format: uuid
        name:
          type: string
        email:
          type: string
        created:
          type: string
          format: date-time
    Workspace:
      type: object
      required:
        - id
        - name
        - ownerId
        - kind
        - created
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        ownerId:
          type: string
          format: uuid
        kind:
          type: string
          enum:
            - org
            - team
            - personal
        teamId:
          type: string
          format: uuid
          nullable: true
        created:
          type: string
          format: date-time
        internal:
          type: boolean
          nullable: true
          description: Explicit internal flag; null means the deployment default (internal unless NOTES_INTERNAL_DEFAULT=false).
    Page:
      type: object
      required:
        - id
        - workspaceId
        - title
        - icon
        - position
        - createdBy
        - created
        - updated
      properties:
        id:
          type: string
          format: uuid
        workspaceId:
          type: string
          format: uuid
        parentId:
          type: string
          format: uuid
          nullable: true
        title:
          type: string
        icon:
          type: string
        position:
          type: number
        createdBy:
          type: string
          format: uuid
        created:
          type: string
          format: date-time
        updated:
          type: string
          format: date-time
        archivedAt:
          type: string
          format: date-time
          nullable: true
        dailyDate:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          nullable: true
          description: Set on a person's daily page (EAS-734), the date it is for in their own time zone. null on every other page.
        inbox:
          type: boolean
          description: True on a person's Inbox (EAS-735), where quick notes land. It stays in their private space.
        locked:
          type: boolean
          description: The page is locked (EAS-730); its content, title and icon can't change.
        lockedAt:
          type: string
          format: date-time
          nullable: true
          description: When it was locked. getPage and the lock routes only.
        lockedBy:
          type: string
          format: uuid
          nullable: true
          description: Who locked it. getPage and the lock routes only.
        lockedByName:
          type: string
          description: That person's name in the caller's workspace, empty if unknown. getPage and the lock routes only.
        canLock:
          type: boolean
          description: Whether the caller may lock or unlock it (its creator, or a workspace owner/admin). getPage and the lock routes only.
        review:
          $ref: "#/components/schemas/PageReview"
        source:
          type: string
          nullable: true
          description: Set when a tool publishes this page from an outside source.
        sourceRef:
          type: string
          nullable: true
          description: The page's stable id in its source (unique per space and source).
        publishedRev:
          type: integer
          format: int64
          nullable: true
          description: Doc rev written by the last publish. docRev above it means the page was edited in Notes since.
        publishedAt:
          type: string
          format: date-time
          nullable: true
        docRev:
          type: integer
          format: int64
        excerpt:
          type: string
          description: What the page says, for list rows. Its paragraphs, list items, quotes and toggle titles in order, joined with a middle dot, with empty field labels such as "Attendees:" left out; headings and table cells only when there is no other text near the start of the page. A page with no text of these kinds uses its plain text. About 140 characters, ending in an ellipsis when cut. A page with no document yet uses its plain text.
        published:
          type: boolean
          description: The page has a live public link (the dashboard's PUBLISHED badge; otherwise DRAFT). Returned by listPages and getPage.
        openComments:
          type: integer
          description: How many open (unresolved) comments the page has, for the page tree. Returned by listPages.
        internalOverride:
          type: boolean
          nullable: true
          description: The page's own internal flag; null inherits the space.
        internal:
          type: boolean
          description: Effective internal flag (page, else space, else default). Returned by getPage only.
    SourceRefTaken:
      type: object
      required:
        - error
        - code
        - page
      properties:
        error:
          type: string
        code:
          type: string
          enum:
            - source_ref_taken
        page:
          $ref: "#/components/schemas/Page"
    WideningMoveRefused:
      type: object
      required:
        - error
        - code
      properties:
        error:
          type: string
        code:
          type: string
          enum:
            - widening_move
            - move_refused
    ConfirmWiden:
      type: object
      required:
        - error
        - code
        - space
      properties:
        error:
          type: string
        code:
          type: string
          enum:
            - confirm_widen
        space:
          $ref: "#/components/schemas/Workspace"
    PublishConflict:
      type: object
      required:
        - error
        - code
        - rev
      properties:
        error:
          type: string
        code:
          type: string
          enum:
            - edited_since_publish
        rev:
          type: integer
          format: int64
        publishedRev:
          type: integer
          format: int64
          nullable: true
        lastEditedBy:
          type: string
          nullable: true
    PageRef:
      type: object
      required:
        - id
        - title
        - icon
        - workspaceId
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        icon:
          type: string
        workspaceId:
          type: string
          format: uuid
    Block:
      type: object
      required:
        - id
        - pageId
        - type
        - content
        - properties
        - position
        - created
        - updated
      properties:
        id:
          type: string
          format: uuid
        pageId:
          type: string
          format: uuid
        parentId:
          type: string
          format: uuid
          nullable: true
        type:
          type: string
        content:
          type: string
        properties:
          type: object
        position:
          type: number
        created:
          type: string
          format: date-time
        updated:
          type: string
          format: date-time
    DocPayload:
      type: object
      required:
        - doc
        - rev
        - updated
      properties:
        doc:
          type: object
          description: Tiptap/ProseMirror document JSON.
        rev:
          type: integer
          format: int64
        updated:
          type: string
          format: date-time
        lastEditedBy:
          type: string
          format: uuid
          nullable: true
        locked:
          type: boolean
          description: The page is locked (EAS-730); notes-sync makes live connections read-only while it is.
    DocConflict:
      type: object
      required:
        - error
        - rev
        - doc
      properties:
        error:
          type: string
        rev:
          type: integer
          format: int64
        doc:
          type: object
        lastEditedBy:
          type: string
          format: uuid
          nullable: true
    VersionMeta:
      type: object
      required:
        - id
        - title
        - created
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        savedBy:
          type: string
          format: uuid
          nullable: true
        created:
          type: string
          format: date-time
        event:
          type: string
          nullable: true
          enum:
            - locked
            - unlocked
          description: |
            Set when the entry records a lock or unlock (by savedBy) rather
            than an edit. Such an entry holds no document: getVersion and
            restoreVersion answer 404 for it. listVersions returns up to 100
            snapshots, and separately up to 100 of these events within the
            same span.
    VersionDetail:
      allOf:
        - $ref: "#/components/schemas/VersionMeta"
        - type: object
          required:
            - doc
          properties:
            doc:
              type: object
    Template:
      type: object
      required:
        - id
        - workspaceId
        - name
        - icon
        - doc
        - created
      properties:
        id:
          type: string
          format: uuid
        workspaceId:
          type: string
          format: uuid
        name:
          type: string
        icon:
          type: string
        doc:
          type: object
        createdBy:
          type: string
          format: uuid
          nullable: true
        created:
          type: string
          format: date-time
    Comment:
      type: object
      required:
        - id
        - pageId
        - authorId
        - body
        - created
        - updated
      properties:
        id:
          type: string
          format: uuid
        pageId:
          type: string
          format: uuid
        parentId:
          type: string
          format: uuid
          nullable: true
        authorId:
          type: string
          format: uuid
        authorKind:
          type: string
          enum:
            - user
            - agent
          description: |
            agent when the comment was written through a delegated credential
            (an MCP/OAuth client or an API key acting for authorId), else user.
            Treat unknown values as user; more kinds may be added.
        body:
          type: string
          description: |
            Plain text. A mention is written in it as
            "@[Name](mention:<user id>)"; show it as "@Name". Only the ids in
            mentions were checked, so draw a token whose id isn't there as
            plain text.
        mentions:
          type: array
          items:
            type: string
            format: uuid
          description: |
            The people this comment @mentions who were checked as members
            able to read the page: who was told, and who "mentions=me"
            matches. Always present (empty when none).
        resolvedAt:
          type: string
          format: date-time
          nullable: true
        created:
          type: string
          format: date-time
        updated:
          type: string
          format: date-time
    InboxComment:
      allOf:
        - $ref: "#/components/schemas/Comment"
        - type: object
          required:
            - page
          properties:
            page:
              type: object
              required:
                - id
                - title
              properties:
                id:
                  type: string
                  format: uuid
                title:
                  type: string
    Share:
      type: object
      required:
        - token
        - mode
        - created
      properties:
        token:
          type: string
        mode:
          type: string
          enum:
            - view
            - edit
        created:
          type: string
          format: date-time
        expiresAt:
          type: string
          format: date-time
          nullable: true
        approved:
          type: boolean
          description: An owner/admin explicitly approved publishing this (internal) page.
    LinkPreview:
      type: object
      required:
        - url
        - title
        - description
        - image
        - siteName
      properties:
        url:
          type: string
          description: The page's address after redirects
        title:
          type: string
          description: Plain text, at most 300 characters; empty when the page has none
        description:
          type: string
          description: Plain text, at most 500 characters
        image:
          type: string
          description: A public https image URL, or empty
        siteName:
          type: string
          description: The site's name, or its host when the page doesn't say
    Attachment:
      type: object
      required:
        - id
        - filename
        - contentType
        - size
        - url
        - created
      properties:
        id:
          type: string
          format: uuid
        pageId:
          type: string
          format: uuid
          nullable: true
        filename:
          type: string
        contentType:
          type: string
        size:
          type: integer
          format: int64
        url:
          type: string
        created:
          type: string
          format: date-time
    PresenceViewer:
      type: object
      required:
        - userId
        - name
        - seen
      properties:
        userId:
          type: string
          format: uuid
        name:
          type: string
        seen:
          type: string
          format: date-time
    PageReview:
      type: object
      description: A page's review settings and state (EAS-739). On getPage and the two review routes only.
      required:
        - everyMonths
        - ownerId
        - ownerIsCreator
        - overdue
        - canManage
      properties:
        everyMonths:
          type: integer
          enum:
            - 0
            - 1
            - 3
            - 6
            - 12
          description: How often the page is reviewed, in months. 0 means never.
        ownerId:
          type: string
          format: uuid
          description: Who reviews the page. Its creator unless someone else was chosen.
        ownerName:
          type: string
          description: That person's name in the caller's workspace, empty if unknown.
        ownerIsCreator:
          type: boolean
        lastReviewedAt:
          type: string
          format: date-time
          nullable: true
          description: When someone last confirmed the page is still correct. null if no one has.
        lastReviewedBy:
          type: string
          format: uuid
          nullable: true
        lastReviewedByName:
          type: string
        dueAt:
          type: string
          format: date-time
          nullable: true
          description: When the page falls due. null when everyMonths is 0.
        overdue:
          type: boolean
          description: The page's due date has passed.
        canManage:
          type: boolean
          description: Whether the caller may change the settings and confirm the page (its creator, its reviewer, or a workspace owner/admin).
    SetPageReviewRequest:
      type: object
      required:
        - everyMonths
      properties:
        everyMonths:
          type: integer
          enum:
            - 0
            - 1
            - 3
            - 6
            - 12
        ownerId:
          type: string
          description: Who reviews the page. Empty means its creator.
    PageViews:
      type: object
      required:
        - days
        - views
        - people
        - publicViews
        - showNames
        - canManage
      properties:
        days:
          type: integer
          description: How many days back the counts cover (30).
        views:
          type: integer
          format: int64
          description: Views by signed-in people. Opening again within 10 minutes counts once.
        people:
          type: integer
          format: int64
          description: How many different signed-in people viewed the page.
        publicViews:
          type: integer
          format: int64
          description: Views through public share links, counted apart.
        showNames:
          type: boolean
          description: Whether the workspace shows who viewed.
        canManage:
          type: boolean
          description: Whether the caller may change that setting.
        viewers:
          type: array
          description: Present only when showNames is true. Most recent first.
          items:
            $ref: "#/components/schemas/PageViewer"
    PageViewer:
      type: object
      required:
        - userId
        - name
        - views
        - last
      properties:
        userId:
          type: string
          format: uuid
        name:
          type: string
        views:
          type: integer
        last:
          type: string
          format: date-time
    NotesSettings:
      type: object
      required:
        - showViewerNames
        - canManage
      properties:
        showViewerNames:
          type: boolean
        canManage:
          type: boolean
          description: Whether the caller may change the settings.
    SearchHit:
      type: object
      required:
        - id
        - title
        - icon
        - workspaceId
        - snippet
        - updated
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        icon:
          type: string
        workspaceId:
          type: string
          format: uuid
        snippet:
          type: string
          description: Match runs are wrapped in **…** markers (ts_headline).
        updated:
          type: string
          format: date-time
