---
name: AgentDocs
description: Read, create, update, search, and share documentation on AgentDocs (agentdocs.eu). Use when the user asks about their docs, wants to write or update pages, search across workspaces, or share documentation.
---

> **Skill version: 2026-11-05** · canonical copy: https://agentdocs.eu/agentdocs-skill.md
>
> This file is a **static upload** — Claude.ai keeps the copy you uploaded, so it does
> not update itself. Fetch the canonical URL and compare the version line above: if it
> is newer than this one, re-download and re-upload (Settings → Skills → Upload Skill).
> The REST API below is hand-mirrored from the live API, so a stale copy can describe
> endpoints that have since moved.
>
> Versions sort as date, then optional revision: `2026-07-28.2` supersedes `2026-07-28`.
> A bare date is revision 1.

### Review and reusable context

For an agent that should not edit directly, ask the owner to create a space token
with `permission: "propose"` (or `"read_only"` for reading only). These restrictions
are enforced on the server; an OAuth connection retains its existing documents
grant. On hosted MCP, use `propose_page_edit` with the current page's version,
full proposed content, and rationale. `list_proposals` returns review feedback;
`revise_page_proposal` submits a new revision against the current page. A person
reviews and publishes in the browser. Agent credentials cannot approve changes.

Use `list_context_collections` and `get_context_collection` to retrieve ordered
project context, required/optional pages, current versions, and changes since the
collection was saved. `create_context_collection` and `update_context_collection`
save a named purpose and ordered `{page_id, required}` entries. Access is checked
on every read; a collection does not share content publicly. `get_page_knowledge`
reports ownership and human-review freshness. These tools extend hosted
MCP; the published stdio package keeps its base tools. REST equivalents and
request contracts: https://agentdocs.eu/llms-full.txt (Proposed changes section).

## Overview

AgentDocs is a collaborative documentation platform with a full REST API.
Base URL: `https://agentdocs.eu`

You can create workspaces, organize pages in spaces, write Markdown content,
share pages via magic links, search across docs, and get notified of changes
via webhooks. Every feature available in the UI is also available via API.

## Setup

**Prefer the MCP tools when they're connected.** If your client already has the
AgentDocs MCP server (tools such as `list_workspaces`, `get_page`,
`update_page`), use them instead of hand-rolled curl calls. Both connections
expose the base document tools; the hosted endpoint also adds the collaboration
tools described above, which the published stdio package doesn't have.

- **Claude.ai, Claude Desktop, Claude mobile:** add `https://agentdocs.eu/mcp` as
  a custom connector (Settings → Connectors → Add custom connector) with no
  headers and no OAuth fields; AgentDocs runs the sign-in and consent itself.
  Prefer it over this Skill wherever it's available.
- **Claude Code:** `claude mcp add --transport http agentdocs https://agentdocs.eu/mcp --header "Authorization: Token <your-token>"`,
  or the local stdio package: `claude mcp add agentdocs --env AGENTDOCS_TOKEN=<your-token> -- npx -y agentdocs-mcp`
- **Other clients** (Codex, Cursor, VS Code, Gemini CLI, Zed, opencode, Docker
  gateway, Windows, updating): https://agentdocs.eu/llms.txt (MCP Server section)
  or https://agentdocs.eu/docs/agents

This Skill covers the rest: accounts that can't add custom connectors, plain
HTTP scripts, and CI.

**Installing this Skill.** On Claude.ai: Skills → Upload Skill, then drag in this
file. In Claude Code:

```bash
mkdir -p ~/.claude/skills/agentdocs ~/.config/agentdocs
curl -fsSL https://agentdocs.eu/agentdocs-skill.md > ~/.claude/skills/agentdocs/SKILL.md
# Token: agentdocs.eu → Profile → Regenerate API Token (shown once; save it straight to the file)
printf '%s' 'YOUR_API_TOKEN' > ~/.config/agentdocs/token
chmod 600 ~/.config/agentdocs/token
```

