- Qubitara Synapse
- Developer guide
- Pages and publishing by API
Pages and publishing by API
Everything the editor does, a script can do. A session or an API key with pages:write (and spaces:read to find the space) is enough.
Find the space#
curl https://<host>/api/v1/projects -H "Authorization: Bearer <token>"Each project (space) has an id, a key and a name.
Create a page#
curl -X POST https://<host>/api/v1/projects/<projectId>/pages \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d '{
"title": "Deployment runbook",
"parentId": null,
"content": { "type": "doc", "content": [
{ "type": "heading", "attrs": { "level": 2 }, "content": [{ "type": "text", "text": "Before you start" }] },
{ "type": "paragraph", "content": [{ "type": "text", "text": "Check the release page." }] }
] }
}'content is a ProseMirror document — the editor's own format. The node types are the blocks the editor offers: paragraph, heading (attrs.level 1–6), bulletList / orderedList with listItem, taskList, codeBlock (attrs.language), blockquote, callout (attrs.variant: info, success, warning, danger), table / tableRow / tableHeader / tableCell, horizontalRule, and inline text with marks bold, italic, code, strike, link (attrs.href). Omit content for an empty page.
The answer is the page: id, title, slug, status (DRAFT), reference, updatedAt and more. parentId makes it a sub-page.
Read a page#
GET /pages/:id — the draft, with status, publishedPath, hasUnpublishedChanges, the available transitions, and can (what the caller may do). GET /pages/:id/children lists one level beneath it; GET /projects/:id/pages the root pages of a space.
Update a page#
curl -X PATCH https://<host>/api/v1/pages/<id> \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d '{ "title": "Deployment runbook", "content": { … }, "baseUpdatedAt": "<the updatedAt you read>" }'baseUpdatedAt is the page's updatedAt as you last read it. If somebody saved in between, the answer is 409 with code PAGE_CHANGED and nothing is overwritten — read again and merge, or POST /pages/:id/conflict-copy to keep yours as a separate copy.
Publish#
curl -X POST https://<host>/api/v1/pages/<id>/publish \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d '{ "changeSummary": "Added the rollback steps" }'Works from any state, including an already published page — that is how "Publish changes" works. The answer carries status: "PUBLISHED" and publishedPath. Other moves go through POST /pages/:id/transitions/:transition with one of submit_for_review, approve, request_changes, deprecate, republish, unpublish; GET /pages/:id lists which are currently allowed in transitions.
Organise#
POST /pages/:id/movewith{ "parentId": "<id or null>", "afterId": "<sibling id>" }or{ "first": true }.POST /pages/:id/duplicatewith optional{ "title", "projectId", "parentId", "withChildren" }.PATCH /pages/:id/ownerwith{ "ownerId" };POST /pages/:id/labelswith{ "labelId" }.POST /pages/:id/lockwith{ "reason" }andPOST /pages/:id/unlock.
Versions#
GET /pages/:id/versions— every version, newest first.POST /pages/:id/versionswith{ "changeSummary" }— save a version deliberately.GET /pages/:id/versions/:n/diff— the difference between version n and the current draft.POST /pages/:id/versions/:n/restore— make version n the draft.
Export#
GET /pages/:id/export?format=markdown or format=html, with withChildren=true for the whole tree. The answer is the file.
Trash#
POST /pages/:id/archive sends a page and its sub-pages to the trash; POST /pages/:id/restore brings it back; DELETE /pages/:id/purge removes it for good; GET /projects/:id/trash lists what is there.
Attachments#
Two steps, like the editor: POST /projects/:id/attachments/upload-url with { filename, mimeType, sizeBytes, pageId } answers with a short-lived uploadUrl to PUT the bytes to and the attachmentId; then POST /attachments/:id/finalize. Reading: GET /attachments/:id/download-url answers with a short-lived link, checked against the page's permissions every time.