Skip to main content

Device Access Scope

A device key reads across its whole project by default (what the credential is). The Access scope setting narrows that, so a device sees only the data of its own organisation and, if you choose, that organisation's child organisations.

It is one setting with two levels. Level 1 is a single choice that makes every coupled change for you. Level 2 exposes each switch on its own. Both write the same configuration that the device_compartment validator reads, so anything you can do here you can also do by editing that configuration by hand. This page is the safer route, because it previews the change and refuses a save that would leave your own devices without access.

In the dashboard it is the Access scope tab on the Devices page.

Before you narrow​

A device's organisation is its FHIR Device.owner. A device with no owner, or whose owner no longer exists, is denied everything once narrowing is on. Do this in order:

  1. Give every device an organisation. Name it with organization when you register the device. A device registered without one gets the project's root organisation when the project's patient custodianship is set to organisation, and no owner otherwise.
  2. Preview the change and confirm unresolved_devices is empty.
  3. Save.

The save is refused while any device has no usable organisation, so step 1 cannot be skipped by accident.

Level 1: the two options​

scopeWhat it does
whole_projectThe default. Turns organisation narrowing off for reads and writes. No RBAC rule is changed.
own_organizationNarrows device reads and searches to the device's organisations, in one action.

Choosing own_organization makes three changes together:

  • It turns on org_aware and org_aware_write.
  • Every Device rule that grants read or search with allowed is switched to device_compartment.
  • Every Device rule that grants create or update on Device, Location or Organization is set to forbidden. A device that could write those resources could pick its own organisation, so narrowing does not apply while it can. This includes the medical_device template's Device / Device / update, so devices lose the ability to update their own Device record.

It also requires rbac.default_access to be Forbidden. It does not change that setting for you; the preview reports it as a blocker until you do.

Device creates stay project-wide. A create rule granted with allowed, such as the template's Device / Observation / create, is not changed. The preview lists these as writes_stay_project_wide. To narrow one, switch that rule to device_compartment in the RBAC editor.

Switching back to whole_project widens no rule. It turns narrowing off but leaves every rule on the validator it has. Rules the preset moved to device_compartment stay there, and the preview lists them as stays_compartment_scoped. Restore any of them to allowed in the RBAC editor if that is what you want.

Level 2: each switch​

SettingTypeDefaultMeaning
org_awareboolfalseNarrowing for read and search
org_aware_writeboolfalseNarrowing for create and update. Has no effect unless org_aware is also on
resolve_locationbooltrueAlso count the managing organisation of the device's location
inheritance_levelsint, 0–50How many levels of child organisations a device reaches

Level 2 changes these four values and no rule. The current Level 1 option is derived from the stored configuration and returned as level_one. A configuration that matches neither option reads custom.

The API​

All three calls take the X-Project-ID header. Reading and previewing need the manage_devices permission. Saving also needs manage_rbac_configuration, because it rewrites RBAC rules. The Project Administrator and Developer roles hold both.

CallPurpose
GET /devices/access-scopeThe setting in force
POST /devices/access-scope/previewWhat a change would do. Saves nothing
PUT /devices/access-scopeSave a change. It is published immediately

Reading the current setting​

GET /devices/access-scope
X-Project-ID: 3fa85f64-5717-4562-b3fc-2c963f66afa6
{
"level_one": "whole_project",
"settings": {
"org_aware": false,
"org_aware_write": false,
"resolve_location": true,
"inheritance_levels": 0
},
"device_rules": [
{ "entity_name": "Observation", "operation": "read", "validator": "allowed" }
],
"default_access": "Forbidden",
"has_unpublished_changes": false
}

device_rules lists every rule for the Device role.

The request body​

A preview and a save take the same body. Send either a Level 1 scope or one or more Level 2 settings, never both:

{ "scope": "own_organization" }
{ "org_aware": true, "inheritance_levels": 1 }

Level 2 settings you leave out keep their current value. A body with both, with neither, or with a value of the wrong type is refused with 422.

The preview​

POST /devices/access-scope/preview
X-Project-ID: 3fa85f64-5717-4562-b3fc-2c963f66afa6
Content-Type: application/json

{ "scope": "own_organization" }

An abridged response:

{
"level_one": "own_organization",
"settings": {
"org_aware": true,
"org_aware_write": true,
"resolve_location": true,
"inheritance_levels": 0
},
"rule_changes": [
{ "entity_name": "Observation", "operation": "read", "from": "allowed", "to": "device_compartment" },
{ "entity_name": "Device", "operation": "update", "from": "allowed", "to": "forbidden" }
],
"devices": [
{ "id": 12, "name": "icu-monitor-05", "organization": null, "owner": "ward-3", "problem": null }
],
"widened": ["Observation/search"],
"writes_stay_project_wide": ["DeviceMetric/create", "Media/create", "Observation/create"],
"stays_project_wide": [],
"stays_compartment_scoped": [],
"unmapped": [],
"disabled_by": [],
"unresolved_devices": [],
"custodianship_mode_2": false,
"blocked": false
}
FieldMeaning
level_oneThe Level 1 option the result equals: whole_project, own_organization or custom
settingsThe four Level 2 values after the change
rule_changesEach rule the change moves, with its validator before and after
devicesEach active device, with the organisation it resolves to as owner. Listed only when narrowing is on after the change
widenedRules that grant more after the change. See widening
writes_stay_project_widecreate and update rules still granted with allowed, which narrowing does not reach
stays_project_wideread and search rules still granted with allowed while narrowing is on. These read across the whole project
stays_compartment_scopedWhen narrowing is off: read and search rules on device_compartment, which keep a device to its own records
unmappedRules the change would move to device_compartment on a resource type that has no organisation. Narrowing would deny these outright
disabled_byReasons the platform would ignore the narrowing you asked for. See below
unresolved_devicesNames of devices with no usable organisation
custodianship_mode_2true when devices are unresolved and the project's patient custodianship is not set to organisation, so registration did not give them an owner
blockedtrue when unmapped, disabled_by or unresolved_devices is non-empty. A blocked change cannot be saved

A device's problem is null when its organisation resolves. Otherwise it is one of these:

problemMeaningWhat to do
not_registeredThe device has no FHIR Device resourceDelete the device and register it again under a new name. This issues a new API key
no_ownerThe Device resource has no owner organisationSet the device's organisation. The API key does not change
owner_not_foundThe owner names an Organization that does not existRestore the Organization, or set the device's organisation to one that exists
lookup_failedThe device could not be checkedRetry the preview

Registering a device again never changes its organisation. A registration that names a different organisation from the one already recorded for that name, or names one where none is recorded, is refused with 409, even after the device was deleted. Change an existing device's organisation instead.

disabled_by entries:

EntryMeaning
default_accessrbac.default_access is not Forbidden
writable:<Resource>/<operation>A Device rule lets devices write a resource their organisation is read from
org_aware_write_without_org_awareWrite narrowing was asked for without read narrowing

Location counts only when resolve_location is on, and Organization only when inheritance_levels is above 0.

Widening needs your acknowledgement​

With narrowing on, a device_compartment rule grants a device both its own records and its organisation's records. So turning narrowing on makes a rule you already set to device_compartment grant more, from "records about this device" to "records of its organisation". Raising inheritance_levels, or turning on resolve_location, while narrowing is on widens them the same way. The preview above assumes an Observation/search rule set that way. The shipped device templates widen nothing; this arises only from rules you scoped yourself.

The preview lists these rules in widened. A save that widens anything is refused until you acknowledge that exact list, by sending it back as acknowledge_widening:

PUT /devices/access-scope
X-Project-ID: 3fa85f64-5717-4562-b3fc-2c963f66afa6
Content-Type: application/json

{
"scope": "own_organization",
"acknowledge_widening": ["Observation/search"]
}

acknowledge_widening is the list, not true. true, an empty list, or a list that differs from the one the save computes in any way is refused with 409. If the rules changed between your preview and your save, for example because someone else edited them, the list changes too and the save is refused. Preview again, review the new list, and send it back.

If widened is empty, leave acknowledge_widening out.

Saving​

A successful PUT answers 200 with the same body as GET, showing the saved setting. The change is published at once; devices see it within about a minute.

StatusMeaning
200Saved and published
403You lack manage_devices, or manage_rbac_configuration for a save
404The project has no active RBAC configuration yet
409Not saved. Either the preview is blocked, or widened is non-empty and acknowledge_widening does not equal it. The body carries the full preview
422The body is malformed, or the resulting configuration fails validation
502Not saved, but the change may already be in force. Reading the setting back shows the old value either way, so check the project's configuration publish status before retrying