Optional personal defaults go in `~/.config/agentdocs/config.json` (keys
`instance_url`, `workspace_slug`, `space_slug`; `chmod 600`). A repository's
`.agentdocs.json` takes precedence (see "Where to write reports").

In Claude Code, invoke with `/agentdocs`, or ask naturally: "list my workspaces", "search docs for X", "create a page", "write a session report".

## Authentication

Three methods (use one per request):
- **JWT**: `Authorization: Bearer <jwt_token>` (expires in 7 days, used for browser sessions)
- **Account API Token**: `Authorization: Token <api_token>` (long-lived, ideal for agents — full access to everything the user owns)
- **Space-scoped Token**: `Authorization: Token <space_token>` (exactly one space, at the permission it was minted with: `direct_edit`, `propose` or `read_only`; same `Token` header; see "Space Tokens" below)

The account API token is **shown only once** — at user registration, at Nostr first-creation, and after explicit rotation via `POST /api/auth/regenerate-token`. **It is not returned by login.** If a user loses the token, they regenerate from the dashboard.

**On Claude Code (or any client with a filesystem)**, the token lives in `~/.config/agentdocs/token` (see "Installing this Skill" above). Read it as:
```bash
AD_TOKEN=$(cat ~/.config/agentdocs/token)
```
Then use it in the Authorization header, and don't print it into the conversation — it's already on disk, so echoing it only risks exposing it.

**On Claude.ai (web) there is no filesystem**, so the token can only come from the user. Ask for one when you need it, and say which kind:
- Prefer a **space-scoped token** (the **Connect an agent** button at the top of the space) — it reaches exactly one space, so a mistake can't touch the rest of the workspace. This is the recommended default for agent work. The form defaults to **Read only**; ask for **Read and edit directly** if the task writes pages, or **Read and propose edits** if a person should review changes first.
- Use an **account token** (Profile → Regenerate API Token) only when the task genuinely spans workspaces — listing workspaces, creating spaces, admin or billing routes.

Once given, use it for the rest of the conversation; don't repeat it back in later replies, and don't put it in page content, comments or share links. To avoid re-pasting every conversation, the user can keep it in their Claude **Project** instructions. Treat a token pasted in chat as a live credential: if it ever appears somewhere it shouldn't, tell the user to rotate it from the dashboard (Profile → Regenerate API Token), which invalidates the old one immediately. **You cannot rotate it yourself** — `POST /api/auth/regenerate-token` requires a signed-in browser session and refuses API tokens (`403 session_required`), precisely so a leaked token cannot be used to lock its owner out.

### Rotate the API token
```bash
curl -X POST https://agentdocs.eu/api/auth/regenerate-token \
  -H "Authorization: Bearer <jwt_token>"   # JWT ONLY — an API token gets 403
# Response: {"api_token": "new_token_here"}  ← shown once
```
Requires an interactive browser session. An account token, space token or OAuth
grant is refused with `403 session_required`: rotation is how an attacker
holding a leaked token would lock the real owner out, so it is gated on the one
credential that cannot itself be the leaked one.

The previous token is invalidated immediately. Save the new one into `~/.config/agentdocs/token`.

### Auth errors are self-describing
Any `/api/*` request without a valid credential returns `401` with a JSON body that explains how to onboard — a machine-readable `error` code (`authentication_required`, `invalid_token`, `token_expired`, `invalid_authorization_format`), the header formats, where to get a token, the public share-link route, and pointers to `llms.txt`, this Skill, and the MCP server. When a call 401s, parse the body instead of guessing. For security the body never confirms whether a specific page exists.

## Key Concepts

- **Workspace** — top-level container (like an org/team)
- **Space** — collection of related pages within a workspace
- **Page** — a Markdown document, can be nested (parent/child hierarchy)
- **Share Link** — public token-based URL to share a page without login
- **Space Token** — an API credential scoped to a single space (direct edit, propose-only or read-only)
- **Webhook** — HTTP callback when pages are created/updated/deleted

## Where to write reports: the project pointer

