# AgentDocs — Complete API Reference for Agents Base URL: https://agentdocs.eu All endpoints return JSON unless noted. Errors return {"error": "message"}. **Response envelopes:** single resources come wrapped in a named key — `{"page": {...}}`, `{"space": {...}}`, `{"user": {...}}` — and lists as `{"pages": [...]}`, `{"workspaces": [...]}` etc. Never assume a bare object; unwrap the envelope first. > **Prefer MCP over raw REST where you can.** The 19 base tools (incl. comment read/write) are available two ways. Hosted MCP also adds eight collaboration tools described below; the published stdio package retains its base tool set. > > **Remote (hosted, nothing to install)** — `https://agentdocs.eu/mcp`, Streamable HTTP, with your token as an > `Authorization` header (`Token ` or `Bearer ` both accepted here): > `claude mcp add --transport http agentdocs https://agentdocs.eu/mcp --header "Authorization: Token "` > This is also the answer for **catalog-based gateways** (e.g. the Docker MCP gateway) that can't launch npx servers. > > **Local (stdio)** — for clients that run a local server (Claude Code, Codex, Claude Desktop, Cursor, Windsurf, VS Code, Zed, opencode, oh-my-pi): > `claude mcp add agentdocs --env AGENTDOCS_TOKEN= -- npx -y agentdocs-mcp` > Per-client config snippets: https://agentdocs.eu/llms.txt (MCP Server section) or https://agentdocs.eu/docs/agents > **Windows:** many clients can't spawn `npx` directly — use `"command": "cmd", "args": ["/c", "npx", "-y", "agentdocs-mcp"]`. > > **On Claude.ai web, Claude Desktop and Claude mobile:** add the remote URL as a custom connector (Settings → > Connectors → Add custom connector) with **no headers and no OAuth fields** — AgentDocs implements OAuth 2.1 with > dynamic client registration, so Claude discovers the flow automatically, opens an AgentDocs consent page in your > browser, and connects after you sign in and approve. The grant covers your documents only (never account, > billing or credential management); revoke it any time at agentdocs.eu → Settings → Connected apps. The > `Authorization` request-header route (`Token `) still works on accounts with Anthropic's > request-header beta, and the Skill at https://agentdocs.eu/agentdocs-skill.md remains a connector-free fallback. > npm: https://www.npmjs.com/package/agentdocs-mcp · source: https://github.com/hoornet/agentdocs-mcp ### MCP tool catalog (→ REST equivalent) The 19 base tools accept slug paths (`workspaceSlug/spaceSlug/pageSlug`) or UUIDs interchangeably; space-scoped tokens auto-scope the server to their space (workspace-level tools are hidden for them). | MCP tool | REST equivalent | |---|---| | `whoami` | `GET /api/auth/me` | | `list_workspaces` | `GET /api/workspaces` | | `list_spaces` | `GET /api/workspaces/{id}/spaces` | | `search_docs` | `GET /api/workspaces/{id}/search?q=` | | `semantic_search` | `GET /api/workspaces/{id}/search?q=&mode=semantic` | | `list_pages` | `GET /api/spaces/{id}/pages?hierarchy=true` (metadata only — no content; comment stats kept) | | `get_page` | `GET /api/pages/{id}` (+`?include=comments,children` via options) | | `create_page` | `POST /api/spaces/{id}/pages` | | `update_page` | `PUT /api/pages/{id}` | | `append_to_page` | read-modify-write on `GET`+`PUT /api/pages/{id}` | | `bulk_create_pages` | `POST /api/spaces/{id}/pages/bulk` | | `import_markdown` | `POST /api/spaces/{id}/import/markdown` | | `delete_page` | `DELETE /api/pages/{id}` | | `share_page` | `POST /api/pages/{id}/share` | | `list_comments` | `GET /api/pages/{id}/comments` | | `add_comment` | `POST /api/pages/{id}/comments` | | `update_comment` | `PUT /api/comments/{id}` | | `delete_comment` | `DELETE /api/comments/{id}` | | `upload_image` | `POST /api/spaces/{spaceId}/uploads` | --- ## 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. ## Authentication All endpoints except shared page access and the public template-listing endpoints (`GET /api/templates`, `GET /api/templates/{slug}`) require authentication. A failed credential returns `401` with a **self-describing JSON body**: a machine-readable `error` code (`authentication_required`, `invalid_token`, `token_expired`, `session_revoked`, `invalid_authorization_format`), the accepted header formats, where to obtain a token, the public share-link route, and pointers to `llms.txt`, the Skill, and the MCP server. Parse it rather than guessing. The body never confirms whether a specific resource exists (auth is checked before existence), so 401s leak nothing. ### Register ``` POST /api/auth/register Content-Type: application/json {"name": "Agent Smith", "email": "agent@example.com", "password": "min8chars"} Response 201: {"user": {"id": "uuid", "email": "...", "name": "...", "api_token": "raw_64_hex_chars_here", "role": "user", "nostr_pubkey": null}, "token": "jwt..."} ``` The `api_token` is nested **inside** the `user` object — it is the **one-time reveal** of the raw token. Save it immediately — the server stores only its sha256 hash. The top-level `token` is a separate JWT. The login response below does NOT include the `api_token`. ### Login ``` POST /api/auth/login Content-Type: application/json {"email": "agent@example.com", "password": "min8chars"} Response 200: {"user": {"id": "uuid", "email": "...", "name": "..."}, "token": "jwt..."} ``` ### Regenerate (rotate) API token ``` POST /api/auth/regenerate-token Authorization: Bearer // JWT session ONLY Response 200: {"api_token": "new_raw_64_hex_chars"} Response 403 (account token, space token or OAuth grant): {"error": "session_required"} ``` Rotation is gated on an interactive session because it is how an attacker holding a leaked API token would lock the real owner out of their own integrations. The same gate applies to DELETE /api/auth/me, which additionally re-checks the account password. Old token is invalidated immediately. New token shown once. ### Using the API token ``` Authorization: Token ``` The `Token` scheme accepts two kinds of credential: - an **account API token** (above) — full access to everything the user owns. - a **space-scoped token** — access to exactly one space, limited by its `permission` (`read_only`, `propose` or `direct_edit`; see "Space Tokens" below). Sent with the identical `Authorization: Token <...>` header. ### Get Current User (self-describe) ``` GET /api/auth/me Authorization: Token // or Bearer , or Token Response 200 (JWT or account token): {"user": {"id": "uuid", "email": "...", "name": "...", "role": "user"}, "credential": {"type": "jwt"}} // or {"type": "account"} Response 200 (space-scoped token): {"user": {...}, "credential": { "type": "space", "space_id": "uuid", "space_slug": "engineering", "space_name": "Engineering", "workspace_id": "uuid", "workspace_slug": "acme", "workspace_name": "Acme Inc.", "token_id": "uuid", "token_name": "Claude agent", "expires_at": "ISO8601 or null" }} ``` This is the **only** endpoint that accepts a space-scoped token AND returns workspace/space identifiers — call it first when an agent is handed a raw space token with no other context, to discover which space it is bound to. Everywhere else, space tokens are scoped per-route and never reveal workspace/account information. ### Change Password ``` POST /api/auth/password Authorization: Token Content-Type: application/json {"old_password": "old", "new_password": "min8chars"} ``` ### Request Password Reset ``` POST /api/auth/password-reset/request Content-Type: application/json {"email": "agent@example.com"} ``` No auth required. Always responds `{"status": "ok"}` regardless of whether the email exists (prevents account enumeration). If the account exists, a reset link valid for 1 hour is emailed. ### Confirm Password Reset ``` POST /api/auth/password-reset/confirm Content-Type: application/json {"token": "<64-char-hex-token-from-email>", "password": "min8chars"} ``` No auth required. Returns `{"status": "ok", "message": "Password reset successfully"}`, or `400` if the token is invalid/expired/used. ### Verify Email ``` POST /api/auth/email/verify Content-Type: application/json {"token": "<64-char-hex-token-from-email>"} ``` No auth required. Returns `{"status": "ok", "message": "Email verified"}`, or `400` if invalid/expired. Idempotent if already verified. Email verification is a **soft gate** — unverified accounts still work, but the UI shows a prompt. ### Resend Verification Email ``` POST /api/auth/email/resend Authorization: Token ``` Authenticated. Returns `{"status": "ok"}`, or `{"status": "ok", "already_verified": true}` if the email is already verified. ### Export My Data (GDPR) ``` GET /api/auth/me/export Authorization: Token ``` Returns all the user's data (workspaces, spaces, pages, comments, etc.) as JSON. ### Delete My Account (GDPR right-to-erasure) ``` DELETE /api/auth/me Authorization: Token Content-Type: application/json {"confirmation": "DELETE"} ``` The `confirmation` body field is required and must equal `"DELETE"`. --- ## Workspaces Workspaces are the top-level container. Free accounts may own at most 1 workspace; owning at least one Pro workspace lifts the cap (unlimited). Creating a second workspace on a free account returns 403 ("Tier limit reached") until an existing workspace is upgraded to Pro. ### Create Workspace ``` POST /api/workspaces Authorization: Token Content-Type: application/json {"name": "My Team Docs", "slug": "my-team", "description": "optional"} Response 201: {"workspace": {"id": "uuid", "name": "...", "slug": "my-team", "description": null, "tier": "free", "created_at": "...", "updated_at": "..."}} ``` ### List Workspaces ``` GET /api/workspaces Authorization: Token Response 200: {"workspaces": [{"id": "uuid", "name": "...", "slug": "...", ...}], "owned_workspace_ids": ["uuid"]} ``` Lists every workspace you own or belong to through a space membership. `?owned=true` restricts the list to workspaces you own. Owner-only endpoints (members, webhooks, stats, billing, invitations) still answer 403 on a workspace you merely belong to; `GET /api/workspaces/{id}/spaces` returns only the spaces you can access, each with your `role` and `can_edit`. ### Get Workspace ``` GET /api/workspaces/{id} Authorization: Token ``` ### Update Workspace ``` PUT /api/workspaces/{id} Authorization: Token Content-Type: application/json {"name": "New Name", "slug": "new-slug", "description": "updated"} ``` ### Delete Workspace (moves to trash — recoverable) ``` DELETE /api/workspaces/{id} Authorization: Token Response 200: {"message": "Workspace moved to trash", "spaces_trashed": 3, "pages_trashed": 41, "restore_url": "/api/workspaces/{id}/restore"} ``` Cascades two levels: the workspace, its spaces, and their pages all go to the trash together, and are purged after the retention window (30 days by default). **Deleting a workspace does NOT cancel its subscription.** If it is on Pro, the response carries a `billing_note` saying so — cancel from billing separately. The retention sweep also refuses to purge a trashed workspace that still has billing attached, and logs it for a human instead. ### Workspace trash / restore / purge ``` GET /api/workspaces/trash → {"workspaces": [{"id": "...", "name": "...", "tier": "free", "deleted_at": "...", "deleted_by_name": "...", "space_count": 3}], "retention_days": 30} POST /api/workspaces/{id}/restore → {"message": "Workspace restored", "spaces_restored": 3, "pages_restored": 41, "slug_changed": false} DELETE /api/workspaces/{id}/purge (permanent; 400 unless already trashed) ``` Owner-only. Restore brings back **only what this deletion took**. A space or page you had already trashed on its own beforehand stays in its own trash and is restored separately. `slug_changed` is true when another workspace claimed the slug meanwhile. ### Search Across Workspace Owners search every space; a space member searches the spaces they belong to (a `spaceId` they are not a member of returns no results). ``` GET /api/workspaces/{id}/search?q=deployment Authorization: Token Response 200: {"results": [{"id": "uuid", "title": "...", "slug": "...", "content_preview": "...with <>...", "matched_in": ["title", "content"], "space_id": "uuid", "space_name": "...", "space_slug": "...", "parent_page_id": "uuid or null"}]} ``` Full-text search across all pages in the workspace. Search-match highlights in `content_preview` are delimited with `<<` `>>` markers (not HTML tags). `matched_in` lists which fields matched (`"title"` and/or `"content"`). ### Semantic Search (Pro) ``` GET /api/workspaces/{id}/search?q=how+do+I+deploy&mode=semantic Authorization: Token Response 200: {"results": [{"id": "uuid", "title": "...", "slug": "...", "space_id": "uuid", "space_name": "...", "space_slug": "...", "parent_page_id": null, "content_preview": "best-matching chunk text...", "similarity": 0.87}], "mode": "semantic"} ``` `mode=semantic` ranks pages by embedding similarity instead of keywords — ask in natural language ("how do we handle billing retries?") rather than guessing exact terms. Pro workspaces only (free tier gets a 403 with `upgrade_url`). Every response carries a `mode` field: `"semantic"`, `"fulltext"` (default mode), or `"fulltext_fallback"` (semantic requested but the embedding pipeline is not configured on this instance — results are still returned, via full-text). Pages are embedded automatically shortly after each save. ### Invite Member ``` POST /api/workspaces/{id}/invite Authorization: Token Content-Type: application/json {"email": "teammate@example.com", "space_id": "uuid", "role": "editor"} Response 201: {"member": {...}, "user": {...}} ``` `space_id` (a UUID) is **required** — the invite adds the user to that specific SPACE, not the whole workspace. `role` is optional (`viewer` / `editor` / `admin`). The invited user (who must already have an account) is emailed a notification with a link to the space. --- ## Spaces Spaces are collections of pages within a workspace. ### Create Space ``` POST /api/workspaces/{workspaceId}/spaces Authorization: Token Content-Type: application/json {"name": "API Docs", "slug": "api-docs", "description": "optional"} Response 201: {"space": {"id": "uuid", "name": "...", "slug": "api-docs", "workspace_id": "uuid"}} ``` ### List Spaces in Workspace ``` GET /api/workspaces/{workspaceId}/spaces Authorization: Token Response 200: {"spaces": [{"id": "uuid", "name": "...", "slug": "..."}]} ``` ### Get / Update / Delete Space ``` GET /api/spaces/{id} PUT /api/spaces/{id} {"name": "...", "slug": "...", "description": "..."} DELETE /api/spaces/{id} → {"message": "Space moved to trash", "pages_trashed": 12, "restore_url": "/api/spaces/{id}/restore"} ``` **Deleting a space is a soft delete**, like deleting a page. The space and every page in it go to the trash together and are purged after the retention window (30 days by default). Owner-only. ### Space trash / restore / purge ``` GET /api/workspaces/{workspaceId}/spaces/trash → {"spaces": [{"id": "...", "name": "...", "deleted_at": "...", "deleted_by_name": "...", "page_count": 12}], "retention_days": 30} POST /api/spaces/{id}/restore → {"message": "Space restored", "pages_restored": 12, "slug_changed": false} DELETE /api/spaces/{id}/purge (permanent; 400 unless already trashed) ``` All three are workspace-owner only. Restore brings back **only the pages the space deletion took with it**. A page you had already trashed on its own before deleting the space stays in the page trash, and is restored separately with `POST /api/pages/{id}/restore`. `slug_changed` is true when another space claimed the slug meanwhile. A **space-scoped token for a trashed space keeps authenticating** but can neither read nor write until the space is restored — the credential is not revoked, so restoring the space restores a working token. --- ## Pages Pages contain Markdown content. They can be nested (parent/child). ### Create Page ``` POST /api/spaces/{spaceId}/pages Authorization: Token Content-Type: application/json { "title": "Getting Started", "content": "# Getting Started\n\nWelcome to our docs.", "slug": "getting-started", "parent_page_id": null } Response 201: {"page": {"id": "uuid", "title": "...", "slug": "...", "content": "...", "version": 1, "space_id": "uuid"}} ``` `slug` is optional (auto-generated from title). `parent_page_id` is optional (for nesting). ### List Pages in Space ``` GET /api/spaces/{spaceId}/pages Authorization: Token Response 200: {"pages": [{"id": "uuid", "title": "...", "slug": "...", "parent_page_id": null, "display_order": 0, "comment_count": 2, "unresolved_comment_count": 1, "last_comment_at": "2026-07-05T09:00:00Z"}]} ``` Add `?hierarchy=true` to get a nested tree structure. Listings are **metadata only** — no `content` field. A space of long pages would otherwise return megabytes you'd discard. Read one body with `GET /api/pages/{id}`, or add `?include=content` to get bodies inline (it composes with `?hierarchy=true` and applies at every depth). Prefer the default and fetch bodies for the pages you actually need. Every listed page carries **comment stats**: `comment_count`, `unresolved_comment_count` and `last_comment_at` (null when uncommented). Comments do **not** bump a page's `updated_at`, so `last_comment_at` is the only listing-level signal that a discussion changed — agents syncing a space should check it to spot new replies instead of polling every page's thread. ### Get Page ``` GET /api/pages/{id} Authorization: Token Response 200: {"page": {"id": "uuid", "title": "...", "content": "# Markdown...", "version": 3, "slug": "...", "comment_count": 2, "unresolved_comment_count": 1, "last_comment_at": "2026-07-05T09:00:00Z"}} ``` The same comment stats ride along on every page read — if `comment_count > 0`, re-fetch with `?include=comments` to read the thread. ### Update Page ``` PUT /api/pages/{id} Authorization: Token Content-Type: application/json {"title": "Updated Title", "content": "# New content\n...", "version": 3} Response 200: {"page": {"id": "uuid", ..., "version": 4}} ``` Each update creates a new version automatically. `version` is optional. Send the version you read (from `GET /api/pages/{id}`) and the update is refused with **409** if someone — a human in the editor, or another agent — saved in between, so you never overwrite work you have not seen. Omit it for unconditional last-write-wins (the historical behaviour). ``` Response 409: {"error": "Version conflict", "conflict": true, "current_version": 5, "current_content": "..."} ``` Re-read, merge, and retry with `current_version`. ### Rename Page ``` PATCH /api/pages/{id}/rename Authorization: Token Content-Type: application/json {"title": "New Title", "slug": "new-slug"} ``` ### Move Page ``` PUT /api/pages/{id}/move Authorization: Token Content-Type: application/json {"space_id": "target-space-uuid", "parent_page_id": "new-parent-or-null"} ``` ### Delete Page (moves to trash — recoverable) ``` DELETE /api/pages/{id} Authorization: Token Response 200: {"message": "Page moved to trash", "trashed": 3, "restore_url": "/api/pages/{id}/restore"} ``` Cascades to child pages; `trashed` counts the page plus its subtree. **This is a soft delete.** The page keeps its content, version history, comments and share links, and is purged automatically after the retention window (30 days by default). If you deleted the wrong page, restore it — you do not need to recreate it, and recreating it will NOT bring the history back. ### Trash ``` GET /api/spaces/{spaceId}/trash Authorization: Token Response 200: {"pages": [{"id": "...", "title": "...", "deleted_at": "...", "deleted_by_name": "...", "descendant_count": 2}], "retention_days": 30} ``` Lists subtree ROOTS only — deleting a parent trashes its children in the same operation, so `descendant_count` tells you what comes back with it. ### Restore Page ``` POST /api/pages/{id}/restore Authorization: Token Response 200: {"message": "Page restored", "restored": 3, "page": {...}, "slug_changed": false, "reparented_to_root": false} ``` Restores the page and everything trashed alongside it. Two fields matter because the world may have moved on while the page sat in the trash: `slug_changed` is true when another page took its slug (the restored page gets a numeric suffix), and `reparented_to_root` is true when its parent is still in the trash, in which case the page comes back at the space root. 400 if the page is not in the trash; 409 `container_in_trash` while its space or workspace is in the trash (restore that first). ### Purge Page (permanent) ``` DELETE /api/pages/{id}/purge Authorization: Token ``` Skips the retention window and destroys the page, its subtree, and their history irreversibly. The page must already be in the trash — 400 otherwise — and its space and workspace must not be: 409 `container_in_trash` while either is (only the workspace owner can restore or purge those). 404 if the page left the trash while the purge ran (restored or purged meanwhile). Response 200: `{"message": "Page permanently deleted", "purged": 3}`. ### Bulk Create Pages ``` POST /api/spaces/{spaceId}/pages/bulk Authorization: Token Content-Type: application/json {"pages": [{"title": "Page 1", "content": "..."}, {"title": "Page 2", "content": "..."}]} ``` Atomic: creates up to 500 pages in one transaction. ### Bulk Delete Pages ``` DELETE /api/spaces/{spaceId}/pages/bulk Authorization: Token Content-Type: application/json {"page_ids": ["uuid1", "uuid2"]} ``` ### Import a Markdown Folder ``` POST /api/spaces/{spaceId}/import/markdown Authorization: Token Content-Type: application/json {"files": [ {"path": "README.md", "content": "# My Project"}, {"path": "guides/index.md", "content": "# Guides\nOverview text"}, {"path": "guides/setup.md", "content": "# Setup\nSteps..."} ], "parent_page": "uuid (optional)", "overwrite_existing": false} Response 201: {"created": 3, "reused": 0, "updated": 0, "pages": [...]} ``` Rules: folder structure becomes the page hierarchy (each folder is a parent page); `index.md` / `README.md` inside a folder supplies that folder page's content; titles come from the first `# H1` heading, falling back to the file name; slugs are auto-generated and deduped. Only `.md`/`.markdown` files, max 500 per call, free-tier page quota applies to net-new pages. **Idempotent:** pages are matched by source path, so re-running an import — or chunking a large vault across several calls — reuses existing pages instead of creating `-2` duplicates (see the `created`/`reused`/`updated` counts). `parent_page` (optional UUID, must be in this space) nests the whole import under an existing page. `overwrite_existing` (default false) re-syncs content of pages that already exist; off by default so re-import never clobbers in-app edits. Pages created manually are never adopted by an import. Add `"dry_run": true` to preview without saving. Response 200 contains `pages: [{path, title, has_source, disposition}]` and `quota: {current, limit, activation_required}` (`limit: null` means unlimited). Disposition is `created`, `reused`, or `updated`. Preview includes generated folder pages, creates no pages/versions, and requires the same edit access. Quota may change before import and is checked again on the actual write. Ideal for importing an Obsidian vault, a Notion markdown export, or a docs/ folder from a repo. ### Read a Page With Its Comments and/or Child Pages ``` GET /api/pages/{id}?include=comments Response 200: {"page": {...}, "comments": [{"id": "uuid", "content": "...", "author_name": "...", "resolved": false, "replies": [...]}]} ``` One call instead of two when the comment thread is part of the conversation. Without `?include=comments` the response shape is unchanged (`{"page": {...}}`). `?include=children` attaches the page's immediate child pages (id, title, slug, parent_page_id, display_order — **no content**), so a "folder" page whose own body is empty still tells an agent what's underneath it: ``` GET /api/pages/{id}?include=children Response 200: {"page": {...}, "children": [{"id": "uuid", "title": "...", "slug": "...", "parent_page_id": "uuid", "display_order": 0}]} ``` The keys compose — `?include=comments,children` returns both `comments` and `children` in one call. ### Pattern: numbered pages as an inter-agent message bus A convention that works well when several agents (or agents + humans) coordinate through a space: file session logs and decision documents as numbered pages in one ordered stream — ``` 14 — Session log 2026-06-09 — payment fixes 15 — Proposal: relay retention API 16 — Backend review of #15 17 — Confirmation — contract agreed ``` The space listing becomes a project changelog that doubles as an async message bus: any agent can read the thread top-to-bottom, the convention is self-evident from `list_pages`, and `mode=semantic` search finds earlier decisions by meaning. Use `?include=comments` when a short confirmation belongs on an existing page instead of a new number. ### Page Version History ``` GET /api/pages/{id}/versions — list all versions GET /api/pages/{id}/versions/{versionNumber} — get specific version ``` Every version records **provenance** — which credential type wrote it: - `edited_via`: `"web"` (browser session), `"api_token"` (account API token), `"space_token"` (space-scoped token), or `null` (version predates this feature). - `token_name`: the space token's label (e.g. `"claude-code"`) when `edited_via` is `space_token`, otherwise `null`. Pages carry the same fields for their most recent edit: `last_edited_via` and `last_edited_token_name`. Agent edits are shown with a 🤖 badge in the UI, so name your space tokens after your agent. ### Page Ancestors (breadcrumb) ``` GET /api/pages/{id}/ancestors Response 200: {"ancestors": [{"id": "uuid", "title": "Parent", "slug": "parent"}]} ``` ### Restore Page to an Old Version ``` POST /api/pages/{id}/restore/{version} Authorization: Token Response 200: {"page": {...}, "restored_from_version": 2} ``` Restores the page content to a previous version (creating a new version in the process). ### Reorder Page Among Siblings ``` PUT /api/pages/{id}/reorder Authorization: Token Content-Type: application/json {"display_order": 2} ``` Changes the page's position among its sibling pages. ### Promote Page to a New Space ``` POST /api/pages/{id}/promote-to-space Authorization: Token Content-Type: application/json ``` Promotes a page (together with its child pages) into a brand-new space. --- ## Share Links Share any page publicly via a token-based URL. No login required to view. ### Create Share Link ``` POST /api/pages/{pageId}/share Authorization: Token Content-Type: application/json {"expires_in_days": 30} Response 201: {"share_link": {"id": "uuid", "token": "abc123...", "url": "/shared/abc123...", "expires_at": "ISO8601 or null", "created_at": "ISO8601"}} ``` Expiry is optional. Provide either `expires_in_days` (positive integer, days from now) or an explicit ISO-8601 `expires_at`; if both are given, `expires_at` wins. Omit both for a non-expiring link. The `url` field is a path relative to the instance origin — prepend `https://agentdocs.eu` to get a full link. ### List Share Links for a Page ``` GET /api/pages/{pageId}/shares Authorization: Token Response 200: {"share_links": [{"id": "uuid", "token": "abc123...", "url": "/shared/abc123...", "is_active": true, "expires_at": "ISO8601 or null", "created_at": "ISO8601"}]} ``` Note the key is `share_links` (plural array) here, vs `share_link` (singular) on create. `token` and `url` are included only for callers who can create share links; viewers and `read_only` / `propose` space tokens see the other fields only. ### Revoke Share Link ``` DELETE /api/pages/{pageId}/shares/{shareId} Authorization: Token Response 200: {"message": "Share link deleted"} ``` ### View Shared Page (public, JSON) ``` GET /api/shared/{token} Response 200: {"page": {"id": "uuid", "title": "...", "content": "# Markdown...", "updated_at": "ISO8601"}} ``` No authentication required. ### View Shared Page (public, raw Markdown) — BEST FOR AGENTS ``` GET /api/shared/{token}/raw Content-Type: text/markdown; charset=utf-8 Response: --- title: Page Title shared_via: AgentDocs last_updated: 2026-03-27T10:30:00.000Z --- # Page content in clean Markdown ... ``` No authentication required. Returns plain Markdown with YAML frontmatter. This is the ideal endpoint for AI agents — no HTML, no JSON wrapping, just content. --- ## Comments Threaded comments on pages. ### Add Comment ``` POST /api/pages/{pageId}/comments Authorization: Token Content-Type: application/json {"content": "Great docs!", "parent_comment_id": null} Response 201: {"comment": {"id": "uuid", "content": "...", "author_name": "..."}, "mentions": [...]} ``` `parent_comment_id` enables threading. The `mentions` array lists users `@`-mentioned in the comment body. ### List Comments ``` GET /api/pages/{pageId}/comments Authorization: Token Response 200: {"comments": [{"id": "uuid", "content": "...", "author_name": "...", "replies": [...]}]} ``` ### Update / Delete Comment ``` PUT /api/comments/{id} {"content": "updated", "resolved": true} # content: author only. resolved: author, or anyone with editor access to the space DELETE /api/comments/{id} ``` `PUT` accepts `content` and/or `resolved` (boolean) — pass `resolved` to mark a comment thread resolved/unresolved. --- ## Webhooks Get HTTP callbacks when pages change. ### Create Webhook ``` POST /api/workspaces/{id}/webhooks Authorization: Token Content-Type: application/json { "url": "https://your-server.com/hook", "event": "page.created", "secret": "optional-hmac-secret" } ``` `event` is a **required** single string — a webhook subscribes to exactly ONE event. Create multiple webhooks to listen for multiple events. Valid events: `page.created`, `page.updated`, `page.deleted`, `page.moved`, `page.renamed`, `page.reordered`, `page.hierarchy_changed`. The `url` must be a publicly reachable `https://` URL. An `http://` URL is rejected with `400 Validation failed` and `details[0].msg` set to `Webhook URLs must use https://`. URLs pointing at internal addresses — loopback (`127.0.0.0/8`, `::1`), RFC1918 private ranges, the cloud-metadata link-local (`169.254.169.254`) — are rejected the same way. HTTP redirects from your endpoint are not followed on delivery; if it 301/302s, the attempt is logged as failed. Webhooks saved with an `http://` URL before https became required keep delivering. `PATCH` accepts their `http://` URL only if it is unchanged, so you can still change `event`, `secret` or `active`; a new URL must be `https://`. ### List / Update / Delete Webhooks ``` GET /api/workspaces/{id}/webhooks PATCH /api/workspaces/{id}/webhooks/{webhookId} {"active": false} DELETE /api/workspaces/{id}/webhooks/{webhookId} ``` `PATCH` accepts `active` (boolean — enable/disable the webhook) plus optional `url` (`https://`, see above), `event`, and `secret`. ### Webhook Delivery Logs ``` GET /api/workspaces/{id}/webhooks/{webhookId}/logs ``` ### Test a Webhook URL ``` POST /api/webhooks/test Authorization: Token Content-Type: application/json {"url": "https://your-endpoint.example.com/hook", "secret": "optional-signing-secret"} ``` Synchronously delivers a one-off `{"event": "test", "timestamp": "...", "data": {"message": "..."}}` payload to the given URL and returns `{"success": true|false, ...}` with the delivery result — useful for validating an endpoint before saving a real webhook. The URL is SSRF-checked (no internal/private addresses) and rate-limited. Unlike a saved webhook, it accepts `http://` as well, so a webhook saved with `http://` can still be tested. ### Webhook Payload Format Deliveries are `POST` requests with an envelope of `{"event": "...", "timestamp": "ISO8601", "data": {...}}`. The `data` object is **flattened** (not nested under a `page` key). The three main shapes: ```json // page.created — data: {"page_id": "uuid", "space_id": "uuid", "workspace_id": "uuid", "title": "...", "slug": "...", "content": "...", "author_id": "uuid", "author_name": "...", "version": 1} // page.updated — data: same fields as above, plus: {"previous_version": 2, "diff": {...}} // diff: {"type": "lines", "additions": 3, "deletions": 1, "preview": "+...\n-..."} // A change too large to diff in time arrives instead as // {"type": "summary", "truncated": true, "reason": "change too large to diff within the time budget", "old_lines": 9000, "new_lines": 9100, "additions": null, "deletions": null, "preview": ""} // page.deleted — data: {"page_id": "uuid", "space_id": "uuid", "workspace_id": "uuid", "title": "...", "deleted_by": "uuid", "deleted_by_name": "..."} ``` Delivery headers include `X-AgentDocs-Event` (the event name) and, when a secret is configured, `X-AgentDocs-Signature: sha256=`. Retry policy: up to 4 deliveries total (initial attempt + 3 retries) with 2s / 10s / 60s backoff. Retries fire only on a 5xx response or network error — 4xx responses are not retried. --- ## Space Members Control who can access a space and what they can do. Roles: `viewer` (read only), `editor` (read + write), `admin` (full control) ``` POST /api/spaces/{spaceId}/members {"user_id": "uuid", "role": "editor"} GET /api/spaces/{spaceId}/members PUT /api/spaces/{spaceId}/members/{id} {"role": "admin"} DELETE /api/spaces/{spaceId}/members/{id} ``` --- ## Space Tokens A **space-scoped token** is an API credential that grants access to exactly **one space**, limited by its `permission`: `read_only`, `propose` or `direct_edit` (editor-level). See "Proposed changes, context collections, and page reviews" at the end of this file for what each permits. Use it to let an AI agent work in one space while keeping every other space private — you simply never mint a token for the private spaces. A space token is sent with the same header as an account token: `Authorization: Token `. It acts with the identity of the user who created it, constrained to a single space. ### Manage space tokens Token-management endpoints require a JWT or **account** token — a space token cannot manage tokens. Authorized callers: workspace owner, space `admin`, or system admin. ``` POST /api/spaces/{spaceId}/tokens {"name": "Agent", "permission": "read_only", "expires_at": "2026-12-31T00:00:00Z"} — 201 {"token": {"id", "name", "permission", "space_id", "token": "", "expires_at", "created_at"}} GET /api/spaces/{spaceId}/tokens — 200 {"tokens": [...]} (no hashes) DELETE /api/spaces/{spaceId}/tokens/{tokenId} — 200 {"message": ...} ``` `permission` is optional and defaults to `direct_edit` over the API (the web form defaults to `read_only`). `expires_at` is optional and must be in the future. The raw token is revealed only in the create response and is never retrievable again. ### What a space token can do (within its space, with `direct_edit`) - List/create pages; get/update/delete a page; rename, reorder, version history, restore, ancestors. - Same-space page `move` (reparent / `display_order`). - Create/list comments; update/delete a comment. - Create/list/delete share links. - Get/update the space; list the space's members. ### What a space token is denied (HTTP 403, or 404 for unknown targets) - Any other space, and any page/comment outside its space. - Workspace, account (`regenerate-token`), admin, and user routes. - `promote-to-space`; moving a page **into or out of** the space (`move` with a different `space_id`); deleting the space; space member writes. - Socket.io real-time editing — space tokens are REST-only. `GET /api/auth/me` is the one self-describing exception — see above. --- ## Templates Pre-built page templates. ``` GET /api/templates — list all templates GET /api/templates/{slug} — get template by slug ``` Use the template content when creating a page. --- ## Image Uploads Attach screenshots and diagrams to your pages, so whoever reads the page later — human or agent — can see what you saw. ``` POST /api/spaces/{spaceId}/uploads Authorization: Token Content-Type: multipart/form-data Field: file (jpeg, png, gif, webp — max 5MB; SVG is rejected) Response 201: {"url": "/api/uploads/uuid.png", "id": "...", "filename": "uuid.png", "mime_type": "image/png", "size_bytes": 73540} ``` The multipart form field name is `file`. Embed the returned URL in your Markdown: `![alt](/api/uploads/uuid.png)` Uploads count against the workspace's **image storage quota** (Free 50 MB, Pro 5 GB). Accounts that have not yet activated (see Plans) have a quota of **0** — uploads are refused with `"activation_required": true` until the owner verifies their email. Over quota you get the standard `403` tier-limit body with `limit`, `current` and `upgrade_url` — free space by deleting images rather than retrying. ``` GET /api/workspaces/{id}/uploads — list images + {total_bytes, limit_bytes, tier} DELETE /api/uploads/{id} — delete an image (frees quota) ``` A workspace-scoped alias exists for callers that have no space handy: `POST /api/uploads?workspace_id={id}` (same body and response; account credentials only — space-scoped tokens must use the space route). Via MCP, use the `upload_image` tool instead: it takes `path` (stdio server only), `source_url`, or base64 `data`, and returns ready-to-paste Markdown. To *see* images already on a page, call `get_page` with `include_images: true` — without it you get the image URL as text, which you cannot view. --- ## Slug Resolution Resolve human-friendly URLs to IDs. ``` GET /api/resolve/{workspaceSlug} GET /api/resolve/{workspaceSlug}/{spaceSlug} GET /api/resolve/{workspaceSlug}/{spaceSlug}/{pageSlug} ``` --- ## Workspace Stats ``` GET /api/workspaces/{id}/stats Authorization: Token Response 200: {"stats": {"spaces": 2, "pages": 47, "members": 3, "webhooks": 1, "active_webhooks": 1, "pages_last_30d": 12, "pages_last_7d": 3, "edits_last_30d": 58, "comments": 9, "created_at": "ISO8601"}} ``` Space/page/member/webhook counts plus recent activity — useful for monitoring your workspace. --- ## Workspace Activity What changed, by whom, across the workspace — every page save (with agent provenance) and every comment, newest first. Owners see every live space; a member sees only the spaces they belong to. ``` GET /api/workspaces/{id}/activity?limit=50&cursor=&actor=agents Authorization: Token Response 200: {"items": [ {"id": "uuid", "kind": "edited", "created_at": "ISO8601", "version": 7, "edited_via": "api_token", "token_name": "deploy-bot", "is_agent": true, "author_id": "uuid", "author_name": "Jure", "page": {"id": "uuid", "title": "Runbook", "slug": "runbook"}, "space": {"id": "uuid", "name": "Ops", "slug": "ops"}, "excerpt": null}, {"id": "uuid", "kind": "comment", "created_at": "ISO8601", "version": null, "edited_via": null, "token_name": null, "is_agent": false, ..., "excerpt": "first 200 chars of the comment"} ], "next_cursor": "opaque string or null"} ``` `kind` is `created` (version 1), `edited`, or `comment`. `limit` is 1–200 (default 50); pass `next_cursor` back as `cursor` to page (it is opaque — do not construct one). `actor=agents` keeps only versions written via an API token, space token or OAuth grant (comments carry no provenance and are excluded). Trashed pages and spaces do not appear. --- ## Real-time Editing (Socket.IO) Connect with Socket.IO for live collaborative editing: ```javascript const socket = io('https://agentdocs.eu', { auth: { token: 'Token at_your_api_token' } }); // Join a page editing session socket.emit('page:open', { page_id: 'uuid' }, (response) => { console.log(response.content, response.version); }); // Submit a change socket.emit('page:change', { page_id: 'uuid', content: '# Updated content', version: currentVersion }, (response) => { if (response.conflict) { // Handle version conflict } }); // Listen for other editors' changes socket.on('page:changed', (data) => { console.log(data.content, data.version, data.author_name); }); ``` Events: `page:open`, `page:change`, `page:cursor`, `page:leave` Server events: `page:changed`, `page:user_joined`, `page:user_left` --- ## Rate Limits - Free tier: 10,000 API calls/month (enforced for API-token requests — an agent over the cap gets HTTP 403; upgrade to Pro to lift it) - Pro tier ($10/mo): 1,000,000 API calls/month - Per credential (your token): 300 requests per 15 minutes — check the `RateLimit-*` response headers - Per source IP (all credentials combined): 1,200 requests per 15 minutes ## Plans ### Before activation (new accounts) A new account has not yet verified an email address or paid, and gets a reduced grant until it does. You can read, write and search docs and use every MCP tool, but: - 1 space per workspace - 10 pages per space - 1 workspace member (no invites) - no webhooks - **no image uploads** — storage quota is 0 - 1K API calls/month A 403 from these limits carries `"activation_required": true` alongside the usual `error` / `message` / `limit` / `current` / `tier` / `upgrade_url` fields, and `tier` reads `unverified`. If you are an agent and hit one, the fix is not retrying or upgrading — ask the human to **verify their email address**, which unlocks the full Free tier below immediately. Paying also activates the account. ### Free ($0/mo, activated) - 1 workspace per account (owning a Pro workspace lifts this cap) - 2 spaces per workspace - 50 pages per space - 2 workspace members - 1 webhook - 10K API calls/month ### Pro (€10/mo) - Unlimited spaces, pages, members - Unlimited webhooks - 1M API calls/month - PDF export - Priority support - Also available quarterly (€30 / 3 months) and yearly (€100/yr, ~2 months free), by card or Lightning --- ## Error Codes - 400 — Bad request (validation error, or creating a page, space or workspace with a slug that is already taken) - 401 — Not authenticated - 403 — Access denied (not owner/member or insufficient role) - 404 — Resource not found - 409 — Conflict (e.g., a stale page `version`, or renaming a page to a slug already in use) - 413 — File too large - 429 — Rate limit exceeded - 500 — Internal server error --- More info: https://agentdocs.eu/docs Swagger UI: https://agentdocs.eu/api/docs Summary: https://agentdocs.eu/llms.txt ## Proposed changes, context collections, and page reviews Space tokens accept `permission: "read_only" | "propose" | "direct_edit"` when created at `POST /api/spaces/:spaceId/tokens`. The legacy API default is `direct_edit`; the web create form defaults to `read_only`. These are enforced server permissions. Read-only refuses all mutations. Propose-only allows page proposal submission/revision but refuses direct edits, deletes, comments, uploads, public sharing, and collection changes. Existing tokens retain direct editing. OAuth grants keep their existing documents scope; they are not implicitly converted into restricted space tokens. Hosted MCP adds these tools to the 19 base tools: | Tool | REST equivalent | |---|---| | `list_proposals(page)` | GET /api/pages/:pageId/proposals | | `propose_page_edit(page,title,content,rationale,base_version,reviewer_id?)` | POST /api/pages/:pageId/proposals | | `revise_page_proposal(page,proposal_id,title,content,rationale,base_version)` | POST /api/pages/:pageId/proposals/:proposalId/revise | | `list_context_collections(space?)` | GET /api/spaces/:spaceId/collections | | `get_context_collection(space?,collection_id,include_content?)` | GET /api/spaces/:spaceId/collections/:collectionId?include=content | | `create_context_collection(space?,name,purpose,pages)` | POST /api/spaces/:spaceId/collections | | `update_context_collection(space?,collection_id,name,purpose,pages)` | PUT /api/spaces/:spaceId/collections/:collectionId | | `get_page_knowledge(page)` | GET /api/pages/:pageId/knowledge | Page references support UUIDs or workspace/space/page paths; space references support UUIDs or workspace/space paths and may be omitted for a space token. Read the current page first. Submit its `version` as `base_version` and provide the complete proposed Markdown plus a rationale. The published page is unchanged. A reviewer defaults to the page owner or workspace owner if not supplied. Read `status`, `feedback`, and `revision` with list_proposals after review. It returns up to 100 proposals per page, open ones first, then the most recent completed reviews. A space holds at most 100 open (pending or changes-requested) proposals; a submission beyond that returns 400 until existing ones are reviewed or revised. Revise against the current page version after changes are requested or a base becomes stale. A revision requires a fresh review. Only a browser JWT may call `POST /api/pages/:pageId/proposals/:proposalId/review` with `{ "action": "approve" | "request_changes" | "reject", "revision": 1, "feedback": "..." }`. Feedback is required for request_changes/reject. Approval atomically checks the proposal revision and base page version, publishes one version with agent provenance, and records the approving person. A stale version returns 409 and publishes nothing. Agent credentials cannot approve. A person cannot approve their own browser-authored proposal; they can review their own agent's proposal. Collection `pages` is an ordered array of `{ "page_id": "uuid", "required": true }` (1–50 distinct pages in the same space). Saving records comparison versions, not frozen content. Reads return current versions, changed_since_saved, review metadata, byte count, and a rough character-based token estimate. `include=content` includes current Markdown only up to 2 MB in total; larger collections return metadata so callers can read individual pages. Moved or inaccessible pages are excluded. Collections never broaden permissions or create public links. Stable browser links use `/context/:spaceId/:collectionId`. Page knowledge: `GET /api/pages/:pageId/knowledge` returns owner, reviewed_at, reviewed_version, current_version, review_interval_days, and due_at. Browser editors set owner/reminders with PUT `{ "owner_id": "uuid" | null, "review_interval_days": 30 | null }` and mark the exact version reviewed with POST `/api/pages/:pageId/knowledge/review` `{ "version": 3 }`. Edits do not mark a page reviewed. Due reminders appear in the current owner's private inbox. Connection checks are browser/token-admin operations: GET `/api/spaces/:spaceId/tokens/:tokenId/verify/:pageId` reports a successful read of that page by that token. Credential creation or whoami is not proof of a page read. The web guide compares against a baseline and waits for a new read. Persistent invitations use the owner's browser JWT: POST `/api/workspaces/:workspaceId/invitations` with `{ "email": "...", "space_id": "uuid", "role": "viewer" | "editor" | "admin" }` saves a seven-day invitation and returns a one-time `accept_url`. The address is stored the way registration stores it (lowercase; Gmail dots and `+tags` removed), so the returned `email` may differ from the one sent. GET lists pending/accepted/ revoked/expired status without revealing registration state. POST `.../invitations/:invitationId/resend` rotates the link (one-minute cooldown); POST `.../revoke` invalidates it. Recipients register or sign in, verify the invited email, and POST `/api/invitations/accept` with `{ "token": "..." }` or `{ "invitation_id": "uuid" }`. Member limits are rechecked at acceptance; existing memberships keep their current role. GET `/api/invitations` lists invitations for the signed-in verified email. The legacy `/invite` route keeps its earlier compatibility behavior; new clients should use `/invitations`. Browser inbox: GET `/api/inbox`; PUT `/api/inbox/:id` `{ "read": true }`; PUT `/api/inbox/preferences` `{ "muted": true }`. Notifications cover mentions, replies, assigned reviews, review feedback, watched changes, and due reviews. Only currently accessible pages are listed. GET/PUT `/api/pages/:pageId/watch` manages `{ "watching": true }`. These personal/member-management actions are not available to OAuth or space tokens. The initial delivery channel is in-app.