# Docs

> Docs module (M9, product.md 7.18; Notion parity for everyday use): 67 endpoints of the Teemli API.

Source: https://docs.teemli.com/developers/reference/docs/

Generated from [`api/openapi.yaml`](/developers/api/) (OpenAPI 3.1). Base URL: `https://api.teemli.com`. Auth: `Authorization: Bearer <token or tml_ API key>`. Errors are `application/problem+json`; writes accept an `Idempotency-Key` header.

Docs module (M9, product.md 7.18; Notion parity for everyday use). Every `/docs/*` route returns 404 while the
organisation's `docs` switch is off (`PUT /admin/settings {switches: {docs: true}}`; data is kept).
Pages live in teamspaces (org / team / restricted) or a person's private space. Roles view < comment < edit < full
(full = share, restrict, delete for good). A page's access = the best grant on it and its ancestors up to the first
page that stops inheriting (`inherit: false`, "restricted"), plus the teamspace's role when inheritance reaches the
top. Grants name a person (guests included), a team, an AI employee or the whole organisation (never guests).
Org admins get full access to org/team teamspaces, never to private spaces, restricted teamspaces or restricted
pages they aren't in, and never inside agent turns. AI employees see only what they were invited to; a person's own
agent sees what its person can. All enforced by RLS (`teemli_doc_page_role`). Page content is a Yjs document
(TipTap/ProseMirror schema in the XML fragment `default`) synced over `/v1/docs/sync`; every stored update needs
edit access (RLS on `doc_updates`). Agents' edits are suggestions (`/suggestions`) unless an AI employee edits a
page that allows it (`ai_edit_direct`).

## Live co-editing WebSocket (y-protocols). First TEXT message `{type: auth, access_token, org_id, page_id}` (resend `{type: auth, access_token}` to refresh). Server: TEXT `{type: ready, role, user: {id, name, color}}`, `{type: role, role}` when access changes, `{type: read_only}` when an update was refused; then BINARY sync (0: step1/step2/update) and awareness (1) messages. Access is checked on connect, every 15 s and on every update (stored as the sender under RLS before it is relayed). Presence names are set by the server. Closes 4401 (auth), 4403 (access revoked), 4404 (no access / module off)

```http
GET /v1/docs/sync
```

**API keys:** not available (needs a person signed in to the app).

**Responses**

- `101` Switching protocols

## The sidebar: your private space (created on first use), teamspaces you can open (with your role), favourites, recently visited, pages shared with you from spaces you can't open