Agents working from a checkout must **never guess** the destination from a
workspace or space name (a workspace called "Agents…" is not the AgentDocs
project). The destination lives with the project, in **`.agentdocs.json` at the
repository root**:

```json
{
  "workspace": "jure-documents-central",
  "space": "agentdocs",
  "reports": {
    "parent": null,
    "title_format": "YYYY-MM-DD — Title"
  }
}
```

- `workspace` / `space` are **slugs** (resolve them with
  `GET /api/resolve/{workspace}/{space}` → ids). `reports.parent` is the slug of
  a page to nest reports under, or `null` for the top level of the space.
- **Precedence:** `.agentdocs.json` in the repo (walk up to the git root) →
  `~/.config/agentdocs/config.json` → ask. The global config is a personal
  default, not a project's pointer; two projects sharing it is how reports end
  up in the wrong workspace.
- **If the file is missing**, list the workspaces and spaces, ask the user which
  one this project reports to (offer to create a space named after the project),
  then write `.agentdocs.json` and say so — the next session, in any tool, starts
  from the file instead of searching.
- **Where the last report went:** `GET /api/spaces/{spaceId}/pages` (or the
  children of `reports.parent`) sorted by `created_at` shows the previous
  report, so a new one lands beside it.

### Report titles

`YYYY-MM-DD — Title` — ISO date first, an em dash, then a short noun phrase:
`2026-09-08 — Autosave regression and comments panel`. Date-first titles sort
correctly by name in every workspace and are unambiguous across projects and
tools. Two reports on one day get a distinguishing title, not a suffix. Put the
session's outcome in the body, not the title.

## Common Workflows

### List workspaces
```bash
curl https://agentdocs.eu/api/workspaces \
  -H "Authorization: Token <api_token>"
```
Response: `{"workspaces": [{"id": "uuid", "name": "...", "slug": "..."}], "owned_workspace_ids": ["uuid"]}`

Lists every workspace you own **or** belong to through a space membership; add
`?owned=true` to list only the workspaces you own. Owner-only endpoints (members,
webhooks, stats, billing, invitations) still answer 403 on workspaces you merely
belong to.

### List spaces in a workspace
```bash
curl https://agentdocs.eu/api/workspaces/{workspaceId}/spaces \
  -H "Authorization: Token <api_token>"
```
Response: `{"spaces": [{"id": "uuid", "name": "...", "slug": "..."}]}`

### List pages in a space
```bash
curl https://agentdocs.eu/api/spaces/{spaceId}/pages \
  -H "Authorization: Token <api_token>"
```
Add `?hierarchy=true` for nested tree structure.

Listings return **metadata only** — no `content`. Fetch a body with
`GET /api/pages/{pageId}`, or add `?include=content` to inline every body
(composes with `?hierarchy=true`). Keep the default unless you really need
the whole space at once; it keeps responses small.

### Get a page
```bash
curl https://agentdocs.eu/api/pages/{pageId} \
  -H "Authorization: Token <api_token>"
```
Response: `{"page": {"id": "uuid", "title": "...", "content": "# Markdown...", "version": 3}}`

### Create a page
```bash
curl -X POST https://agentdocs.eu/api/spaces/{spaceId}/pages \
  -H "Authorization: Token <api_token>" \
  -H "Content-Type: application/json" \
  -d '{"title": "My Page", "content": "# Hello\nMarkdown content here"}'
```
Optional fields: `slug` (auto-generated from the title when omitted — and deduped if it collides), `parent_page_id` (for nesting). Response 201: `{"page": {"id": "uuid", "title": "...", "slug": "...", "version": 1}}`.

### Update a page
```bash
curl -X PUT https://agentdocs.eu/api/pages/{pageId} \
  -H "Authorization: Token <api_token>" \
  -H "Content-Type: application/json" \
  -d '{"title": "Updated Title", "content": "# New content", "version": 3}'
```
Each update creates a new version automatically. `version` is optional: send the version you read and the update is refused with `409` (`{"conflict": true, "current_version", "current_content"}`) if the page was saved by someone else in between — re-read, merge, retry. Omit it for unconditional last-write-wins.

