Skip to content

ADD_MASK_KEYFRAMES API Documentation ​

🌐 Language Switch ​

中文版 | English

Interface Information ​

POST /openapi/capcut-mate/v1/add_mask_keyframes

Function Description ​

Add mask keyframes to video segments that already have a mask. Keyframes are written on the segment common_keyframes list and can animate position (X/Y), size (width/height), feather, and rotation. Units match add_masks: pixels for position and size, 0–100 for feather, degrees for rotation.

The segment must already have a mask from add_masks. This API does not create a mask and does not change the mask material's static config.

Request Parameters ​

json
{
  "draft_url": "https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/get_draft?draft_id=2025092811473036584258",
  "keyframes": [
    {"segment_id": "d62994b4-25fe-422a-a123-87ef05038558", "offset": 0, "X": 0, "Y": 0, "width": 540, "height": 540, "feather": 0, "rotation": 0},
    {"segment_id": "d62994b4-25fe-422a-a123-87ef05038558", "offset": 5000000, "X": -360, "Y": -200, "width": 1076, "height": 1071, "feather": 100, "rotation": 180}
  ]
}

Parameter Description ​

ParameterTypeRequiredDefaultDescription
draft_urlstring✅""Full URL of the target draft
keyframesarray✅[]Mask keyframe list

keyframes ​

FieldTypeRequiredDescription
segment_idstring✅Target video segment ID
offsetinteger✅Time offset from the segment start, in microseconds
Xnumber❌Mask center X in pixels, relative to material center, right is positive
Ynumber❌Mask center Y in pixels, relative to material center, down is positive
widthnumber❌Mask width in pixels
heightnumber❌Mask height in pixels
feathernumber❌Feather amount, 0–100
rotationnumber❌Rotation in degrees

X, Y, width, height, feather, and rotation are optional, but each item must include at least one of them. 0 is a valid value. For position or size animation, send both axes at the same offset. Sending only X writes the X-axis keyframe only; sending only width writes KFTypeMaskSizeX only.

Writing the same property at the same timestamp on the same segment overwrites the previous value.

Response ​

json
{
  "code": 0,
  "message": "success",
  "draft_url": "https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/get_draft?draft_id=2025092811473036584258",
  "keyframes_added": 12,
  "affected_segments": ["d62994b4-25fe-422a-a123-87ef05038558"]
}
FieldTypeDescription
draft_urlstringDraft URL
keyframes_addedintegerNumber of draft properties written (X/Y and width/height each count as 1)
affected_segmentsarraySegment IDs that received keyframes

Examples ​

Position keyframes ​

bash
curl -X POST https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/add_mask_keyframes \
  -H "Content-Type: application/json" \
  -d '{
    "draft_url": "YOUR_DRAFT_URL",
    "keyframes": [
      {"segment_id": "segment-id", "offset": 0, "X": 0, "Y": 0},
      {"segment_id": "segment-id", "offset": 5000000, "X": -360, "Y": -200}
    ]
  }'

Size keyframes ​

bash
curl -X POST https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/add_mask_keyframes \
  -H "Content-Type: application/json" \
  -d '{
    "draft_url": "YOUR_DRAFT_URL",
    "keyframes": [
      {"segment_id": "segment-id", "offset": 0, "width": 540, "height": 540},
      {"segment_id": "segment-id", "offset": 5000000, "width": 1076, "height": 1071}
    ]
  }'

Feather and rotation ​

bash
curl -X POST https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/add_mask_keyframes \
  -H "Content-Type: application/json" \
  -d '{
    "draft_url": "YOUR_DRAFT_URL",
    "keyframes": [
      {"segment_id": "segment-id", "offset": 0, "feather": 0, "rotation": 0},
      {"segment_id": "segment-id", "offset": 5000000, "feather": 100, "rotation": 180}
    ]
  }'

Error Codes ​

CodeMessageDescriptionSolution
2001Invalid draft URLDraft missing or not in cacheCheck draft_url
2015Segment not foundsegment_id does not existConfirm the segment ID
2016Invalid segment typeNot a video segmentCall this API only on video/image segments
2046Invalid mask keyframe informationMissing property, invalid feather, or bad formatCheck keyframes
2047No mask found on the segmentThe segment has no mask yetCall add_masks first
2048Mask keyframe addition failedFailed to save the draftRetry or contact support

Notes ​

  • Call Add Masks before adding mask keyframes.
  • Position conversion uses the material size (pixels / half material dimension), not the canvas size.
  • Size conversion uses the material size (width / material_width, height / material_height), matching the static mask config.
  • An offset beyond the segment duration is clamped to the end of the segment.
  • Round-corner keyframes are not supported.