Bulk Unlinking Devices
Device audits, patient unenrollment, and hardware reclamation all produce the same task: unlink many HWI Devices in one pass. This recipe covers how to build an accurate list of devices, execute the unlink safely, and verify the result.
The process involves:
- Build a list of HWI Device IDs, either from a CSV export in the Tenovi web app or from a filtered
GET /hwi/hwi-devices/query. - Loop through that list, calling
GET /hwi/unlink-gateway/{hwi_device_id}/once per device. - Re-query the affected Gateways to confirm they are fully cleared.
Before You Start
Section titled “Before You Start”You will need an active API key and your Client Domain. All requests are made against https://api2.tenovi.com/clients/{CLIENT_DOMAIN}/hwi/ over HTTPS. See API URL Config and Client Domain for details.
Unlinking takes effect immediately. Data transmission stops and connection fees stop at the moment the call succeeds. There is no grace period and no scheduled effective date.
A Gateway is only reusable when every device on it is unlinked. One Gateway can carry multiple HWI Devices. Unlinking two of three leaves the Gateway occupied and unavailable for a new patient. This is the most common way a bulk unlink appears to succeed while leaving hardware stranded.
The call is a GET but it changes state. Treat it accordingly. Browser prefetch, proxy caching, retry wrappers, and rerunning a saved request collection can all fire it again without you intending to.
Reruns are safe. Calling unlink-gateway against a device that is already unlinked returns 200. A partially completed batch can be rerun from the top without additional effect.
Step 1 - Build the List of Devices to Unlink
Section titled “Step 1 - Build the List of Devices to Unlink”You need the hwi_device_id of every device in scope. There are two ways to get them.
Option A: Export from the Tenovi Web App
Section titled “Option A: Export from the Tenovi Web App”The Devices screen in the Tenovi web app exports to CSV. For most audits this is the fastest path, and it lets someone outside engineering assemble and review the list before handing it over to execute.
The export includes HWI Device IDs alongside patient IDs, Gateway IDs, and date timestamps, so you can filter and cross reference in a spreadsheet without writing any code. Narrow it down to the devices in scope, then use the resulting HWI Device ID column as your input list.
Because the export carries both the patient ID and the Gateway ID on every row, it is also the quickest way to check whether a Gateway has other devices attached before you unlink anything. Sort by Gateway ID and look for duplicates.
Option B: Query hwi-devices Directly
Section titled “Option B: Query hwi-devices Directly”Filter server side rather than pulling your full account and filtering locally.
GET /clients/{CLIENT_DOMAIN}/hwi/hwi-devices/?device__hardware_uuid={gateway_uuid}&page=1&page_size=100Useful Query Parameters
Section titled “Useful Query Parameters”| Parameter | Description |
|---|---|
device__hardware_uuid | Filter to devices attached to a specific Gateway. Note the double underscores. |
device__hardware_uuid__iexact | Case insensitive match on the Gateway UUID. |
patient__external_id | Filter to devices assigned to a specific patient. Note the double underscores. This is the query parameter form of the patient.external_id response field (see the Patients Object). |
properties__key | Filter by a Device Property key. See Device Properties. |
properties__value | Filter by a Device Property value. |
search | Free text search term. |
page | Page number within the paginated result set. |
page_size | Results per page. |
Choosing Your Filter: Gateway or Patient
Section titled “Choosing Your Filter: Gateway or Patient”| Approach | Use when | Watch for |
|---|---|---|
Gateway scoped (device__hardware_uuid) | Device audits and hardware reclamation. Guarantees the Gateway ends up fully cleared and available for reuse. | Nothing. This is the safer default. |
Patient scoped (patient__external_id) | Unenrollment workflows, where the unit of work is the patient. | A device on the same Gateway may be assigned to a different patient record. The Gateway will remain occupied. Verify in Step 3. |
Lead with Gateway scoped whenever the goal is to get hardware back into service. Lead with Patient scoped when working with unenrolling a patient.
Dry Run First
Section titled “Dry Run First”Output your final list of hwi_device_id values and review it before executing anything. Confirm the count matches what you expect. This is the last point at which the operation is reversible.
Step 2 - Loop the unlink-gateway Call
Section titled “Step 2 - Loop the unlink-gateway Call”For each hwi_device_id in your list, send a GET request to the unlink-gateway endpoint.
GET /clients/{CLIENT_DOMAIN}/hwi/unlink-gateway/{hwi_device_id}/curl --location 'https://api2.tenovi.com/clients/CLIENT_DOMAIN/hwi/unlink-gateway/HWI_DEVICE_ID/' \--header 'Authorization: Api-Key API_KEY_HERE'A successful call returns the HWI Device object with the hardware_uuid field of the nested device object set to null.
Key Response Fields
Section titled “Key Response Fields”| Field | Notes |
|---|---|
id | The hwi_device_id. Retired permanently once unlinked. |
device.hardware_uuid | The Gateway UUID. null after a successful unlink. This is the field to check. |
patient.external_id | Your identifier for the patient the device was assigned to. |
Step 3 - Verify
Section titled “Step 3 - Verify”Two checks, in this order.
Confirm each device is unlinked. Re-query hwi-devices for your list and confirm device.hardware_uuid is null on every record.
Confirm each Gateway is empty. For every Gateway touched by the batch, query for remaining devices:
GET /clients/{CLIENT_DOMAIN}/hwi/hwi-devices/?device__hardware_uuid={gateway_uuid}&page=1Any device still returning with a non null device.hardware_uuid means that Gateway is still occupied and cannot be assigned to a new patient. This is the step that catches a patient scoped unlink that left hardware stranded.
Testing with Postman
Section titled “Testing with Postman”If you prefer not to write a script, the Tenovi Postman collection includes the relevant calls. Postman Collection Runner can iterate a CSV of HWI Device IDs and issue one request per row.
Set the iteration delay to 1,200 milliseconds. The documented limit is 1 request per second, but Postman fires close enough to that boundary to trigger 429 responses in practice. The extra 200 milliseconds absorbs it. Run against a two or three row CSV first and confirm the response before loading the full list.
Common Issues
Section titled “Common Issues”Issues specific to this recipe. For platform wide behavior see Common Gotchas.
404 on a device ID you believe is valid The device does not exist or belongs to a different account. The response body describes the reason. Check for a copy and paste error, a truncated ID, or an ID pulled from the wrong client domain.
The Gateway is still unavailable after unlinking Another HWI Device is still attached to it. A Gateway is only reusable once every device on it is unlinked. Query hwi-devices filtered by device__hardware_uuid to find what remains.
No devices returned when filtering by patient The query parameter is patient__external_id with double underscores. The patient.external_id form is the response field name and will not work as a filter.
You need the device back You cannot reverse an unlink. Activate a new HWI Device against the Gateway and update any mapping in your system that referenced the old hwi_device_id. Measurement history collected under the old device is retained.