### Search across a workspace
```bash
curl "https://agentdocs.eu/api/workspaces/{workspaceId}/search?q=deployment" \
  -H "Authorization: Token <api_token>"
```
Response: `{"results": [{"id": "uuid", "title": "...", "slug": "...", "content_preview": "...with <<highlights>>...", "matched_in": ["title", "content"], "space_name": "...", "space_slug": "..."}]}`

Search-match highlights are delimited with `<<` `>>` markers (not HTML tags), and the snippet field is `content_preview`.

### Create a share link
```bash
curl -X POST https://agentdocs.eu/api/pages/{pageId}/share \
  -H "Authorization: Token <api_token>" \
  -H "Content-Type: application/json" \
  -d '{"expires_in_days": 30}'
```
Expiry is optional — pass `expires_in_days` (positive integer) **or** an explicit
ISO-8601 `expires_at` (e.g. `"2026-06-01T00:00:00Z"`); `expires_at` wins if both are
sent. Omit both for a non-expiring link.

Response 201: `{"share_link": {"id": "uuid", "token": "...", "url": "/shared/{token}", "expires_at": "ISO8601 or null", "created_at": "ISO8601"}}`. Note `url` is **relative** — prepend `https://agentdocs.eu`.

The shared page is then viewable at:
- JSON: `GET https://agentdocs.eu/api/shared/{token}`
- Raw Markdown: `GET https://agentdocs.eu/api/shared/{token}/raw` (no auth needed)

### List / revoke share links
```bash
curl https://agentdocs.eu/api/pages/{pageId}/shares \
  -H "Authorization: Token <api_token>"
```
Response: `{"share_links": [ ... ]}` (note the plural key, vs singular `share_link` on create). Revoke with `DELETE /api/pages/{pageId}/shares/{shareId}` → `{"message": "Share link deleted"}`.

### Read a shared page (no auth required)
```bash
curl https://agentdocs.eu/api/shared/{token}/raw
```
Returns clean Markdown with YAML frontmatter — ideal for agents.

### Delete a page (moves to trash — recoverable)
```bash
curl -X DELETE https://agentdocs.eu/api/pages/{pageId} \
  -H "Authorization: Token <api_token>"
# → {"message": "Page moved to trash", "trashed": 3, "restore_url": "/api/pages/{pageId}/restore"}
```
Cascades to child pages. **This is a soft delete** — content, version history and
comments are kept, and the page is purged automatically after the retention
window (30 days by default).

**If you deleted the wrong page, restore it rather than recreating it** —
recreating will not bring the history back:
```bash
curl -X POST https://agentdocs.eu/api/pages/{pageId}/restore \
  -H "Authorization: Token <api_token>"
# → {"message": "Page restored", "restored": 3, "slug_changed": false, "reparented_to_root": false}
```
`slug_changed` is true when another page took the slug meanwhile (the restored
page gets a numeric suffix); `reparented_to_root` is true when its parent is
still trashed, so it comes back at the space root.

See what can still be recovered with `GET /api/spaces/{spaceId}/trash`, or
destroy something irreversibly with `DELETE /api/pages/{pageId}/purge` (the page
must already be in the trash).

**Deleting a workspace works the same way, two levels deep** —
`DELETE /api/workspaces/{workspaceId}` trashes the workspace, its spaces and all
their pages together; recover with `POST /api/workspaces/{workspaceId}/restore`,
list with `GET /api/workspaces/trash`. Note it does **not** cancel a Pro
subscription.

**Deleting a space works the same way** — `DELETE /api/spaces/{spaceId}` moves the
space *and every page in it* to the trash together (owner-only). Recover with
`POST /api/spaces/{spaceId}/restore`, list what is recoverable with
`GET /api/workspaces/{workspaceId}/spaces/trash`. Restoring a space brings back
only the pages that went down with it — anything you had trashed individually
beforehand stays in the page trash and is restored on its own.

