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

Summary

Insert a new image at the target position.
  • Operation ID: create.image
  • API member path: editor.doc.create.image(...)
  • Mutates document: yes
  • Idempotency: non-idempotent
  • Supports tracked mode: no
  • Supports dry run: yes
  • Deterministic target resolution: yes

Expected result

Returns a CreateImageResult with the new image address.

Input fields

FieldTypeRequiredDescription
altstringno
atobject(kind=“documentStart”) \object(kind=“documentEnd”) \object(kind=“before”) \object(kind=“after”) \object(kind=“inParagraph”)noOne of: object(kind=“documentStart”), object(kind=“documentEnd”), object(kind=“before”), object(kind=“after”), object(kind=“inParagraph”)
sizeobjectno
size.heightnumberno
size.widthnumberno
srcstringyes
titlestringno

Example request

{
  "alt": "example",
  "src": "example",
  "title": "example"
}

Output fields

FieldTypeRequiredDescription
failureobjectno
imageobjectno
successbooleanno

Example response

{
  "image": {},
  "success": true
}

Pre-apply throws

  • TARGET_NOT_FOUND
  • INVALID_TARGET
  • CAPABILITY_UNAVAILABLE
  • INVALID_INPUT

Non-applied failure codes

  • INVALID_TARGET
  • INVALID_INPUT

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "alt": {
      "type": "string"
    },
    "at": {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "documentStart"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "documentEnd"
            }
          },
          "required": [
            "kind"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "before"
            },
            "target": {
              "$ref": "#/$defs/BlockNodeAddress"
            }
          },
          "required": [
            "kind",
            "target"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "after"
            },
            "target": {
              "$ref": "#/$defs/BlockNodeAddress"
            }
          },
          "required": [
            "kind",
            "target"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "const": "inParagraph"
            },
            "offset": {
              "type": "integer"
            },
            "target": {
              "$ref": "#/$defs/BlockNodeAddress"
            }
          },
          "required": [
            "kind",
            "target"
          ],
          "type": "object"
        }
      ]
    },
    "size": {
      "additionalProperties": false,
      "properties": {
        "height": {
          "type": "number"
        },
        "width": {
          "type": "number"
        }
      },
      "type": "object"
    },
    "src": {
      "type": "string"
    },
    "title": {
      "type": "string"
    }
  },
  "required": [
    "src"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "type": "object"
    },
    "image": {
      "type": "object"
    },
    "success": {
      "type": "boolean"
    }
  },
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "image": {
      "type": "object"
    },
    "success": {
      "const": true
    }
  },
  "required": [
    "success",
    "image"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "INVALID_TARGET",
            "INVALID_INPUT"
          ]
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}