Spaces and pages (API)
In Docs, a space holds a tree of pages. A page’s text lives in versions: you create the page (title and place in the tree), then publish content into it, and every publish adds a new version. Integrations use this for reports that update themselves — a nightly KPI page, a weekly sales summary, a price list exported from the ERP.
Scope: reading needs docs:read; writing needs docs:write. Creating a page, publishing into it and publishing an interactive HTML page’s raw HTML also work with the script scope doc:create. Space and page permissions still apply: you can only write where your space role lets you edit.
Examples use the space OPS (5a7c9e1b-3d5f-4a8c-b2e4-6f8a1c3e5d79) in acme.sofiaspace.uz.
List spaces
Section titled “List spaces”GET /api/v1/orgs/{orgId}/spaces — Scope: docs:read.
| Parameter | Meaning |
|---|---|
includeArchived |
true also returns archived spaces |
includeStats |
true fills pageCount, updatedAt, memberCount and memberPreviewUserIds |
curl https://acme.sofiaspace.uz/api/v1/orgs/6b1f0c3e-2a4d-4c55-9a51-0d3f6a1e7b20/spaces \ -H "Authorization: Bearer $SOFIA_TOKEN"{ "spaces": [ { "id": "5a7c9e1b-3d5f-4a8c-b2e4-6f8a1c3e5d79", "orgId": "6b1f0c3e-2a4d-4c55-9a51-0d3f6a1e7b20", "key": "OPS", "name": "Operations", "description": "How we run the office", "icon": null, "homepagePageId": "1b3d5f7a-9c2e-4a6b-8d0f-2a4c6e8b0d35", "createdBy": "2c9a7f41-5b3e-4d1a-8f20-7e6b5c4d3a21", "createdAt": "2026-03-05T10:00:00Z", "deletedAt": null, "canManage": true, "avatarVersion": null, "projectId": null, "sharedOnly": false, "pictureKind": "LETTER", "pictureColor": "teal", "pictureSymbol": "", "openTo": "MEMBERS", "defaultRole": "VIEWER", "myRole": "ADMIN", "pageCount": 0, "updatedAt": null, "memberCount": 0, "memberPreviewUserIds": [] } ]}myRole is your role in the space: ADMIN, EDITOR, COMMENTER or VIEWER (empty when you only see pages shared with you, sharedOnly: true). deletedAt is set on an archived space. projectId is the project the space is connected to, if any. pictureKind (LETTER, SYMBOL or UPLOAD), pictureColor and pictureSymbol describe the space’s picture.
Get a space
Section titled “Get a space”GET /api/v1/spaces/{spaceId} — Scope: docs:read. One space in the same shape.
Create a space
Section titled “Create a space”POST /api/v1/orgs/{orgId}/spaces — Scope: docs:write. Honours Idempotency-Key. Returns 201 and the space; you become its admin. Any member of the workspace may create a space.
| Field | Required | Meaning |
|---|---|---|
key |
yes | Short key, unique in the workspace, for example REPORTS |
name |
yes | Space name |
description |
no | Short description |
openTo |
no | MEMBERS (default: only people you add) or ORG (everyone in the workspace) |
defaultRole |
no | With ORG: what everyone gets — VIEWER (default), COMMENTER or EDITOR |
pictureKind |
no | LETTER (default: the key’s first letter) or SYMBOL |
pictureColor |
no | teal, blue, violet, orange, rose or moss |
pictureSymbol |
no | With SYMBOL: the icon’s name |
Errors: 409 ALREADY_EXISTS for a key in use; 409 ENTITLEMENT_DENIED at the plan’s space limit (3 on Free, 10 on Pro, 25 on Business); 429 over 30 new spaces an hour per person.
List the pages in a space
Section titled “List the pages in a space”GET /api/v1/spaces/{spaceId}/pages — Scope: docs:read. Every page you can open in the space, as a flat list ordered by position; build the tree from parentPageId.
{ "pages": [ { "id": "0e2c4a6f-8b1d-4e3a-9c5f-7a9b1d3f5e81", "spaceId": "5a7c9e1b-3d5f-4a8c-b2e4-6f8a1c3e5d79", "parentPageId": "1b3d5f7a-9c2e-4a6b-8d0f-2a4c6e8b0d35", "title": "Sales KPI — November 2026", "position": 3.0, "currentVersionId": "2c4e6a8b-0d1f-4a3c-9e5b-7d9f1b3d5a46", "createdBy": "2c9a7f41-5b3e-4d1a-8f20-7e6b5c4d3a21", "createdAt": "2026-11-01T02:00:00Z", "updatedAt": "2026-11-14T02:00:00Z", "hasRestrictions": false, "kind": "RICH_TEXT", "projectId": null, "editMode": "DRAFT" } ]}kind is RICH_TEXT or HTML (interactive HTML page). parentPageId is null for top-level pages.
Get a page
Section titled “Get a page”GET /api/v1/pages/{pageId} — Scope: docs:read. The page in the shape above, without its content. editMode is DRAFT (people edit a draft and publish it) or LIVE (edits go straight to the page); see Publish content into a page for what publishing does to each.
Read a page’s content
Section titled “Read a page’s content”GET /api/v1/pages/{pageId}/content — Scope: docs:read. Optional locale (for example ru) reads a language version; without it, the original.
{ "pageId": "0e2c4a6f-8b1d-4e3a-9c5f-7a9b1d3f5e81", "hasContent": true, "currentVersionId": "2c4e6a8b-0d1f-4a3c-9e5b-7d9f1b3d5a46", "currentVersionNumber": 14, "content": "{\"type\":\"doc\",\"content\":[{\"type\":\"heading\",\"attrs\":{\"level\":2},\"content\":[{\"type\":\"text\",\"text\":\"Sales this month\"}]}]}", "hasNewerDraft": false, "kind": "RICH_TEXT", "locale": "", "sourceVersionNumber": 0}content is the published document as a string (format). hasContent is false for a page nobody has published yet.
Create a page
Section titled “Create a page”POST /api/v1/spaces/{spaceId}/pages — Scope: docs:write or doc:create. Honours Idempotency-Key. Returns 201 and the page — empty, until you publish into it.
| Field | Required | Meaning |
|---|---|---|
title |
yes | Page title, up to 500 characters. For an HTML page it may be blank: the file’s own <title> is used |
parentPageId |
no | Put it under this page; leave out for the top level |
kind |
no | RICH_TEXT (default) or HTML for an interactive HTML page |
htmlFileId |
with HTML |
Your confirmed upload of the HTML file; it becomes version 1. Needs docs:write |
versionNote |
no | With HTML: a note for version 1 |
You need the Editor role in the space — or, for a page under parentPageId, edit rights on that page.
curl -X POST https://acme.sofiaspace.uz/api/v1/spaces/5a7c9e1b-3d5f-4a8c-b2e4-6f8a1c3e5d79/pages \ -H "Authorization: Bearer $SOFIA_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: kpi-page-2026-12" \ -d '{"title":"Sales KPI — December 2026","parentPageId":"1b3d5f7a-9c2e-4a6b-8d0f-2a4c6e8b0d35"}'Errors: 403 without edit rights; 402 SUSPENDED when the workspace is read-only; 429 over 60 new pages a minute per person.
Publish content into a page
Section titled “Publish content into a page”POST /api/v1/pages/{pageId}/publish — Scope: docs:write or doc:create. Returns the new version.
| Field | Required | Meaning |
|---|---|---|
content |
yes | The whole page as a rich-text document string (format) |
baseVersionNumber |
no | The version your text is based on. If someone published since, you get 409 PAGE_CHANGED_SINCE_DRAFT instead of overwriting their change |
Query parameter locale (for example ru) publishes into a language version instead of the original.
curl -X POST https://acme.sofiaspace.uz/api/v1/pages/0e2c4a6f-8b1d-4e3a-9c5f-7a9b1d3f5e81/publish \ -H "Authorization: Bearer $SOFIA_TOKEN" \ -H "Content-Type: application/json" \ -d '{"content":"{\"type\":\"doc\",\"content\":[{\"type\":\"heading\",\"attrs\":{\"level\":2},\"content\":[{\"type\":\"text\",\"text\":\"Sales this month\"}]},{\"type\":\"paragraph\",\"content\":[{\"type\":\"text\",\"text\":\"Revenue: 1 240 000 000 so‘m (plan 1 100 000 000).\"}]}]}"}'{ "id": "3d5f7a9c-1e2b-4d4f-8a6c-8e0b2d4f6a57", "pageId": "0e2c4a6f-8b1d-4e3a-9c5f-7a9b1d3f5e81", "versionNumber": 15, "content": "{\"type\":\"doc\", ...}", "createdBy": "2c9a7f41-5b3e-4d1a-8f20-7e6b5c4d3a21", "createdAt": "2026-11-14T02:00:05Z", "htmlSha256": "", "htmlSizeBytes": 0, "versionNote": "", "locale": "", "sourceVersionNumber": 0}- Each publish replaces what readers see and keeps the old text in version history. Nothing is lost.
- On a
LIVEpage,baseVersionNumberis ignored: the publish becomes what everyone is editing right away. - With an AI-scope token, publishing also closes any open editing session on the page, so people editing it switch to the new version; what they hadn’t saved isn’t merged in.
- You can only publish into a rich-text page; an interactive HTML page (
kind: HTML) refuses with409. For those, see Publish a new version of an interactive HTML page. - Building the document string by hand is error-prone: build it as an object in your language, then serialize it to JSON twice — once for the
contentstring, once for the request body. See the Python example in Integration examples.
Publish a new version of an interactive HTML page
Section titled “Publish a new version of an interactive HTML page”An interactive HTML page (kind: HTML) shows one HTML file. A build job — for example CI that regenerates a dashboard or a report — can publish a new file as the page’s next version. Every version is kept in the page’s version history, and the page’s readers see the new one right away.
There are two ways. Both need edit rights on the page, and the page must already be an interactive page:
| Endpoint | Scope | Send |
|---|---|---|
PUT /api/v1/pages/{pageId}/html |
docs:write or doc:create |
The HTML itself as the request body. One call |
POST /api/v1/pages/{pageId}/html/versions |
docs:write |
The fileId of an HTML file you uploaded first |
Send the HTML in the body
Section titled “Send the HTML in the body”PUT /api/v1/pages/{pageId}/html — Scope: docs:write or doc:create. Returns the new version.
- The body is the whole HTML file, UTF-8 text, at most 5 MB.
Content-Typemust betext/html(for exampletext/html; charset=utf-8).- Optional header
X-Version-Note: a note about what changed, shown in version history. - Optional header
If-Match: the version ID your job expects to be current (fromcurrentVersionIdin Read a page’s content). If someone published since, you get409instead of overwriting their version. Quotes around the ID are allowed.
curl -X PUT https://acme.sofiaspace.uz/api/v1/pages/7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d42/html \ -H "Authorization: Bearer $SOFIA_TOKEN" \ -H "Content-Type: text/html; charset=utf-8" \ -H "X-Version-Note: Nightly build 2026-11-25" \ -H "If-Match: 4e6a8c0b-2d4f-4b6a-9c8e-0a2c4e6b8d13" \ --data-binary @dist/report.html{ "id": "5f7b9d1c-3e5a-4c7b-8d9f-1b3d5f7a9c24", "pageId": "7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d42", "versionNumber": 8, "sha256": "28eb2bd698097d10caa10931fa26e05b2afa5e2c2fdec83df7d292659dfec556", "sizeBytes": 48213, "versionNote": "Nightly build 2026-11-25"}Use --data-binary, not -d: -d drops line breaks. Keep the new id if you send If-Match next time.
Publish an uploaded file
Section titled “Publish an uploaded file”POST /api/v1/pages/{pageId}/html/versions — Scope: docs:write (not doc:create, which can’t upload files). Returns the new version in the shape above.
First upload the HTML file as in Files and attachments, with "mimeType": "text/html" and "module": "doc", and confirm it. Then:
| Field | Required | Meaning |
|---|---|---|
fileId |
yes | Your own confirmed upload, or a file that is already a version of this page (to bring an old version back) |
versionNote |
no | A note about what changed |
expectedCurrentVersionId |
no | Works like If-Match above |
curl -X POST https://acme.sofiaspace.uz/api/v1/pages/7b9d1f3a-5c7e-4a9b-8d1f-3a5c7e9b1d42/html/versions \ -H "Authorization: Bearer $SOFIA_TOKEN" \ -H "Content-Type: application/json" \ -d '{"fileId":"d4f6a8c1-3e5b-4d7f-9a1c-2e4f6b8d0a13","versionNote":"Q4 figures","expectedCurrentVersionId":"4e6a8c0b-2d4f-4b6a-9c8e-0a2c4e6b8d13"}'Errors for both
Section titled “Errors for both”| Status | Why |
|---|---|
400 |
A page ID, file ID or version ID that isn’t a UUID, or an empty body |
403 |
You can’t edit the page |
404 |
No such page, or you can’t open it |
409 |
The page isn’t an interactive page (it’s rich text), or another version was published since the one in If-Match / expectedCurrentVersionId |
413 |
The HTML is over 5 MB |
415 |
Not text/html, not valid UTF-8, doesn’t look like an HTML document, or (for fileId) a file someone else uploaded or one that isn’t confirmed |
Create a new interactive page
Section titled “Create a new interactive page”A doc:create token can’t create an interactive page: it can only publish new versions into one that exists. Create the page in the app (+ Page → Interactive page), then publish into it from your job. A docs:write token can create one with Create a page by sending "kind": "HTML" and "htmlFileId" (an uploaded HTML file, as above) instead of content.
Rename a page
Section titled “Rename a page”PUT /api/v1/pages/{pageId}/title — Scope: docs:write. Body {"title": "…"}. Doesn’t create a version.
Move a page
Section titled “Move a page”PUT /api/v1/pages/{pageId}/move — Scope: docs:write.
| Field | Meaning |
|---|---|
newParentPageId |
Leave out to keep the parent; "" to move to the top level; a page ID to move under it |
afterPageId, beforePageId |
Place it between these siblings; leave both out to put it last |
Error: 400 PAGE_MOVE_CYCLE.
Page comments
Section titled “Page comments”GET /api/v1/pages/{pageId}/comments — Scope: docs:read. All comments at once: {"comments": [ … ]}. Optional locale reads a language version’s comments.
POST /api/v1/pages/{pageId}/comments — Scope: docs:write. Returns 201 and the comment. Needs at least the Commenter role. Up to 40,000 characters of text; at most 60 comments a minute per person.
| Field | Required | Meaning |
|---|---|---|
content |
yes | Plain text or a rich-text document string |
parentCommentId |
no | Reply to this comment |
{ "id": "4e6a8c0d-2f3b-4e5d-9f7a-9a1c3e5f7b68", "pageId": "0e2c4a6f-8b1d-4e3a-9c5f-7a9b1d3f5e81", "authorId": "2c9a7f41-5b3e-4d1a-8f20-7e6b5c4d3a21", "content": "Numbers updated from the ERP at 07:00.", "parentCommentId": null, "createdAt": "2026-11-14T02:00:06Z", "editedAt": null, "deletedAt": null, "anchorMarkId": null, "anchorExcerpt": null, "locale": "", "via": { "kind": "pat", "name": "ERP sync" }}via names the AI app or token that wrote the comment for its author (null for one written in the app).
PUT /api/v1/comments/{commentId} — Scope: docs:write. Body {"content": "…"}; only the author can edit.
Post page-level comments through the API; anchorMarkId and anchorExcerpt belong to comments made on selected text in the editor.
Add a language version
Section titled “Add a language version”POST /api/v1/pages/{pageId}/locales — Scope: doc:create only (not docs:write). Returns 201.
| Field | Required | Meaning |
|---|---|---|
locale |
yes | Language code, for example ru, en, uz |
title |
no | The title in that language; empty copies the original’s |
baseLocale |
no | The original’s own language, if not set yet |
Errors: 400 for a malformed language code; 409 when the page already has that language.
Then publish with ?locale=ru. See Page languages.
Pages that link here
Section titled “Pages that link here”GET /api/v1/pages/{pageId}/backlinks — Scope: docs:read. Pages whose published content links to this one, most recently updated first, at most 100. Only pages you can open are listed; more is true when there are others beyond the 100.
{ "pages": [ { "pageId": "1b3d5f7a-9c2e-4a6b-8d0f-2a4c6e8b0d35", "title": "Operations home", "spaceKey": "OPS" } ], "more": false }What you can’t do with the API
Section titled “What you can’t do with the API”- You can’t delete a page with a token:
DELETE /api/v1/pages/{pageId}answers403with"error": "SIGNED_IN_APP_ONLY". It works only for AI apps you signed in to through the Sofia Space MCP server, and in the app. - You can’t delete a page comment with a token (
DELETE /api/v1/comments/{commentId}answers403 SIGNED_IN_APP_ONLY); delete it in the app. - You can’t remove a page attachment or get a file’s download link with a token (
403 SIGNED_IN_APP_ONLY); see Files and attachments. - With
doc:createonly, you can’t create an interactive HTML page or publish one from an uploaded file; you can onlyPUTthe HTML of an existing one. - You can’t delete or archive a space, restore an old version, or create a page from a template.
- You can’t save a private draft: publishing is the only way to write content.
- You can’t read version history, list a page’s languages, share a page, or change a space’s members.
- You can’t add a language version with
docs:write; onlydoc:createreaches it. - You can’t import a Word or Markdown file as a page through the API.