### Bulk create pages (up to 500)
```bash
curl -X POST https://agentdocs.eu/api/spaces/{spaceId}/pages/bulk \
  -H "Authorization: Token <api_token>" \
  -H "Content-Type: application/json" \
  -d '{"pages": [{"title": "Page 1", "content": "..."}, {"title": "Page 2", "content": "..."}]}'
```
Response: `{"created": N, "pages": [...]}`.

### Bulk delete pages
```bash
curl -X DELETE https://agentdocs.eu/api/spaces/{spaceId}/pages/bulk \
  -H "Authorization: Token <api_token>" \
  -H "Content-Type: application/json" \
  -d '{"page_ids": ["uuid", "..."]}'
```
Response: `{"deleted": N, "page_ids": [...]}`.

## Complete API Endpoints

### Auth
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/auth/register` | Register (name, email, password). Response: `{"user": {"id", "email", "name", "api_token", "role", "nostr_pubkey"}, "token": "<jwt>"}` — the raw API token is nested at `user.api_token` (one-time reveal), and the top-level `token` is a JWT. |
| POST | `/api/auth/login` | Login. Returns JWT only — API token NOT returned. |
| POST | `/api/auth/regenerate-token` | Rotate the API token. **JWT session only** — API/space/OAuth credentials get `403 session_required`. Returns new raw token once; previous token invalidated. |
| POST | `/api/auth/password` | Change password. |
| POST | `/api/auth/password-reset/request` | Start a password reset (body `{"email"}`). No auth. Always returns `{"status":"ok"}` (no account enumeration); emails a 1-hour reset link if the account exists. |
| POST | `/api/auth/password-reset/confirm` | Complete reset (body `{"token","password"}`; `token` is the 64-hex value from the email). No auth. |
| POST | `/api/auth/email/verify` | Verify email (body `{"token"}`, 64-hex from email). No auth. Idempotent. Verification is a soft gate. |
| POST | `/api/auth/email/resend` | Resend the verification email. Auth required. Returns `{"status":"ok"}` or `{"status":"ok","already_verified":true}`. |
| GET | `/api/auth/me` | Self-describe. `user.has_password` is false for Nostr-only accounts. Accepts JWT, account token, **or** space-scoped token. Returns `{user, credential}` — `credential.type` is `"jwt"` / `"account"` / `"space"`. For space tokens, `credential` additionally contains `space_id`, `space_slug`, `space_name`, `workspace_id`, `workspace_slug`, `workspace_name`, `token_id`, `token_name`, `expires_at`. **Use this to discover your space when handed a raw space token.** |
| GET | `/api/auth/me/export` | GDPR data export — all the user's data as JSON. |
| DELETE | `/api/auth/me` | GDPR account deletion. **JWT session only** (`403 session_required` otherwise), and requires body `{"confirmation": "DELETE", "password": "<password>"}` — the password is re-checked. Accounts with no password (Nostr-only) omit it. |

### Workspaces
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/workspaces` | Create workspace |
| GET | `/api/workspaces` | List user's workspaces |
| GET | `/api/workspaces/:id` | Get workspace |
| PUT | `/api/workspaces/:id` | Update workspace |
| DELETE | `/api/workspaces/:id` | Delete workspace (cascades) |
| GET | `/api/workspaces/:id/search?q=` | Full-text search |
| GET | `/api/workspaces/:id/search?q=&mode=semantic` | Semantic (embedding) search, natural-language queries — **Pro only**. Response `mode` field says `semantic` or `fulltext_fallback` |
| POST | `/api/workspaces/:id/invite` | Invite user by email to a space (body `{"email","space_id","role"?}`). User must already have an account; they're emailed a notification with a link to the space. |

