List devices
- Sandbox: available
- Staging: available
- Production: unknown
Lists the devices in your project with their zone, location and resident names. Use it for device directory and administration screens.
Auth: bearer token. The caller must be a practitioner, an admin or a System Owner, and needs Device:search and Device:read.
Scope: the caller's project (from the token).
Behaviour
- Every device in the project is listed, whether or not it has a location or resident.
idis the Device resource id.thingsboardIdis the device identifier that telemetry is keyed by.statusisactivewhen the device's live telemetry reports it active, otherwiseinactive.lastActivityTimeis the latest telemetry activity time, or the device's last-seen time when telemetry has none.searchmatches device, location and zone names.patientSearchmatches resident names. Both are case-insensitive substring matches.organizationId,locationId,patientIdandactivefilter on exact values.orderByisASCorDESCin any case, defaultASC. Rows with an empty sort value sort last inASCorder and first inDESCorder.pageis zero-based.countdefaults to 20, maximum 100.totalis the number of rows after filtering.- The device structure is cached for up to 5 minutes. Writes made through the Slim routes refresh it sooner.
- If the device list cannot be built and no earlier complete list exists, the route returns 503. Retry shortly.
Example
curl -X GET 'https://api.sandbox.ovok.com/v1/slim/device?page=0&count=20&sortBy=deviceName&orderBy=ASC' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk'bearerAuthorizationBearer <JWT>page?string"0"count?string"20"sortBy?string"deviceName""deviceName""locationName""patientName""organizationName""lastActivityTime""createdAt"orderBy?string"ASC""ASC""DESC"search?string1 <= lengthpatientSearch?string1 <= lengthorganizationId?string1 <= lengthlocationId?string1 <= lengthpatientId?string1 <= lengthactive?stringOne page of devices.
application/json- response
total*number0 <= valuepage*number0 <= valuecount*number1 <= valueresources*array<>curl -X GET 'https://api.sandbox.ovok.com/v1/slim/device'{ "total": 0, "page": 0, "count": 1, "resources": [ { "id": "string", "name": "string", "thingsboardId": "string", "status": "active", "organizationId": "string", "organizationName": "string", "locationId": "string", "locationName": "string", "patientId": "string", "patientName": "string", "lastActivityTime": "string", "createdAt": "string" } ]}Move device to another project PUT
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"}' ```
Create device POST
Creates a device in your project and, optionally, assigns it to a zone, a location and a resident in the same write. **Auth:** bearer token. The caller must be a practitioner, an admin or a System Owner, and needs `Device:create`. **Scope:** the device is created in the caller's project (from the token). ## Behaviour - `name` is stored, trimmed, as the device's user-friendly name and as its official device identifier. - A `name` whose serial a device of your project already holds is refused with 422, in any spelling: spaces around it or its `/`, other case, with or without the manufacturer prefix ingest gives the serial (`Sleepiz/30QD24001`, `sleepiz/30qd24001` and `30QD24001` hold one serial). Ingest finds a device by its serial, so one serial belongs to one device. - A `name` whose serial a device of another customer already holds is refused with 409, in the same spellings. Ingest routes readings by serial, and cannot tell two customers' devices with one serial apart. - `thingsboardId` is stored as a second identifier. When you omit it, Ovok generates a random UUID for it. - `organizationId`, `locationId` and `patientId` are optional. Each one you send is assigned in the same transaction as the create. If any part fails, nothing is written. - A device in a room is in the room's zone. An `organizationId` that differs from the zone of the device's room (the room you send, or the one it is in) answers 422 with `path: ["organizationId"]` and changes nothing: move the room to that zone, or the device to a room in it. A device with no room, or in a room with no zone, takes any zone. A zone change re-zones only the device, never its room, the room's other devices or a resident. - Assigning a resident moves them: the resident is removed from every other device they hold, and their active out-of-bed episode is closed. - Assigning a resident who is not active (`discharged`, `discharged-recent` or `archived`) is refused with 422 and nothing is created: reactivate them first. - The device starts with status `active`. - The create is recorded in the change history. - The response is the same as `GET /v1/slim/device/{id}` for the new device. ## Example ```bash curl -X POST 'https://api.sandbox.ovok.com/v1/slim/device' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \ -H 'Content-Type: application/json' \ -d '{"name": "Sleepiz/3001000", "locationId": "c3499c27-2973-0a7f-807e-fb8676a92dcb"}' ```