```http
GET /v1/orgs/{org}/docs/home
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Responses**

- `200` {private_space_id, spaces: [DocSpace], favorites: [PageSummary], recent: [PageSummary + visited_at], shared: [PageSummary], can_create_spaces}
- `404` Not found (also returned for rows the caller may not see, and for disabled features) — Problem

## Create a teamspace (people, not guests or agents); you get full access

```http
POST /v1/orgs/{org}/docs/spaces
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` (required) | string |  |
| `icon` | string |  |
| `description` | string |  |
| `visibility` | `org`, `team`, `restricted` |  |
| `team_id` | string (uuid) |  |
| `default_role` | `view`, `comment`, `edit`, `full` |  |

**Responses**

- `201` DocSpace {id, kind, name, icon, description, visibility, team_id, default_role, position, role}
- `422` Invalid input — Problem

## Change a teamspace (full access): name, icon, description, visibility, team_id, default_role, position, archived

```http
PATCH /v1/orgs/{org}/docs/spaces/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocSpace
- `403` Authenticated but not allowed (e.g. unverified email, not the agent's controller, card routed to someone else) — Problem

## Archive a teamspace (full access)

```http
DELETE /v1/orgs/{org}/docs/spaces/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {archived: true}

## The whole page tree of a space, flat (not database rows, templates or trashed pages), with your role per page

```http
GET /v1/orgs/{org}/docs/spaces/{id}/pages
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {items: [PageSummary + role]}

## A teamspace and its explicit grants

```http
GET /v1/orgs/{org}/docs/spaces/{id}/sharing
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {space, grants: [{id, principal, role}]}

## Grant a person, team, AI employee or everyone access to a teamspace (full access)

```http
POST /v1/orgs/{org}/docs/spaces/{id}/grants
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `person_id` | string (uuid) |  |
| `team_id` | string (uuid) |  |
| `agent_id` | string (uuid) | An AI employee |
| `whole_org` | boolean |  |
| `email` | string | Someone outside the organisation becomes a guest (pages only) |
| `role` | `view`, `comment`, `edit`, `full` |  |

**Responses**

- `201` {id}

## Create a page, database (kind database: seeded with Name/Status/Assignee/Due/Tags and a Table view) or database row (in_database + parent_id = the database, props). Start from Markdown, a built-in template key or any page you can read (template_id). No space or parent = your private space. Needs edit access at the place

```http
POST /v1/orgs/{org}/docs/pages
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `space_id` | string (uuid) |  |
| `parent_id` | string (uuid) |  |
| `title` | string |  |
| `icon` | string |  |
| `cover` | string |  |
| `kind` | `page`, `database` |  |
| `in_database` | boolean |  |
| `props` | object |  |
| `is_template` | boolean |  |
| `template` | string |  |
| `template_id` | string (uuid) |  |
| `markdown` | string |  |
| `after_id` | string (uuid) |  |

**Responses**

- `201` DocPage
- `403` Authenticated but not allowed (e.g. unverified email, not the agent's controller, card routed to someone else) — Problem
- `422` Invalid input — Problem

## A page (records a visit): summary + inherit, ai_edit_direct, full_width, props, db_schema (own, or the database's for a row), database, breadcrumbs, space, role, favorite, created_by, edited_by, edited_via, counts {comments_open, suggestions_open, backlinks}, linked_tasks

```http
GET /v1/orgs/{org}/docs/pages/{id}
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocPage
- `404` Not found (also returned for rows the caller may not see, and for disabled features) — Problem

## Edit page metadata (edit access): title, icon (null clears), cover, full_width, props (rows; merged, null removes; validated against the schema), is_template; ai_edit_direct needs full access

```http
PATCH /v1/orgs/{org}/docs/pages/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocPage

## Delete for good (only from the trash; full access)

```http
DELETE /v1/orgs/{org}/docs/pages/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {deleted: true}
- `409` Conflicting state (card already answered, duplicate in flight, name taken) — Problem

## Sub-pages (not rows)

```http
GET /v1/orgs/{org}/docs/pages/{id}/children
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {items: [PageSummary]}

## Move / reorder (edit access here and at the destination; no cycles): {space_id?, parent_id? (null = top level), before_id? | after_id?}

```http
POST /v1/orgs/{org}/docs/pages/{id}/move
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocPage
- `403` Authenticated but not allowed (e.g. unverified email, not the agent's controller, card routed to someone else) — Problem

## Duplicate with content, sub-pages (and a database's views and rows)

```http
POST /v1/orgs/{org}/docs/pages/{id}/duplicate
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `201` DocPage

## Move a page and its sub-pages to the trash (edit access)

```http
POST /v1/orgs/{org}/docs/pages/{id}/trash
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {trashed: true}

## Restore from the trash (with what was trashed with it; to the top of its space if its parent is still in the trash)

```http
POST /v1/orgs/{org}/docs/pages/{id}/restore
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocPage

## Favourite / unfavourite {favorite}

```http
PUT /v1/orgs/{org}/docs/pages/{id}/favorite
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {favorite}

## Pages (you can see) that link to or mention this one

```http
GET /v1/orgs/{org}/docs/pages/{id}/backlinks
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {items: [PageSummary]}

## Who has access: your role, inherit, ai_edit_direct, the space, space_applies, grants on the page and inherited ones (inherited_from {id, title, kind: page|space})

```http
GET /v1/orgs/{org}/docs/pages/{id}/sharing
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {role, inherit, ai_edit_direct, space, space_applies, grants: [{id, principal: {kind: person\|team\|agent\|org, id, name, email?, is_guest?}, role, inherited_from}]}

## Share (full access): a person, team, AI employee (only AI employees: your own agents already read what you can), everyone (not guests), or an email (a guest when the guests switch is on). Notifies the person

```http
POST /v1/orgs/{org}/docs/pages/{id}/grants
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `person_id` | string (uuid) |  |
| `team_id` | string (uuid) |  |
| `agent_id` | string (uuid) | An AI employee |
| `whole_org` | boolean |  |
| `email` | string | Someone outside the organisation becomes a guest (pages only) |
| `role` | `view`, `comment`, `edit`, `full` |  |

**Responses**

- `201` Sharing
- `403` Authenticated but not allowed (e.g. unverified email, not the agent's controller, card routed to someone else) — Problem

## Restrict (inherit false: keeps people granted on parent pages, drops the teamspace's members, gives you full access) or inherit again (full access)

```http
PUT /v1/orgs/{org}/docs/pages/{id}/inherit
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `inherit` (required) | boolean |  |

**Responses**

- `200` Sharing

## The page as Markdown and its top-level blocks with ids (agents, mobile)

```http
GET /v1/orgs/{org}/docs/pages/{id}/content
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {markdown, blocks: [{id, type, markdown}]}

## Block edits applied on the server (edit access), relayed to live editors: replace | insert_after | insert_before | delete (block_id) | append, with Markdown

```http
POST /v1/orgs/{org}/docs/pages/{id}/content
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `ops` (required) | array of DocBlockOp |  |

**Responses**

- `200` {markdown, blocks}
- `403` Authenticated but not allowed (e.g. unverified email, not the agent's controller, card routed to someone else) — Problem
- `422` Invalid input — Problem

## Export as Markdown (a database exports its rows as a table)

```http
GET /v1/orgs/{org}/docs/pages/{id}/export.md
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` text/markdown attachment

## Export as PDF, laid out on the server (G2; same access as reading the page; a database as a table). Images and files are named, not embedded; characters the bundled Latin fonts can't draw are left out (the web print view remains for those)

```http
GET /v1/orgs/{org}/docs/pages/{id}/export.pdf
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` application/pdf attachment
- `404` Not found (also returned for rows the caller may not see, and for disabled features) — Problem

## Page history: snapshots (auto every few minutes of editing and when editors leave, manual, restore, import, agent edits)

```http
GET /v1/orgs/{org}/docs/pages/{id}/versions
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {items: [{id, kind: auto\|manual\|restore\|import\|agent\|create, label, created_at, authors: [Actor], created_by, size}]}

## Save a version now (edit access) {label?}

```http
POST /v1/orgs/{org}/docs/pages/{id}/versions
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `201` {id}

## Comments, flat (thread by parent_id)

```http
GET /v1/orgs/{org}/docs/pages/{id}/comments
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |
| `resolved` | query | `open`, `resolved`, `all` |  |

**Responses**

- `200` {items: [{id, page_id, parent_id, block_id, anchor, quote, body, author, via, resolved_at, resolved_by, edited_at, created_at}]}

## Comment (comment access): page-level, on a block (block_id), inline (anchor {start, end}: base64 Yjs relative positions, quote) or a reply (parent_id; reopens a resolved thread). Mentions `@[Name](person|agent:ID)` notify people who can see the page; an @mentioned AI employee with access answers in the thread

```http
POST /v1/orgs/{org}/docs/pages/{id}/comments
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |
| `resolved` | query | `open`, `resolved`, `all` |  |

**Responses**

- `201` DocComment

## Agents' suggested edits

```http
GET /v1/orgs/{org}/docs/pages/{id}/suggestions
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |
| `status` | query | `open`, `all` |  |

**Responses**

- `200` {items: [{id, agent, person, label ("Maya via Scout (AI)" \| "Riya (AI)"), summary, ops: [DocBlockOp + before], status: open\|accepted\|rejected\|stale, created_at, decided_by, decided_at}]}

## Upload an image or file to a page (edit access; raw body ≤ 25 MB; stored under the organisation's prefix)

```http
POST /v1/orgs/{org}/docs/pages/{id}/files
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |
| `name` | query | string |  |
| `mime` | query | string |  |

**Request body:** `application/octet-stream`.

**Responses**

- `201` {id, name, size, mime, url}

## Work items linked to the page

```http
GET /v1/orgs/{org}/docs/pages/{id}/tasks
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {items: [{id, title, completed}]}

## Link a work item {item_id} (you can see both and edit one)

```http
POST /v1/orgs/{org}/docs/pages/{id}/tasks
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `201` {linked: true}

## Unlink a work item

```http
DELETE /v1/orgs/{org}/docs/pages/{id}/tasks/{item}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |
| `item` (required) | path | string (uuid) |  |

**Responses**

- `200` {unlinked: true}

## Pages linked to a work item (for the Tasks item pane)

```http
GET /v1/orgs/{org}/docs/task-links
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `item_id` (required) | query | string (uuid) |  |

**Responses**

- `200` {items: [PageSummary]}

## Trashed pages you can see (the pages that were trashed, not their sub-pages)

```http
GET /v1/orgs/{org}/docs/trash
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `q` | query | string |  |

**Responses**

- `200` {items: [PageSummary + trashed_by, space_name, role]}

## Titles and content (Postgres full-text with prefix matching + title trigram), only pages you can read

```http
GET /v1/orgs/{org}/docs/search
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `q` | query | string |  |
| `space_id` | query | string (uuid) |  |
| `limit` | query | integer |  |
| `rows` | query | boolean |  |

**Responses**

- `200` {items: [PageSummary + snippet (matches wrapped in \u0001…\u0002), path]}

## @-mention picker: people and AI employees you can see, pages

```http
GET /v1/orgs/{org}/docs/mentions
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `q` | query | string |  |

**Responses**

- `200` {people, agents, pages}

## Built-in page/database templates and your organisation's template pages

```http
GET /v1/orgs/{org}/docs/templates
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Responses**

- `200` {builtin: [{key, name, icon, description, kind}], org: [PageSummary]}

## Docs notifications: mentions, comments, replies, shares, agent suggestions

```http
GET /v1/orgs/{org}/docs/inbox
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Responses**

- `200` {items: [{id, kind, doc_page_id, doc_comment_id, text, actor, page, read_at, created_at}], unread}

## Mark all docs notifications read

```http
POST /v1/orgs/{org}/docs/inbox/read-all
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Responses**

- `200` {read: true}

## Mark one read

```http
POST /v1/orgs/{org}/docs/inbox/{id}/read
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {read: true}

## Change a grant's role {role} (full access)

```http
PATCH /v1/orgs/{org}/docs/grants/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {role}

## Remove a grant (full access; anyone may remove their own)

```http
DELETE /v1/orgs/{org}/docs/grants/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {deleted: true}

## A version's full Yjs state (update v1) for a read-only preview

```http
GET /v1/orgs/{org}/docs/versions/{id}/state
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` Yjs update

## Restore a version (edit access): its content becomes the page's (as a new edit, relayed live) and a `restore` version is saved

```http
POST /v1/orgs/{org}/docs/versions/{id}/restore
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {restored: true, page_id}

## Edit your comment's body; resolve / reopen its thread (comment access)

```http
PATCH /v1/orgs/{org}/docs/comments/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocComment

## Delete (author, or full access)

```http
DELETE /v1/orgs/{org}/docs/comments/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {deleted: true}

## Accept (edit access): the edits are applied as you and relayed to live editors; `stale` if the blocks are gone

```http
POST /v1/orgs/{org}/docs/suggestions/{id}/accept
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocSuggestion
- `409` Conflicting state (card already answered, duplicate in flight, name taken) — Problem

## Reject (edit access, or the person a personal agent suggested for)

```http
POST /v1/orgs/{org}/docs/suggestions/{id}/reject
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocSuggestion

## Add a property (edit access): text, number, select, multi_select, status, date, person, checkbox, url, email, files, relation (relation_database_id), created_by, created_time, edited_by, edited_time

```http
POST /v1/orgs/{org}/docs/databases/{id}/properties
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Request body** (JSON)

| Field | Type | Description |
|---|---|---|
| `name` | string |  |
| `type` | string |  |
| `options` | array of object |  |
| `relation_database_id` | string (uuid) |  |
| `number_format` | string |  |

**Responses**

- `201` {schema}

## Rename, change type (values that no longer fit are cleared) or options

```http
PATCH /v1/orgs/{org}/docs/databases/{id}/properties/{prop}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |
| `prop` (required) | path | string |  |

**Responses**

- `200` {schema}

## Delete a property and its values (not the title)

```http
DELETE /v1/orgs/{org}/docs/databases/{id}/properties/{prop}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |
| `prop` (required) | path | string |  |

**Responses**

- `200` {schema}

## Rows, filtered and sorted in SQL. Filters [{property, op: equals|not_equals|contains|not_contains|is_empty|is_not_empty|gt|lt|gte|lte|before|after|checked|unchecked, value}], filter_mode and|or, sorts [{property, direction}] (select/status by option order), q, limit ≤ 2000, templates

```http
POST /v1/orgs/{org}/docs/databases/{id}/query
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {items: [PageSummary + props, created_by, edited_by, created_at], schema, relations: {id: {title, icon}}, people: {id: {name}}}

## A database's views (shared by everyone who can see it)

```http
GET /v1/orgs/{org}/docs/databases/{id}/views
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {items: [{id, database_id, name, type: table\|board\|list\|calendar\|gallery, config, position}]}

## Add a view (edit access): config {filters, filter_mode, sorts, group_by, date_property, visible, widths, cover}

```http
POST /v1/orgs/{org}/docs/databases/{id}/views
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `201` DocView

## Row templates (rows with is_template; create a row from one with template_id)

```http
GET /v1/orgs/{org}/docs/databases/{id}/templates
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {items}

## Change a view: name, type, config, position

```http
PATCH /v1/orgs/{org}/docs/views/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` DocView

## Delete a view (a database keeps at least one)

```http
DELETE /v1/orgs/{org}/docs/views/{id}
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {deleted: true}

## Download (images, PDF, media inline; anything else as an attachment; nosniff)

```http
GET /v1/orgs/{org}/docs/files/{id}/content
```

**API keys:** needs the `docs:read` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` File bytes

## Bookmark preview of a public web page (SSRF-safe fetch): {url}

```http
POST /v1/orgs/{org}/docs/unfurl
```

**API keys:** needs the `docs:write` scope.

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Responses**

- `200` {url, title, description, image, site}

## Import Markdown files as pages {space_id?, parent_id?, files: [{name, markdown}]} (≤ 200 files; the first `# heading` becomes the title)

```http
POST /v1/orgs/{org}/docs/import/markdown
```

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Responses**

- `201` {pages: [PageSummary]}

## Dry run of a Notion export ("Markdown & CSV" zip, raw body ≤ 200 MB; nested part zips are read too): what would be created

```http
POST /v1/orgs/{org}/docs/import/notion/preview
```

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |

**Request body:** `application/zip`.

**Responses**

- `200` {pages, databases, rows, files, top_level: [{title, kind}], warnings}
- `422` Invalid input — Problem

## Import: pages and sub-pages, databases with typed properties from the CSV, rows with values and their page bodies, images/files into storage, links between pages rewritten to the new pages

```http
POST /v1/orgs/{org}/docs/import/notion
```

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `space_id` | query | string (uuid) |  |
| `parent_id` | query | string (uuid) |  |

**Request body:** `application/zip`.

**Responses**

- `201` {import_id, state: done, counts: {pages, databases, rows, files}, page_ids}

## An import's result

```http
GET /v1/orgs/{org}/docs/imports/{id}
```

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `200` {id, source, state, counts, page_ids, error}

## Save ready meeting notes (summary, decisions, action items as to-dos, notes) as a Docs page {space_id?, parent_id?} (default: your private pages)

```http
POST /v1/orgs/{org}/meetings/{id}/doc-page
```

**API keys:** not available (needs a person signed in to the app).

| Parameter | In | Type | Description |
|---|---|---|---|
| `org` (required) | path | string (uuid) | The caller's organisation id. |
| `id` (required) | path | string (uuid) | A Tasks object (project, section, field, item, comment, rule, form, view, attachment, notification or import). |

**Responses**

- `201` DocPage
- `409` Conflicting state (card already answered, duplicate in flight, name taken) — Problem
