# Move device to another project

Canonical page: https://docs.ovok.com/slim-apis/device/move-device-to-another-project

| Method | Path |
| --- | --- |
| `PUT` | `/v1/slim/device/assign/project` |

[Authentication](/authentication) · [Access policies](/access-policies)

Moves a device into another project in your project tree, and optionally places it in a location there.

**Auth:** bearer token. The caller must be a practitioner, an admin or a System Owner, and needs `Device:update`.
**Scope:** the device must be in the caller's project or one of its sub-projects. The target `projectId` must be your project, its parent or one of its sub-projects.

## Request [#request]

### Body [#body]

The body is strict: a field that is not listed here fails validation.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `deviceId` | `string (uuid)` | Yes | Id of the device to move. |
| `projectId` | `string (uuid)` | Yes | Id of the target project: your project, its parent or a sub-project. |
| `locationId` | `string (uuid)` | No | Location in the target project to place the device in. |

## Behaviour [#behaviour]

- The device's resident, location and zone are removed before the move, because those references belong to the old project.
- If a resident was assigned, their active out-of-bed episode is closed and their open device use record is ended, in the same write.
- When you send `locationId`, the device is placed in that location. The location must be in the target project.
- The move is written in one transaction. If it fails, nothing is written.
- Moving a device to the project it is already in still removes its resident, location and zone. Send `locationId` to place it in a location again.
- The response is `{ success, deviceId, projectId, locationId }`. `locationId` is `null` when you sent none.

## Example [#example]

```bash
curl -X PUT 'https://api.sandbox.ovok.com/v1/slim/device/assign/project' \
  -H "Authorization: Bearer ${OVOK_TOKEN}" \
  -H 'Content-Type: application/json' \
  -d '{"deviceId": "8c5e7a21-4b9d-4f36-a1c8-0d2e6b9f3a54", "projectId": "b7a3d915-6e20-4c8f-9a14-3d5f7b9c1e68"}'
```

## Successful response [#successful-response]

`200` — Device moved to the target project.

```json
{
  "success": true,
  "deviceId": "8c5e7a21-4b9d-4f36-a1c8-0d2e6b9f3a54",
  "projectId": "b7a3d915-6e20-4c8f-9a14-3d5f7b9c1e68",
  "locationId": null
}
```

| Field | Type | Description |
| --- | --- | --- |
| `success` | `boolean` | Always `true`. |
| `deviceId` | `string (uuid)` | Id of the device that was moved. |
| `projectId` | `string (uuid)` | Id of the project the device now belongs to. |
| `locationId` | `string (uuid) \| null` | Id of the location the device was placed in. `null` when you sent none. |

## Errors [#errors]

| Status | Meaning |
| --- | --- |
| [`401`](/errors/unauthenticated) | Bearer token is missing, invalid or expired. |
| [`403`](/errors/forbidden) | You are not a practitioner, admin or System Owner, you lack `Device:update`, your session has no project, the device is outside your project or sub-projects, the target project is outside your project tree, or the location is not in the target project. |
| [`404`](/errors/not-found) | No device with this `deviceId` exists. |
| [`409`](/errors/conflict) | The device's current project or the target project is moving to another Signals tenant. Retry when the move is done. |
| [`422`](/errors/validation-failed) | The body fails validation. |
