# Migrate the Mux TypeScript SDK from Robots Beta to GA

Upgrade @mux/ts to version 16, where client.robots calls the Robots GA API, and choose which calls move to v1 now and which stay on the Beta API for the moment.

Version 16 of the [Mux TypeScript SDK](/docs/integrations/mux-typescript-sdk) (`@mux/ts`) makes the Robots GA API (v1) the default. `client.robots` now calls `/robots/v1`, and the Beta API (v0) has moved to `client.robotsV0`. This guide covers the SDK-specific steps. For field-by-field changes, see [Migrate Robots from Beta to GA](/docs/guides/robots-migrate-to-v1).

<Callout type="info" title="Migrate with your coding agent">
  Paste this prompt into your agent to review your integration, apply the relevant changes, and test the migration.

  <div />
</Callout>

<Callout type="warning" title="Upgraded code can compile and still change behavior">
  Many Robots calls written for version 15 still compile against version 16, but now send requests to v1. Ask Questions, for example, has the same request shape in both versions. Review every `client.robots` call after upgrading: either move it to `client.robotsV0` to stay on the Beta API for now, or update it for v1.
</Callout>

## Before you upgrade

* **Switch from `@mux/mux-node` to `@mux/ts`.** `@mux/mux-node` was renamed, and 15.5.0 is its final release. Replace the dependency and update your imports:

  ```bash
  npm uninstall @mux/mux-node && npm install @mux/ts
  ```

  ```diff
  - import Mux from '@mux/mux-node';
  + import Mux from '@mux/ts';
  ```

* **Accept the Robots terms in the Mux Dashboard.** Without them, v1 requests return `403`.

* **Update and deploy your webhook handlers** so they accept both v0 and v1 events. See [Migrate Robots webhooks from Beta to GA](/docs/guides/robots-migrate-webhooks-to-v1).

## Upgrade to version 16

```bash
npm install @mux/ts@^16
```

Version 16 has other breaking changes outside Robots, such as the removal of `client.data.realTime`. See the SDK's [migration guide](https://github.com/muxinc/mux-ts/blob/main/MIGRATION.md#migrating-from-v15-to-v16) for the full list.

## Choose v0 or v1 for each call

For each Robots call, either keep it on the Beta API for now or move it to v1.

**Stay on the Beta API:** switch to `client.robotsV0`. Its methods are deprecated, and each one points to its v1 replacement. Beta types keep their version 15 names under `Mux.RobotsV0`; for example, `Mux.Robots.WorkflowBinding` becomes `Mux.RobotsV0.WorkflowBinding`.

```diff
- await mux.robots.jobs.summarize.create({ parameters: { asset_id } });
+ await mux.robotsV0.jobs.summarize.create({ parameters: { asset_id } });
```

**Move to v1:** keep `client.robots` and update the request and response fields. For example, Find Key Moments durations change from milliseconds to seconds:

```diff
  await mux.robots.jobs.findKeyMoments.create({
    parameters: {
      asset_id,
-     target_duration_ms: { min: 15000, max: 45000 },
+     target_duration: { min: 15, max: 45 },
    },
  });
```

Renaming `target_duration_ms` to `target_duration` without converting the values asks for durations 1,000 times longer.

Existing jobs and Directives keep the API version used to create them. Read and cancel v0 jobs through `client.robotsV0`, and v1 jobs through `client.robots`.

## Update code that moves to v1

The [API migration guide](/docs/guides/robots-migrate-to-v1) lists every field change. In summary:

* **Times are in seconds:** every millisecond field on requests and responses becomes a seconds field, and fractional seconds are allowed.
* **Renamed and removed fields:** for example, `to_language_code` becomes `output_language_code`, `uploaded_track_id` becomes `track_id`, and `replaced_tracks` becomes `replaced_track_ids`.
* **Workflows:** Find Scenes has no v1 equivalent; use [Analyze Structure](/docs/guides/robots-analyze-structure) instead.
* **Directives:** `workflows` becomes `bindings`, and each binding's `params` becomes `parameters`. `directives.list()` now returns summaries; retrieve a Directive for its full configuration. See [Migrate Robots Directives from Beta to GA](/docs/guides/robots-migrate-directives-to-v1).

Some SDK types are renamed for v1 too:

| Version 15 | Version 16 |
| :-- | :-- |
| `WorkflowBinding` | `DirectiveBinding` |
| `TrackResourceDeclaration` | `DirectiveTrackResource` |
| `ShotsResourceDeclaration` | `DirectiveShotsResource` |
| `NodeState` | `DirectiveNodeState` |
| `DirectiveRunDetail` | `DirectiveRun` |

In version 15, `Mux.Robots.DirectiveRun` was the response from creating a run. In version 16, the same name is the full run, which creating a run now returns.

## Update webhook types

v1 jobs and Directive runs send `robots.v1.job.<workflow>.<status>` and `robots.v1.directive_run.<status>` events, typed with payload types such as `WebhookSummarizeJob` and `WebhookDirectiveRun`. Beta events keep their names, and their payload types gain a `V0` suffix, such as `WebhookSummarizeJobV0`.

If you stay on v0, the Directive-run event types now describe the run itself in `data`, which is what Mux delivers, instead of a `directive_run` wrapper.

## Migration checklist

* \[ ] The dependency is `@mux/ts` version 16, with no `@mux/mux-node` imports left.
* \[ ] Every `client.robots` call is either on `client.robotsV0` deliberately or updated for v1.
* \[ ] v1 request builders and response parsers use seconds and the renamed fields.
* \[ ] Imports of renamed Directive types are updated.
* \[ ] Webhook handlers accept both v0 and v1 events and use the matching payload types.
* \[ ] Non-Robots breaking changes in the SDK's migration guide are handled.
