Devices
Create device
Create device using Ovok’s Slim API.
| Method | Path |
|---|---|
POST | /v1/slim/device |
Authentication · Access policies
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).
Request
Body
The body is strict: a field that is not listed here fails validation.
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Device serial and user-friendly name. At least 1 character. Unique within the project; another customer's serial is refused with 409. |
thingsboardId | string | No | Device identifier that telemetry is keyed by. At least 1 character. Default: a random UUID. |
organizationId | string (uuid) | No | Zone to assign. If locationId names a room with a zone, this must be that zone. |
locationId | string (uuid) | No | Location to assign the device to. |
patientId | string (uuid) | No | Resident to assign to the device. |
Behaviour
nameis stored as the device's user-friendly name and as its official device identifier (the serial). A serial already used by another customer is refused with409; this check runs before the room-zone check.thingsboardIdis stored as a second identifier. When you omit it, Ovok generates a random UUID for it.organizationId,locationIdandpatientIdare 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 takes the room's zone. If
organizationIddiffers from that zone, the request is refused with422and nothing is created. A device without a room, or in a room without a zone, can use any zone. - A zone change applies only to the device.
- Assigning a resident moves them: the resident is removed from every other device they hold, and their active out-of-bed episode is closed.
- 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
curl -X POST 'https://api.sandbox.ovok.com/v1/slim/device' \
-H "Authorization: Bearer ${OVOK_TOKEN}" \
-H 'Content-Type: application/json' \
-d '{"name": "Demo/1000001", "locationId": "5d2a9c64-7e1b-4830-b6f5-9a3c1e8d7b02"}'Successful response
201 — The created device.
{
"id": "8c5e7a21-4b9d-4f36-a1c8-0d2e6b9f3a54",
"name": "Demo/1000001",
"status": "active",
"statusReason": [],
"thingsboardId": "Demo/1000001",
"organizationId": "1e6b8d30-2c4f-4a95-8d7e-b0a2c4e6f918",
"organizationName": "Zone A",
"locationId": "5d2a9c64-7e1b-4830-b6f5-9a3c1e8d7b02",
"locationName": "Room 101 Bed 1",
"patientId": "3f1c2b7e-8d4a-4c1e-9b2f-6a7d5e4c3b21",
"patientName": "demo-resident",
"floor": "1",
"room": "101",
"bed": "1"
}The body is the new device, as GET /v1/slim/device/{id} returns it.
| Field | Type | Description |
|---|---|---|
id | string (uuid) | Device id. |
name | string | Device name. Empty string when it has none. |
status | "active" | "inactive" | "entered-in-error" | "unknown" | Connection status. Left out when unknown. |
statusReason | object[] | Why the platform marked the device, when it did. Empty array when nothing was recorded. |
statusReason[].code | string | Reason code, such as no-assigned-resident. Stable. Render from this. |
statusReason[].display | string | null | A sentence for the code. null for a code that has none. |
thingsboardId | string | Device identifier that telemetry is keyed by. Left out when the device has none. |
organizationId | string (uuid) | Zone id. Left out when there is none. |
organizationName | string | null | Zone name. |
locationId | string (uuid) | Location id. Left out when there is none. |
locationName | string | null | Location name. |
patientId | string (uuid) | Resident id. Left out when there is none. |
patientName | string | null | The resident's full display name. |
floor | string | Floor code of the location. Left out when not set. |
room | string | Room code of the location. Left out when not set. |
bed | string | Bed code of the location. Left out when not set. |
Errors
| Status | Meaning |
|---|---|
400 | A zone, location or resident in the body does not exist, or the FHIR backend refuses the write. |
401 | Bearer token is missing, invalid or expired. |
403 | You are not a practitioner, admin or System Owner, or you lack Device:create. |
409 | This device serial is in use by another customer. (path: ["name"]). |
422 | The body fails validation, a device in this project already uses the serial (including a DeviceID identifier equal to name), the zone does not match the room's zone (path: ["organizationId"]), or you send locationId and patientId for a discharged resident. |
Last updated on