### Spaces
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/workspaces/:wid/spaces` | Create space |
| GET | `/api/workspaces/:wid/spaces` | List spaces |
| GET | `/api/spaces/:id` | Get space |
| PUT | `/api/spaces/:id` | Update space |
| DELETE | `/api/spaces/:id` | Delete space |

### Pages
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/spaces/:sid/pages` | Create page |
| GET | `/api/spaces/:sid/pages` | List pages (?hierarchy=true). Each page carries `comment_count` / `unresolved_comment_count` / `last_comment_at` — comments don't bump `updated_at`, so check `last_comment_at` to spot new replies |
| POST | `/api/spaces/:sid/pages/bulk` | Bulk create (up to 500) |
| POST | `/api/spaces/:sid/import/markdown` | Import a markdown folder: `{"files": [{"path": "guides/setup.md", "content": "..."}]}`. Folders become parent pages (`index.md`/`README.md` supplies the folder page's content); titles from the first `# H1`, else the file name. Max 500/call. **Idempotent** — re-import reuses by source path (no `-2` dupes); optional `parent_page` (anchor) + `overwrite_existing` (re-sync). Returns `{created, reused, updated, pages}` |
| DELETE | `/api/spaces/:sid/pages/bulk` | Bulk delete |
| GET | `/api/pages/:id` | Get page (includes `comment_count` / `unresolved_comment_count` / `last_comment_at`). Add `?include=comments` for the comment thread and/or `?include=children` for immediate child pages (id/title/slug, no content); they compose: `?include=comments,children` |
| PUT | `/api/pages/:id` | Update page |
| PATCH | `/api/pages/:id/rename` | Rename title/slug |
| PUT | `/api/pages/:id/move` | Move to different parent/space |
| PUT | `/api/pages/:id/reorder` | Reorder a page among its siblings |
| POST | `/api/pages/:id/promote-to-space` | Promote a page (with its children) into a new space |
| DELETE | `/api/pages/:id` | Delete page (cascades) |
| GET | `/api/pages/:id/versions` | List versions. Each version records provenance: `edited_via` (`web` \| `api_token` \| `space_token`; `null` for pre-2026-06 versions) and `token_name` (space-token label, e.g. your agent's name) |
| POST | `/api/pages/:id/restore/:version` | Restore a page to an old version → `{"page": {...}, "restored_from_version": N}` |
| GET | `/api/pages/:id/ancestors` | Get parent chain |

### Share Links
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/pages/:pid/share` | Create share link (requires **editor** access) |
| GET | `/api/pages/:pid/shares` | List share links (read access only) |
| DELETE | `/api/pages/:pid/shares/:sid` | Revoke share link (requires **editor** access) |
| GET | `/api/shared/:token` | View shared page (JSON) |
| GET | `/api/shared/:token/raw` | View shared page (Markdown) |

Creating and revoking share links requires **editor** access — a viewer-role member gets `403`. Listing share links needs only read access.

### Comments
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/pages/:pid/comments` | Add comment |
| GET | `/api/pages/:pid/comments` | List threaded comments |
| PUT | `/api/comments/:id` | Update comment |
| DELETE | `/api/comments/:id` | Delete comment |

### Webhooks
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/workspaces/:id/webhooks` | Create webhook |
| GET | `/api/workspaces/:id/webhooks` | List webhooks |
| PATCH | `/api/workspaces/:id/webhooks/:wid` | Update webhook |
| DELETE | `/api/workspaces/:id/webhooks/:wid` | Delete webhook |
| GET | `/api/workspaces/:id/webhooks/:wid/logs` | Delivery logs for a webhook |
| POST | `/api/webhooks/test` | Test-deliver a one-off payload to a URL (body `{"url","secret"?}`) without saving a webhook. Auth required; URL is SSRF-checked and rate-limited. Returns `{"success", ...}`. |

The `url` must be a publicly reachable `https://` URL. An `http://` URL is
rejected with 400 (`details[0].msg`: `Webhook URLs must use https://`), and so
are internal addresses (loopback, RFC1918 private ranges, `169.254.169.254`
cloud metadata). Webhooks saved with `http://` before this rule keep delivering;
`PATCH` accepts their `http://` URL only unchanged. `/api/webhooks/test` still
accepts `http://`. HTTP redirects on delivery are not followed.

### Space Members
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/spaces/:sid/members` | Add member |
| GET | `/api/spaces/:sid/members` | List members |
| PUT | `/api/spaces/:sid/members/:mid` | Update role |
| DELETE | `/api/spaces/:sid/members/:mid` | Remove member |

### Space Tokens
A space-scoped token reaches **one space only** — ideal for handing an agent
access to a single space while keeping others private. Its `permission` is
`direct_edit` (the API default), `propose` or `read_only` (the web form's
default).
Sent as `Authorization: Token <space_token>` (same header as an account token).

| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/spaces/:sid/tokens` | Mint a token — body `{"name", "expires_at"?, "permission"?}`. Returns `{"token": {"id","name","permission","space_id","token":"<raw — once>","expires_at","created_at"}}` |
| GET | `/api/spaces/:sid/tokens` | List tokens for the space (no hashes) |
| DELETE | `/api/spaces/:sid/tokens/:tid` | Revoke a token |

Token management requires a JWT or account token (workspace owner / space
admin / system admin) — a space token cannot mint or list tokens. A space
token can use page, comment and share-link routes **within its space** and read
that space's members; it gets **403** on every other space, on workspace /
account / admin routes (except `GET /api/auth/me`, which self-describes — see
Auth table above), on `promote-to-space`, on moving a page into or out of the
space, on deleting the space, and on member writes. Restricted tokens are
narrower still: `read_only` refuses every mutation, and `propose` may submit and
revise proposals but is refused direct edits, deletes, comments, uploads, public
sharing and collection changes. Space tokens are REST-only — Socket.io
real-time editing rejects them.

### Other
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/templates` | List page templates |
| POST | `/api/spaces/:spaceId/uploads` | Upload an image (multipart, form field `file`; jpeg/png/gif/webp, max 5MB; SVG rejected) → `201` `{"url": "...", "id": "...", "size_bytes": N}` |
| POST | `/api/uploads?workspace_id=:id` | Same, for callers with no space handy (account credentials only) |
| GET | `/api/workspaces/:id/uploads` | List images → `{uploads, total_bytes, limit_bytes, tier}` |
| DELETE | `/api/uploads/:id` | Delete an image (frees quota) |
| GET | `/api/workspaces/:id/stats` | Workspace stats — space/page/member/webhook counts + recent activity |

The `stats` response is `{"stats": {"spaces", "pages", "members", "webhooks", "active_webhooks", "pages_last_30d", "pages_last_7d", "edits_last_30d", "comments", "created_at"}}`.

**Images.** Attach screenshots to the pages you write so the next reader — human
or agent — can see what you saw. Embed the returned URL as `![alt](/api/uploads/uuid.png)`.
Uploads count against the workspace image-storage quota (Free 50 MB, Pro 5 GB; **0 for a
new account until its owner verifies their email — a 403 carrying `"activation_required": true`
means ask the human to verify, not retry**); over
quota you get the standard `403` tier body with `limit`, `current` and `upgrade_url`.
Via MCP use `upload_image`, and read images back with `get_page` + `include_images: true`
(plain `get_page` returns the URL as text, which you cannot actually view).

## Tips for Agents

0. **Working from a repository? Read `.agentdocs.json` first** (see "Where to
   write reports") — it names the workspace and space; do not search for them.
1. **Otherwise start** by listing workspaces to find the right workspace ID
2. **Then list spaces** within that workspace to find the space ID
3. **Then list pages** or search to find specific content
4. **Use `?hierarchy=true`** on page listings to understand the page tree structure
5. **Page content is Markdown** — write content in proper Markdown format
6. **Each page update creates a version you can restore** — send the `version` you read so a concurrent edit returns `409` instead of being overwritten
7. **Share links with `/raw`** return clean Markdown with YAML frontmatter
8. **Bulk operations** are atomic — all succeed or all fail
