Update device
- Sandbox: available
- Staging: available
- Production: unknown
Updates a device's name and identifier, and assigns or unassigns its zone, location and resident.
Auth: bearer token. The caller must be a practitioner, an admin or a System Owner, and needs Device:update.
Scope: the device must belong to the caller's project (from the token).
Behaviour
nameis required and replaces the device's user-friendly name, trimmed. Renaming the device to a serial that a device of another customer already holds is refused with 409, in any spelling.- Renaming the device to a serial another device of your project 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. A device may take another spelling of its own serial. - For
organizationId,locationIdandpatientId: omit the field to leave it unchanged, sendnullto unassign, or send a UUID to assign. - A device in a room is in the room's zone. An
organizationIdthat differs from the zone of the device's room (the room you send, or the one it is in) answers 422 withpath: ["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. The resident who was on this device before loses it. Each resident who loses a device has their active out-of-bed episode closed in the same transaction.
- Assigning a resident who is not active (
discharged,discharged-recentorarchived) is refused with 422 and changes nothing: reactivate them first. Unassigning one (patientId: null) is allowed. - All changes are written in one transaction. If any part fails, nothing is written.
- Sending values the device already has is not an error, and writes nothing.
- Resident assignment changes, renames, identifier changes and zone changes are recorded in the change history.
- The response is the same as
GET /v1/slim/device/{id}after the update.
Example
curl -X PUT 'https://api.sandbox.ovok.com/v1/slim/device/c3499c27-2973-0a7f-807e-fb8676a92dcb' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \ -H 'Content-Type: application/json' \ -d '{"name": "Sleepiz/3001000", "patientId": null}'bearerAuthorizationBearer <JWT>id*stringuuidapplication/json- body
name*string1 <= lengththingsboardId?string1 <= lengthorganizationId?stringuuidlocationId?stringuuidpatientId?stringuuidThe updated device.
application/json- response
id*stringDevice resource id.
name*stringstatus?string"active""inactive""entered-in-error""unknown"statusReason*array<>thingsboardId?stringorganizationId?stringorganizationName*stringlocationId?stringlocationName*stringpatientId?stringpatientName*stringfloor?stringroom?stringbed?stringcurl -X PUT 'https://api.sandbox.ovok.com/v1/slim/device/497f6eca-6276-4993-bfeb-53cbbbba6f08' \ -H 'Content-Type: application/json' \ -d '{ "name": "string"}'{ "id": "string", "name": "string", "status": "active", "statusReason": [ { "code": "string", "display": "string" } ], "thingsboardId": "string", "organizationId": "string", "organizationName": "string", "locationId": "string", "locationName": "string", "patientId": "string", "patientName": "string", "floor": "string", "room": "string", "bed": "string"}Delete device DELETE
Deletes a device from your project. **Auth:** bearer token. The caller must be a practitioner, an admin or a System Owner, and needs `Device:delete`. System Owners cannot delete devices. **Scope:** the device must belong to the caller's project (from the token). ## Behaviour - The Device resource is deleted. This cannot be undone. - If a resident is assigned, they are unassigned and their active out-of-bed episode is closed in the same transaction. - The device's use history is updated in the same transaction. - The delete is recorded in the change history. - The response has no body. ## Example ```bash curl -X DELETE 'https://api.sandbox.ovok.com/v1/slim/device/c3499c27-2973-0a7f-807e-fb8676a92dcb' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' ```
Create night report PDF POST
Creates a night report PDF for one resident and stores it. Optionally emails the PDF. Use it for the report download and email feature on the dashboard. **Auth:** bearer token. The caller must be a practitioner, an admin or a System Owner, and needs `search` and `read` on `Patient`, `Device` and `Observation`. **Scope:** the caller's project (from the token). The resident is read with your token, so Medplum's access policy limits which residents you can export. ## Behaviour - `code` must be `TRENDS_PDF_EXPORT`. Any other value is rejected with `400`. - The report layout comes from the export template content for `code` and `language`. A template in your project wins over one in its parent project. The route returns `400` when no template exists. - The report period is `(period.start, period.end]` in the project's time zone: for a range of more than one day the first day is left out, because its night belongs to the day before. A single-day range reports that day. A night counts for the day its sleep ends. - The report covers sleep statistics, heart rate and respiratory rate for each night. It holds only what ends inside one of the resident's use periods of its device, as `GET /v1/slim/sleep/statistics` does: the sleep table's recordings, and the readings behind the heart and respiratory rate rows and charts. A reading with no end time is then left out. So a previous resident's night that ended before the device was handed over, but reached Ovok after it, is not reported. A resident with no device use history has everything reported. - When a night has several sleep recordings left, the sleep table uses the one written last (latest `meta.lastUpdated`), the rule `GET /v1/slim/sleep/statistics` uses. - Once a resident has any use period, the report also leaves out what a device with no period of theirs recorded, and what a device recorded before its earliest period. A device assigned before use periods were recorded gets its first one on its next edit in Ovok, starting at the Device's last write before that edit, so what it recorded before then is not reported. Each device whose readings in a report all drop is counted in the `sleep.device_use_device_dropped` metric and logged at most once a minute. - Report times use the project's time zone. The `timeZone` field in the body is not used. - The PDF is stored as a Binary, and a `DocumentReference` links it to the resident. Both are written in one transaction, so a failed store leaves neither. The response is that `DocumentReference`. Its `content[0].attachment.url` points to the Binary. - When `mailTo` has addresses, the PDF is emailed to them as an attachment after the store succeeds. The email is sent in the language you set. With no addresses, nothing is emailed. - If the email cannot be sent, the route returns `500`, but the report has already been stored. - Every call creates a new report. Nothing is deduplicated. ## Example ```bash curl -X POST 'https://api.sandbox.ovok.com/v1/slim/export/pdf' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \ -H 'Content-Type: application/json' \ -d '{ "code": "TRENDS_PDF_EXPORT", "patientId": "c3499c27-2973-0a7f-807e-fb8676a92dcb", "language": "en", "period": { "start": "2026-09-21T00:00:00Z", "end": "2026-09-28T00:00:00Z" }, "mailTo": ["max.mustermann@example.com"] }' ```