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

Summary

Create a new list from one or more paragraphs, or convert existing paragraphs into a new list.
  • Operation ID: lists.create
  • API member path: editor.doc.lists.create(...)
  • Mutates document: yes
  • Idempotency: non-idempotent
  • Supports tracked mode: no
  • Supports dry run: yes
  • Deterministic target resolution: yes

Expected result

Returns a ListsCreateResult with the new listId and the first item address.

Input fields

FieldTypeRequiredDescription
atBlockAddressnoBlockAddress
at.kind"block"noConstant: "block"
at.nodeIdstringno
at.nodeType"paragraph"noConstant: "paragraph"
kindenumyes"ordered", "bullet"
levelintegerno
modeenumyes"empty", "fromParagraphs"
targetBlockAddressOrRangenoBlockAddressOrRange

Example request

{
  "at": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "paragraph"
  },
  "kind": "ordered",
  "mode": "empty",
  "target": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "paragraph"
  }
}

Output fields

Variant 1 (item.kind=“block”)

FieldTypeRequiredDescription
itemListItemAddressyesListItemAddress
item.kind"block"yesConstant: "block"
item.nodeIdstringyes
item.nodeType"listItem"yesConstant: "listItem"
listIdstringyes
successtrueyesConstant: true

Variant 2 (success=false)

FieldTypeRequiredDescription
failureobjectyes
failure.codeenumyes"INVALID_TARGET", "LEVEL_OUT_OF_RANGE"
failure.detailsanyno
failure.messagestringyes
successfalseyesConstant: false

Example response

{
  "item": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "listItem"
  },
  "listId": "example",
  "success": true
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • CAPABILITY_UNAVAILABLE
  • INVALID_TARGET

Non-applied failure codes

  • INVALID_TARGET
  • LEVEL_OUT_OF_RANGE

Raw schemas

{
  "additionalProperties": false,
  "else": {
    "required": [
      "mode",
      "kind",
      "target"
    ]
  },
  "if": {
    "properties": {
      "mode": {
        "const": "empty"
      }
    }
  },
  "properties": {
    "at": {
      "$ref": "#/$defs/BlockAddress"
    },
    "kind": {
      "enum": [
        "ordered",
        "bullet"
      ]
    },
    "level": {
      "maximum": 8,
      "minimum": 0,
      "type": "integer"
    },
    "mode": {
      "enum": [
        "empty",
        "fromParagraphs"
      ]
    },
    "target": {
      "$ref": "#/$defs/BlockAddressOrRange"
    }
  },
  "required": [
    "mode",
    "kind"
  ],
  "then": {
    "required": [
      "mode",
      "kind",
      "at"
    ]
  },
  "type": "object"
}
{
  "oneOf": [
    {
      "additionalProperties": false,
      "properties": {
        "item": {
          "$ref": "#/$defs/ListItemAddress"
        },
        "listId": {
          "type": "string"
        },
        "success": {
          "const": true
        }
      },
      "required": [
        "success",
        "listId",
        "item"
      ],
      "type": "object"
    },
    {
      "additionalProperties": false,
      "properties": {
        "failure": {
          "additionalProperties": false,
          "properties": {
            "code": {
              "enum": [
                "INVALID_TARGET",
                "LEVEL_OUT_OF_RANGE"
              ]
            },
            "details": {},
            "message": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "type": "object"
        },
        "success": {
          "const": false
        }
      },
      "required": [
        "success",
        "failure"
      ],
      "type": "object"
    }
  ]
}
{
  "additionalProperties": false,
  "properties": {
    "item": {
      "$ref": "#/$defs/ListItemAddress"
    },
    "listId": {
      "type": "string"
    },
    "success": {
      "const": true
    }
  },
  "required": [
    "success",
    "listId",
    "item"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "INVALID_TARGET",
            "LEVEL_OUT_OF_RANGE"
          ]
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}