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

Summary

Insert a new named bookmark at a target location.
  • Operation ID: bookmarks.insert
  • API member path: editor.doc.bookmarks.insert(...)
  • Mutates document: yes
  • Idempotency: non-idempotent
  • Supports tracked mode: no
  • Supports dry run: no
  • Deterministic target resolution: yes

Expected result

Returns a BookmarkMutationResult indicating success with the bookmark address or a failure.

Input fields

FieldTypeRequiredDescription
atTextTargetyesTextTarget
at.kind"text"yesConstant: "text"
at.segmentsTextSegment[]yes
namestringyes
tableColumnobjectno
tableColumn.colFirstintegerno
tableColumn.colLastintegerno

Example request

{
  "at": {
    "kind": "text",
    "segments": [
      {
        "blockId": "block-abc123",
        "range": {
          "end": 10,
          "start": 0
        }
      }
    ]
  },
  "name": "example",
  "tableColumn": {
    "colFirst": 1,
    "colLast": 1
  }
}

Output fields

Variant 1 (bookmark.kind=“entity”)

FieldTypeRequiredDescription
bookmarkobject(kind=“entity”)yes
bookmark.entityType"bookmark"yesConstant: "bookmark"
bookmark.kind"entity"yesConstant: "entity"
bookmark.namestringyes
successtrueyesConstant: true

Variant 2 (success=false)

FieldTypeRequiredDescription
failureobjectyes
failure.codestringyes
failure.detailsanyno
failure.messagestringyes
successfalseyesConstant: false

Example response

{
  "bookmark": {
    "entityType": "bookmark",
    "kind": "entity",
    "name": "example"
  },
  "success": true
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • INVALID_TARGET
  • INVALID_INPUT
  • CAPABILITY_UNAVAILABLE

Non-applied failure codes

  • None

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "at": {
      "$ref": "#/$defs/TextTarget"
    },
    "name": {
      "type": "string"
    },
    "tableColumn": {
      "additionalProperties": false,
      "properties": {
        "colFirst": {
          "type": "integer"
        },
        "colLast": {
          "type": "integer"
        }
      },
      "required": [
        "colFirst",
        "colLast"
      ],
      "type": "object"
    }
  },
  "required": [
    "name",
    "at"
  ],
  "type": "object"
}
{
  "oneOf": [
    {
      "additionalProperties": false,
      "properties": {
        "bookmark": {
          "additionalProperties": false,
          "properties": {
            "entityType": {
              "const": "bookmark"
            },
            "kind": {
              "const": "entity"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "kind",
            "entityType",
            "name"
          ],
          "type": "object"
        },
        "success": {
          "const": true
        }
      },
      "required": [
        "success",
        "bookmark"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "properties": {
        "failure": {
          "additionalProperties": false,
          "properties": {
            "code": {
              "type": "string"
            },
            "details": {},
            "message": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object"
        },
        "success": {
          "const": false
        }
      },
      "required": [
        "success",
        "failure"
      ],
      "type": "object"
    }
  ]
}
{
  "additionalProperties": false,
  "properties": {
    "bookmark": {
      "additionalProperties": false,
      "properties": {
        "entityType": {
          "const": "bookmark"
        },
        "kind": {
          "const": "entity"
        },
        "name": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "entityType",
        "name"
      ],
      "type": "object"
    },
    "success": {
      "const": true
    }
  },
  "required": [
    "success",
    "bookmark"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}