# keyframe.set

> Adds or replaces a keyframe of one animated property of an item.

Source: https://stuarty.com/docs/mcp/tools/edit/keyframe.set/

Sets the value of x, y, scale, rotation, opacity, (clips and audio) volume, (clips) brightness, contrast, saturation, temperature, tint or hue, (items with a mask, set it first with clip.set_mask) mask_x, mask_y, mask_width, mask_height or mask_feather, or (clips) crop_left, crop_top, crop_right or crop_bottom at an absolute position inside the item, from its start to its end inclusive. When the property had no keyframe and at is after the start, its current static value becomes the first keyframe. The easing applies from this keyframe to the next. At most 100 keyframes per property.

## Arguments

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `at` | `string` | yes | Position on the project timeline, from the item start to its end inclusive. |
| `bezier` | array of `number` | no | X1, y1, x2, y2 of the curve of easing bezier: x1 and x2 from 0 to 1, y1 and y2 from -2 to 3.; at least 4 items; at most 4 items |
| `easing` | `linear`, `ease_in`, `ease_out`, `ease_in_out`, `hold`, `bezier` | no | From this keyframe to the next. Default linear. bezier needs the bezier argument. |
| `item_id` | `string` | yes | pattern `^itm_[0123456789abcdefghjkmnpqrstvwxyz]{10}$` |
| `property` | `string`, one of 21 values | yes |  |
| `value` | `number` | yes | Valid for the property: scale above 0 up to 20, opacity 0 to 1, volume 0 to 4. |

## Errors

- [`E_VALIDATION`](/docs/reference/error-codes#e_validation)
- [`E_INVALID_TIME`](/docs/reference/error-codes#e_invalid_time)
- [`E_NOT_FOUND`](/docs/reference/error-codes#e_not_found)
- [`E_TYPE_MISMATCH`](/docs/reference/error-codes#e_type_mismatch)
- [`E_LIMIT`](/docs/reference/error-codes#e_limit)
- [`E_INVALID_STATE`](/docs/reference/error-codes#e_invalid_state)

## Scope

Scope `edit`. The scope is the one an API key needs in network mode. Run `stuarty command:help keyframe.set` for the same description from the binary, or call the [`command_help`](/docs/mcp/tools/command_help) tool.

## Next steps

- [The edit tool](/docs/mcp/tools/edit)
- [Batches, revisions and idempotency](/docs/agents/batches)

**As an MCP call**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "edit",
    "arguments": {
      "project_id": "prj_7k2m9x4q1b",
      "base_revision": 12,
      "operations": [
        {
          "op": "keyframe.set",
          "args": {
            "at": "2s",
            "easing": "ease_out",
            "item_id": "itm_s6t7v8w9x0",
            "property": "scale",
            "value": 1.2
          }
        }
      ]
    }
  }
}
```

**As a batch file for the CLI**

```json
[
  {
    "op": "keyframe.set",
    "args": {
      "at": "2s",
      "easing": "ease_out",
      "item_id": "itm_s6t7v8w9x0",
      "property": "scale",
      "value": 1.2
    }
  }
]
```

```bash
stuarty edit --project prj_7k2m9x4q1b --ops batch.json --json
```

**Over HTTP**

```bash
curl -X POST "http://127.0.0.1:7878/api/v1/projects/prj_7k2m9x4q1b/edit" \
  -H "Authorization: Bearer $STUARTY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "base_revision": 12,
  "operations": [
    {
      "op": "keyframe.set",
      "args": {
        "at": "2s",
        "easing": "ease_out",
        "item_id": "itm_s6t7v8w9x0",
        "property": "scale",
        "value": 1.2
      }
    }
  ]
}'
```

The ids in the example are illustrative: read the real ones with `project_get`.
