# composition.create_from_selection

> Moves the selected items into a new timeline, as one composition clip.

Source: https://stuarty.com/docs/mcp/tools/edit/composition.create_from_selection/

Makes a new timeline of the project from the selected items (same tracks, same frame size and rate, starting at frame 0) and replaces them with one composition of it, on the top-most visual track of the selection, for the same frames. The inverse puts the items back; the new timeline stays in the project.

## Arguments

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | `string` | no | The id of the composition item.; pattern `^itm_[0123456789abcdefghjkmnpqrstvwxyz]{10}$` |
| `item_ids` | array of `string` | yes | The items to move, each once.; at least 1 items; at most 100 items |
| `name` | `string` | no | The name of the new timeline; default Composition.; min length 1; max length 120 |
| `timeline_id` | `string` | no | The id of the new timeline.; pattern `^prj_[0123456789abcdefghjkmnpqrstvwxyz]{10}$` |

## Errors

- [`E_VALIDATION`](/docs/reference/error-codes#e_validation)
- [`E_NOT_FOUND`](/docs/reference/error-codes#e_not_found)
- [`E_INVALID_STATE`](/docs/reference/error-codes#e_invalid_state)
- [`E_ID_EXISTS`](/docs/reference/error-codes#e_id_exists)
- [`E_OVERLAP`](/docs/reference/error-codes#e_overlap)
- [`E_LIMIT`](/docs/reference/error-codes#e_limit)

## Scope

Scope `edit`. The scope is the one an API key needs in network mode. Run `stuarty command:help composition.create_from_selection` 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": "composition.create_from_selection",
          "args": {
            "id": "itm_k1k2k3k4k5",
            "item_ids": [
              "itm_m1n2p3q4r5",
              "itm_c3d4e5f6g7"
            ],
            "name": "Intro",
            "timeline_id": "prj_a1b2c3d4e5"
          }
        }
      ]
    }
  }
}
```

**As a batch file for the CLI**

```json
[
  {
    "op": "composition.create_from_selection",
    "args": {
      "id": "itm_k1k2k3k4k5",
      "item_ids": [
        "itm_m1n2p3q4r5",
        "itm_c3d4e5f6g7"
      ],
      "name": "Intro",
      "timeline_id": "prj_a1b2c3d4e5"
    }
  }
]
```

```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": "composition.create_from_selection",
      "args": {
        "id": "itm_k1k2k3k4k5",
        "item_ids": [
          "itm_m1n2p3q4r5",
          "itm_c3d4e5f6g7"
        ],
        "name": "Intro",
        "timeline_id": "prj_a1b2c3d4e5"
      }
    }
  ]
}'
```

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