const handleUnlock = async (req, res) => {
// Retrieve the internal user ID used to set the
// user_identifier_key.
const user_identifier_key = req.auth.userId
// The application user specifies a device to unlock from
// among the filtered set of devices.
const device_id = req.body.device_id
// Confirm that the selected device is, indeed, among the
// set of devices that the user owns.
const devices = await seam.devices.list({
user_identifier_key,
device_ids: [device_id],
})
if (devices.length === 0) return res.send(401).end()
// Trigger an action on the device, like unlocking the door.
await seam.devices.unlock_door({ device_id })
res.send(204)
}