SlimSlim/Device

List devices

  • Sandbox: available
  • Staging: available
  • Production: unknown
GET
/v1/slim/device

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.
  • id is the Device resource id. thingsboardId is the device identifier that telemetry is keyed by.
  • status is active when the device's live telemetry reports it active, otherwise inactive.
  • lastActivityTime is the latest telemetry activity time, or the device's last-seen time when telemetry has none.
  • search matches device, location and zone names. patientSearch matches resident names. Both are case-insensitive substring matches.
  • organizationId, locationId, patientId and active filter on exact values.
  • orderBy is ASC or DESC in any case, default ASC. Rows with an empty sort value sort last in ASC order and first in DESC order.
  • page is zero-based. count defaults to 20, maximum 100. total is 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'

Authorization

bearer
headerAuthorizationBearer <JWT>

Query Parameters

page?string
Default"0"
count?string
Default"20"
sortBy?string
Default"deviceName"
Value in"deviceName""locationName""patientName""organizationName""lastActivityTime""createdAt"
orderBy?string
Default"ASC"
Value in"ASC""DESC"
search?string
Length1 <= length
patientSearch?string
Length1 <= length
organizationId?string
Length1 <= length
locationId?string
Length1 <= length
patientId?string
Length1 <= length
active?string

Response Body

One page of devices.

application/json
  1. response
total*number
Range0 <= value
page*number
Range0 <= value
count*number
Range1 <= value
resources*array<>
Example Request
curl -X GET 'https://api.sandbox.ovok.com/v1/slim/device'
Example Response
{  "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"}' ```