# Move device to another project

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

`PUT /v1/slim/device/assign/project`

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.

## 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 writes nothing and still succeeds.
- The response is `{ success, deviceId, projectId, locationId }`. `locationId` is `null` when you sent none.

## Example

```bash
curl -X PUT 'https://api.sandbox.ovok.com/v1/slim/device/assign/project' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{"deviceId": "c3499c27-2973-0a7f-807e-fb8676a92dcb", "projectId": "87ea5dfc-8b8e-384d-8489-79496e706390"}'
```
