# caption.set_words

> Replaces the words of a caption.

Source: https://stuarty.com/docs/mcp/tools/edit/caption.set_words/

Replaces all words, given as words (1 to 60, times relative to the caption, as lengths) or as text, which is split on whitespace and spread over the caption's current duration like caption.add (duration may change it). With words the caption lasts until the end of the last word unless duration is given. Line breaks are cleared; keyframes are cut when the caption gets shorter.

## Arguments

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `duration` | `string` | no | A length. With words: at least the end of the last word, default that end. With text: default the current duration. |
| `item_id` | `string` | yes | A caption.; pattern `^itm_[0123456789abcdefghjkmnpqrstvwxyz]{10}$` |
| `text` | `string` | no | Text split on whitespace and spread over the duration; instead of words. |
| `words` | array of `object` | no | 1 to 60 words with times relative to the caption, as lengths. Or give text. |

## 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_INVALID_STATE`](/docs/reference/error-codes#e_invalid_state)
- [`E_LIMIT`](/docs/reference/error-codes#e_limit)
- [`E_OVERLAP`](/docs/reference/error-codes#e_overlap)

## Scope

Scope `edit`. The scope is the one an API key needs in network mode. Run `stuarty command:help caption.set_words` 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": "caption.set_words",
          "args": {
            "item_id": "itm_s6t7v8w9x0",
            "words": [
              {
                "duration": "12f",
                "start": "0f",
                "text": "Hello"
              },
              {
                "duration": "12f",
                "start": "12f",
                "text": "world"
              }
            ]
          }
        }
      ]
    }
  }
}
```

**As a batch file for the CLI**

```json
[
  {
    "op": "caption.set_words",
    "args": {
      "item_id": "itm_s6t7v8w9x0",
      "words": [
        {
          "duration": "12f",
          "start": "0f",
          "text": "Hello"
        },
        {
          "duration": "12f",
          "start": "12f",
          "text": "world"
        }
      ]
    }
  }
]
```

```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": "caption.set_words",
      "args": {
        "item_id": "itm_s6t7v8w9x0",
        "words": [
          {
            "duration": "12f",
            "start": "0f",
            "text": "Hello"
          },
          {
            "duration": "12f",
            "start": "12f",
            "text": "world"
          }
        ]
      }
    }
  ]
}'
```

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