add_comment
Post a new comment on any target in a workspace: a row, a cell, a doc text range, an html element, an entire surface, or the workspace itself. Polymorphic target shape mirrors the REST POST /api/workspaces/:slug/comments. For threading, pass parentId to hang the new comment as a reply (the server flattens nested replies to single depth and auto-unresolves a resolved parent). Mentions are an array of { kind: 'user'|'agent', id, label } triples; the server validates each mention's access to the workspace before accepting. Fires comment.added (and comment.unresolved when a reply reopens a resolved parent). For replies to existing comments where you don't want to reconstruct the target, prefer reply_to_comment which derives the target from the parent. Editor or commenter role required.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | Comment body (plain text or markdown). 1-5000 chars. | |
| slug | Yes | The workspace slug ('my-workspace' or 'my-org/my-workspace'). | |
| target | Yes | Polymorphic target. Shapes: { type: 'row', rowId: '<cuid>' } { type: 'cell', rowId: '<cuid>', columnKey: '<key>' } { type: 'doc_range', surfaceSlug: '<slug>', anchor: { from: <number>, to: <number>, text: '<plain>' } } { type: 'html_element', surfaceSlug: '<slug>', anchor: { selector: '<css>', text?: '<plain>' } } { type: 'surface', surfaceSlug: '<slug>' } { type: 'workspace' } | |
| mentions | No | Optional `[{ kind, id, label }]` mentions. Each mention's principal must have workspace access. Fires inbox + email + webhook fan-out for newly-mentioned recipients only. | |
| parentId | No | Optional parent comment id. When passed, this comment becomes a reply in the thread. Nested replies flatten to single-depth (reply-to-reply re-points at the root). Re-opens a resolved parent. |