Skip to main content

Summary

Create a new comment thread (or reply when parentCommentId is given). Accepts TextAddress / TextTarget anchors, or a TrackedChangeCommentTarget that names a logical tracked-change id. The tracked-change target accepts both the explicit kind form and the Labs-compatible trackedChangeId-only form; the adapter normalizes it to a Word-compatible content anchor on the requested revision side.
  • Operation ID: comments.create
  • API member path: editor.doc.comments.create(...)
  • Mutates document: yes
  • Idempotency: non-idempotent
  • Supports tracked mode: no
  • Supports dry run: no
  • Deterministic target resolution: yes

Expected result

Returns a Receipt with the new commentId in id and inserted on success; rejects whitespace-only bodies, unsupported anchor contexts, and cross-story targets. Tracked-change comment targets support insertion, deletion, replacement, and paired-move revisions; they fail with TARGET_NOT_FOUND for stale ids, CAPABILITY_UNAVAILABLE for formatting / structural revisions and unpaired move sides, and INVALID_TARGET for incompatible side requests or ambiguous replacement targets that omit a required side.

Input fields

FieldTypeRequiredDescription
parentCommentIdstringno
sideenumno"inserted", "deleted", "source", "destination"
storyStoryLocatornoStoryLocator
targetTextAddress | TextTarget | SelectionTarget | CommentTrackedChangeTarget | objectnoOne of: TextAddress, TextTarget, SelectionTarget, CommentTrackedChangeTarget, object
textstringyes
trackedChangeIdstringno

Example request

{
  "target": {
    "blockId": "block-abc123",
    "kind": "text",
    "range": {
      "end": 10,
      "start": 0
    },
    "story": {
      "kind": "story",
      "storyType": "body"
    }
  },
  "text": "Hello, world.",
  "trackedChangeId": "example"
}

Output fields

Variant 1 (success=true)

FieldTypeRequiredDescription
idstringyes
insertedEntityAddress[]no
removedEntityAddress[]no
successtrueyesConstant: true
updatedEntityAddress[]no

Variant 2 (success=false)

FieldTypeRequiredDescription
failureobjectyes
failure.codeenumyes"INVALID_INPUT", "INVALID_TARGET", "INVALID_CONTEXT", "TARGET_NOT_FOUND", "CAPABILITY_UNAVAILABLE"
failure.detailsanyno
failure.messagestringyes
successfalseyesConstant: false

Example response

{
  "id": "id-001",
  "inserted": [
    {
      "entityId": "entity-789",
      "entityType": "comment",
      "kind": "entity"
    }
  ],
  "success": true,
  "updated": [
    {
      "entityId": "entity-789",
      "entityType": "comment",
      "kind": "entity"
    }
  ]
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • CAPABILITY_UNAVAILABLE
  • INVALID_TARGET
  • INVALID_INPUT

Non-applied failure codes

  • INVALID_INPUT
  • INVALID_TARGET
  • INVALID_CONTEXT
  • TARGET_NOT_FOUND
  • CAPABILITY_UNAVAILABLE

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "parentCommentId": {
      "description": "Parent comment ID for creating a threaded reply.",
      "type": "string"
    },
    "side": {
      "description": "Optional side for the top-level trackedChangeId shorthand.",
      "enum": [
        "inserted",
        "deleted",
        "source",
        "destination"
      ]
    },
    "story": {
      "$ref": "#/$defs/StoryLocator",
      "description": "Optional story for the top-level trackedChangeId shorthand."
    },
    "target": {
      "description": "Text range to anchor the comment. Accepts either a single-block TextAddress {kind:'text', blockId, range}, a multi-segment TextTarget {kind:'text', segments:[{blockId, range}, ...]} for selections that span blocks, a SelectionTarget {kind:'selection', start, end} returned by query.match, a TextSearchCommentTarget {text, story?}, or a TrackedChangeCommentTarget ({kind:'trackedChange', trackedChangeId, side?} or {trackedChangeId, side?}) that names a logical tracked-change id as a convenience anchor .",
      "oneOf": [
        {
          "$ref": "#/$defs/TextAddress"
        },
        {
          "$ref": "#/$defs/TextTarget"
        },
        {
          "$ref": "#/$defs/SelectionTarget"
        },
        {
          "$ref": "#/$defs/CommentTrackedChangeTarget"
        },
        {
          "additionalProperties": false,
          "properties": {
            "story": {
              "$ref": "#/$defs/StoryLocator"
            },
            "text": {
              "description": "Text to find and anchor the comment to. The adapter resolves the first body/story match.",
              "type": "string"
            }
          },
          "required": [
            "text"
          ],
          "type": "object"
        }
      ]
    },
    "text": {
      "description": "Comment text content.",
      "type": "string"
    },
    "trackedChangeId": {
      "description": "Compatibility shorthand for target: { trackedChangeId }. Used only when target is omitted.",
      "type": "string"
    }
  },
  "required": [
    "text"
  ],
  "type": "object"
}
{
  "oneOf": [
    {
      "$ref": "#/$defs/CommentsCreateSuccess"
    },
    {
      "additionalProperties": false,
      "properties": {
        "failure": {
          "additionalProperties": false,
          "properties": {
            "code": {
              "enum": [
                "INVALID_INPUT",
                "INVALID_TARGET",
                "INVALID_CONTEXT",
                "TARGET_NOT_FOUND",
                "CAPABILITY_UNAVAILABLE"
              ]
            },
            "details": {},
            "message": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object"
        },
        "success": {
          "const": false
        }
      },
      "required": [
        "success",
        "failure"
      ],
      "type": "object"
    }
  ]
}
{
  "$ref": "#/$defs/CommentsCreateSuccess"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "INVALID_INPUT",
            "INVALID_TARGET",
            "INVALID_CONTEXT",
            "TARGET_NOT_FOUND",
            "CAPABILITY_UNAVAILABLE"
          ]
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}