Comments are v2 territory, end to end. There are two kinds, and they are separate APIs:
Footer comments — the thread at the bottom of a page.
Inline comments — anchored to a selection in the body.
ts
import { createV2Client } from 'confluence.js';const confluence = createV2Client({ host, auth });/** Confluence's own storage format — the one the editor round-trips without loss. */const storage = (html: string) => ({ representation: 'storage' as const, value: html });
An inline comment has to say what text it is attached to:
ts
await confluence.comment.createInlineComment({ pageId: '12345', body: storage('<p>Is this still true?</p>'), inlineCommentProperties: { textSelection: 'ships every Tuesday', textSelectionMatchCount: 1, textSelectionMatchIndex: 0, },});
textSelection must appear in the page body verbatim. textSelectionMatchCount is how many times it occurs and textSelectionMatchIndex which occurrence you mean — Confluence uses the pair to re-anchor the comment as the page changes.
Comments
Comments are v2 territory, end to end. There are two kinds, and they are separate APIs:
Footer comments
Read them back:
Replies
A reply is a footer comment with a
parentCommentId— passed instead ofpageId, since the parent already says where it lives:Inline comments
An inline comment has to say what text it is attached to:
textSelectionmust appear in the page body verbatim.textSelectionMatchCountis how many times it occurs andtextSelectionMatchIndexwhich occurrence you mean — Confluence uses the pair to re-anchor the comment as the page changes.danglingmeans the text it pointed at is gone. Filter server-side if you only care about live threads:Update
Like pages, an update is a new version, and you say which one you are creating:
Note the two different
bodys: the outer one is the request payload, the inner one is the comment text.Delete
WARNING
Deleting a comment is permanent — there is no trash for it, and a read afterwards is a 404.
Everywhere else comments live
Pages are not the only container: