# Control scenario run

> A simulation run and the virtual rooms and devices it created.

`POST https://api.cymatics.tech/v1/scenario-runs/{run}/control`

Scope: `simulation:write` · Test only

## Request

Send your key as `Authorization: Bearer cym_test_…`. Requires the `simulation:write` scope. Test mode only: live keys get 403 mode_mismatch.

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `run` (SDK and CLI: `run_id`) | path | `string` | Yes | Run id |
| `Idempotency-Key` | header | `string` | No | Replays the first response for an identical request within the project and mode. |

## Request body

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `action` | body | `pause \| resume \| stop \| advance` | Yes |  |
| `duration_ms` | body | `integer, ≥ 0` | No |  |

```json
{
  "action": "pause",
  "duration_ms": 60000
}
```

## Response

`200 · application/json`

```json
{
  "data": {
    "object": "scenario_run",
    "id": "run_01",
    "scenario_id": "bed_exit",
    "status": "running",
    "elapsed_ms": 0,
    "duration_ms": 60000,
    "speed": 1,
    "seed": 42,
    "rooms": [
      {
        "id": "room_bedroom"
      }
    ],
    "devices": [
      {
        "id": "dev_bedroom",
        "room_id": "room_bedroom"
      }
    ]
  },
  "meta": {
    "request_id": "req_01",
    "project_id": "proj_demo",
    "livemode": false,
    "generated_at": "2026-10-24T23:55:30.000Z"
  }
}
```

## Errors

| Status | Description |
| --- | --- |
| `429` | `rate_limit_exceeded`: Too many requests this minute for the key (or twice that across the project), or too many open streams for the project. Retry after the seconds in Retry-After.<br>`quota_exceeded`: A live key's project has used its monthly live-hour cap. There is no Retry-After. Don't retry; raise the live-hour cap in the dashboard. Headers: Retry-After, RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset. |
| `503` | `live_unavailable`: This operation has no live data for this project yet (for example, no paired Cymo covers it). Don't retry the same request; pair a Cymo that covers it, or build against a test key.<br>`service_unavailable`: A dependency, such as API key verification, is unreachable, or the project is busy with another write. Retry after the seconds in Retry-After, with backoff. |
| `4XX` | Invalid request, credential, permission or revision. |
| `default` | Error with a stable code and request ID. |

Every error is a `{ error, meta }` envelope with a stable `code`. See [Errors](https://docs.cymatics.tech/errors) for each code and whether to retry.

## Call it

**TypeScript · @cymos/sdk**

```ts
import { Cymo } from "@cymos/sdk";

const cymo = new Cymo({ apiKey: process.env.CYMO_API_KEY! });

const { data, meta } = await cymo.scenarioRuns.control({
  run_id: "run_01",
  action: "pause",
  duration_ms: 60000
});
```

**terminal · cymatics CLI**

```sh
$ cymatics scenario-runs control --run-id run_01 --input body.json --json
```

**curl**

```sh
curl -X POST "https://api.cymatics.tech/v1/scenario-runs/run_01/control" \
  -H "Authorization: Bearer $CYMO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"pause","duration_ms":60000}'
```

The SDK takes path parameters and body fields in one object. The CLI reads the body from `--input`, a JSON file or `-` for stdin.

**MCP tool**

```
control_scenario_run({
  run_id: "run_01",
  input: {
    action: "pause",
    duration_ms: 60000
  }
})
```

The MCP tool `control_scenario_run` calls this operation with your key. It takes the request body as `input`.
