# Move an agent's work to another machine and/or switch its model.

> One mechanism for a Mac to Boat handoff, a Boat to Mac handoff and a model, connection or harness switch.
> https://koi.dog/docs/api/agents/move-agent/

`POST /api/v1/agents/{id}/move` · Scope: `crews`

The same agent continues; no second agent is created. A working agent keeps working while its work (uncommitted changes too) is copied onto the task branch; then its turn is stopped at a safe point, what it left is saved, and its next run continues from that commit and is told it is taking over. `target` defaults to `{"kind": "stay"}` (a switch only); `connectionId`, `model` and `options` default to the agent's own. A move to the cloud goes through the planner like a launch: it reserves budget, honours the crew's and the install's caps and the start gates, and may start a VM. Follow it with `agent.move` events or `GET /agents/{id}/moves`. When an API key calls it, the timeline records who did what and the outcome. No query parameters.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The agent's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Makes a retry safe: the same key with the same request returns the first answer and does nothing else. |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `target` | `object` | no | Where the work goes. Default: stay on the machine it is on (a model or harness switch). Default `{"kind":"stay"}`. |
| `target.kind` | `enum` | yes | `stay` on the machine it is on, `cloud`, or `node` with `nodeId`. |
| `target.nodeId` | `string` | no | The machine to move to. At least 5 characters. With `kind` `node`. |
| `connectionId` | `string` | no | Another model connection (its harness comes with it). Default: the agent's own. At least 5 characters. |
| `model` | `string` | no | Model on that connection. Default: the agent's model when the connection is unchanged, else the connection's default. At least 1 character. |
| `options` | `object` | no | Per-run settings chosen alongside a model. Unset means the harness's own default. |
| `options.effort` | `enum` | no | How much reasoning the model spends, where its harness lets you choose. Left out, the harness's default. One of `low`, `medium`, `high`, `xhigh`, `max`. |

## Response.

200 OK: a JSON object. The example has placeholder values.

- **409 conflict**: Refused with `409 conflict` and the reason, changing nothing, when the agent or the target cannot do it now (read `GET /agents/{id}/move-options` first).
- **422 validation_failed**: The body does not match its schema; each problem is in `details`.

## Request.

```sh
curl -X POST "https://app.koi.dog/api/v1/agents/$ID/move" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{
      "target": {
        "kind": "cloud"
      }
    }'
```

```js
const res = await fetch(`https://app.koi.dog/api/v1/agents/${process.env.ID}/move`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    target: {
      kind: "cloud",
    },
  }),
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    f"https://app.koi.dog/api/v1/agents/{os.environ['ID']}/move",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "target": {
            "kind": "cloud",
        },
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "agent": {
    "id": "string",
    "crewId": "string",
    "taskId": "string",
    "role": "manager",
    "connectionId": "string",
    "harness": "claude-code",
    …
  },
  "move": {
    "id": "string",
    "agentId": "string",
    "crewId": "string",
    "state": "capturing",
    "reason": "string",
    "target": { … },
    …
  }
}
```
