---
title: "Create or update a monitors relation"
method: PUT
path: "/v1/role/{roleId}/monitors"
tags: ["Monitors"]
---

# Create or update a monitors relation

`PUT /v1/role/{roleId}/monitors`

Create a monitors relation (or update the existing one) between a role and a device.<br><br>
        To execute this query, the user must be a member of an authorizing role which satisfies both of the following conditions:
        <ol>
          <li>
            One of the following role-related conditions is true:
            <ul>
              <li>
                The authorizing role has *direct or indirect* deviceManagement rights for the role from which the monitors relation is created (or updated)
              </li>
              <li>
                The authorizing role has *indirect* roleManagement rights for the role from which the monitors relation is created (or updated)
              </li>
            </ul>
          </li>
          <li>
            The authorizing role has monitorManagement rights for the device to which the monitors relation is created
          </li>
        </ol>

## Path parameters

- `roleId` integer, required

## Query parameters

- `deviceId` integer[], required

## Request body

- Def31
  - `monitorManagement` boolean, required — Indicates whether the role has the right to create new monitors relations to the monitored device. If true, the role may read and edit any device property.
  - `reads` string[], required — A list of device properties which may be read by the role monitoring the device
  - `edits` string[], required — A list of device properties which may be both read and edited by the role monitoring the device

## Response `200`

The newly created (or updated) monitors relation

- object
  - `monitors` union — The newly created (or updated) monitors relation
    - Def32
      - `id` integer, required — Id of the monitors relation
      - `roleId` integer, required — Id of the role which monitors a device via the monitors relation
      - `deviceId` integer, required — Id of the device which is monitored via the monitors relation
      - `monitorManagement` boolean, required — Indicates whether the role has the right to create new monitors relations to the monitored device. If true, the role may read and edit any device property.
      - `reads` string[], required — A list of device properties which may be read by the role monitoring the device
      - `edits` string[], required — A list of device properties which may be both read and edited by the role monitoring the device
    - Def32[]
      - `id` integer, required — Id of the monitors relation
      - `roleId` integer, required — Id of the role which monitors a device via the monitors relation
      - `deviceId` integer, required — Id of the device which is monitored via the monitors relation
      - `monitorManagement` boolean, required — Indicates whether the role has the right to create new monitors relations to the monitored device. If true, the role may read and edit any device property.
      - `reads` string[], required — A list of device properties which may be read by the role monitoring the device
      - `edits` string[], required — A list of device properties which may be both read and edited by the role monitoring the device

## Other responses

- `400` — Invalidly formatted body or query parameters
- `401` — Authentication required or token invalid
- `403` — User does not have appropriate role management rights
- `409` — The monitors relation cannot be updated, since it is the only monitors relation of the device which allows monitorManagement rights, and the proposed change would revoke these rights, resulting in a device with uneditable monitors relations.

---

[API](https://skmtc.dev/eniris/apis/eniris-metadata-telemetry-query-api.md) · [All operations](https://skmtc.dev/eniris/apis/eniris-metadata-telemetry-query-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/eniris/eniris-metadata-telemetry-query-api/revisions/fe3723575e19/schema)
