Skip to main content
Alpha: Document API is currently alpha and subject to breaking changes.

Summary

  • Operation ID: insert
  • API member path: editor.doc.insert(...)
  • Mutates document: yes
  • Idempotency: non-idempotent
  • Supports tracked mode: yes
  • Supports dry run: yes
  • Deterministic target resolution: yes

Input fields

FieldTypeRequiredDescription
targetTextAddressnoTextAddress
textstringyes

Example request

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

Output fields

No fields.

Example response

{
  "inserted": [
    {
      "entityId": "entity-789",
      "entityType": "comment",
      "kind": "entity"
    }
  ],
  "resolution": {
    "range": {
      "from": 0,
      "to": 10
    },
    "requestedTarget": {
      "blockId": "block-abc123",
      "kind": "text",
      "range": {
        "end": 10,
        "start": 0
      }
    },
    "target": {
      "blockId": "block-abc123",
      "kind": "text",
      "range": {
        "end": 10,
        "start": 0
      }
    },
    "text": "Hello, world."
  },
  "success": true,
  "updated": [
    {
      "entityId": "entity-789",
      "entityType": "comment",
      "kind": "entity"
    }
  ]
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • CAPABILITY_UNAVAILABLE
  • INVALID_TARGET

Non-applied failure codes

  • INVALID_TARGET
  • NO_OP

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "target": {
      "$ref": "#/$defs/TextAddress"
    },
    "text": {
      "type": "string"
    }
  },
  "required": [
    "text"
  ],
  "type": "object"
}
{
  "oneOf": [
    {
      "$ref": "#/$defs/TextMutationSuccess"
    },
    {
      "additionalProperties": false,
      "properties": {
        "failure": {
          "additionalProperties": false,
          "properties": {
            "code": {
              "enum": [
                "INVALID_TARGET",
                "NO_OP"
              ]
            },
            "details": {},
            "message": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object"
        },
        "resolution": {
          "$ref": "#/$defs/TextMutationResolution"
        },
        "success": {
          "const": false
        }
      },
      "required": [
        "success",
        "failure",
        "resolution"
      ],
      "type": "object"
    }
  ]
}
{
  "$ref": "#/$defs/TextMutationSuccess"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "INVALID_TARGET",
            "NO_OP"
          ]
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "resolution": {
      "$ref": "#/$defs/TextMutationResolution"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure",
    "resolution"
  ],
  "type": "object"
}