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

Summary

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

Input fields

FieldTypeRequiredDescription
atomictrueyesConstant: true
changeModeenumyes"direct", "tracked"
expectedRevisionstringyes
stepsobject[]yes

Example request

{
  "atomic": true,
  "changeMode": "direct",
  "expectedRevision": "rev-001",
  "steps": [
    {}
  ]
}

Output fields

FieldTypeRequiredDescription
revisionobjectyes
stepsobject[]yes
successtrueyesConstant: true
timingobjectyes
trackedChangesobject[]no

Example response

{
  "revision": {
    "after": "example",
    "before": "example"
  },
  "steps": [
    {}
  ],
  "success": true,
  "timing": {
    "totalMs": 12.5
  },
  "trackedChanges": [
    {}
  ]
}

Pre-apply throws

  • REVISION_MISMATCH
  • MATCH_NOT_FOUND
  • AMBIGUOUS_MATCH
  • STYLE_CONFLICT
  • PRECONDITION_FAILED
  • INVALID_INPUT
  • CROSS_BLOCK_MATCH
  • SPAN_FRAGMENTED
  • TARGET_MOVED
  • PLAN_CONFLICT_OVERLAP
  • INVALID_STEP_COMBINATION
  • CAPABILITY_UNAVAILABLE

Non-applied failure codes

  • None

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "atomic": {
      "const": true
    },
    "changeMode": {
      "enum": [
        "direct",
        "tracked"
      ]
    },
    "expectedRevision": {
      "type": "string"
    },
    "steps": {
      "items": {
        "type": "object"
      },
      "type": "array"
    }
  },
  "required": [
    "expectedRevision",
    "atomic",
    "changeMode",
    "steps"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "revision": {
      "additionalProperties": false,
      "properties": {
        "after": {
          "type": "string"
        },
        "before": {
          "type": "string"
        }
      },
      "required": [
        "before",
        "after"
      ],
      "type": "object"
    },
    "steps": {
      "items": {
        "type": "object"
      },
      "type": "array"
    },
    "success": {
      "const": true
    },
    "timing": {
      "additionalProperties": false,
      "properties": {
        "totalMs": {
          "type": "number"
        }
      },
      "required": [
        "totalMs"
      ],
      "type": "object"
    },
    "trackedChanges": {
      "items": {
        "type": "object"
      },
      "type": "array"
    }
  },
  "required": [
    "success",
    "revision",
    "steps",
    "timing"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "revision": {
      "additionalProperties": false,
      "properties": {
        "after": {
          "type": "string"
        },
        "before": {
          "type": "string"
        }
      },
      "required": [
        "before",
        "after"
      ],
      "type": "object"
    },
    "steps": {
      "items": {
        "type": "object"
      },
      "type": "array"
    },
    "success": {
      "const": true
    },
    "timing": {
      "additionalProperties": false,
      "properties": {
        "totalMs": {
          "type": "number"
        }
      },
      "required": [
        "totalMs"
      ],
      "type": "object"
    }
  },
  "required": [
    "success",
    "revision",
    "steps",
    "timing"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "failure": {
      "additionalProperties": false,
      "properties": {
        "code": {
          "enum": [
            "REVISION_MISMATCH",
            "MATCH_NOT_FOUND",
            "AMBIGUOUS_MATCH",
            "STYLE_CONFLICT",
            "PRECONDITION_FAILED",
            "INVALID_INPUT",
            "CROSS_BLOCK_MATCH",
            "SPAN_FRAGMENTED",
            "TARGET_MOVED",
            "PLAN_CONFLICT_OVERLAP",
            "INVALID_STEP_COMBINATION",
            "CAPABILITY_UNAVAILABLE"
          ]
        },
        "details": {},
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "type": "object"
    },
    "success": {
      "const": false
    }
  },
  "required": [
    "success",
    "failure"
  ],
  "type": "object"
}