---
title: Monitor API - Notehub API Reference
description: The Notehub Monitor API lists, creates, updates, and deletes the alert monitors that watch a Notehub project and send email or Slack alerts.
source_url: https://dev.blues.io/api-reference/notehub-api/monitor-api/
canonical_url: https://dev.blues.io/api-reference/notehub-api/monitor-api/
markdown_url: https://dev.blues.io/api-reference/notehub-api/monitor-api.md
---

# Monitor API

The Notehub monitor API provides RESTful methods that can be used to [manage project alerts](https://dev.blues.io/notehub/notehub-walkthrough.md#configuring-alert-monitors).

| Name | HTTP Request |
| - | - |
| [Get Monitors](#get-monitors) | **GET** `/v1/projects/{projectOrProductUID}/monitors` |
| [Get Monitor](#get-monitor) | **GET** `/v1/projects/{projectOrProductUID}/monitors/{monitorUID}` |
| [Create Monitor](#create-monitor) | **POST** `/v1/projects/{projectOrProductUID}/monitors` |
| [Delete Monitor](#delete-monitor) | **DELETE** `/v1/projects/{projectOrProductUID}/monitors/{monitorUID}` |
| [Update Monitor](#update-monitor) | **PUT** `/v1/projects/{projectOrProductUID}/monitors/{monitorUID}` |

## Get Monitors (Notehub) {#get-monitors}

Get all alert monitors for a Notehub [project](https://dev.blues.io/api-reference/glossary.md#project).

| | |
| - | - |
| HTTP Method: | `GET` |
| URL: | `https://api.notefile.net/v1/projects/{projectOrProductUID}/monitors` |
| Path Parameters: | - `projectOrProductUID` - The [ProjectUID](https://dev.blues.io/api-reference/glossary.md#projectuid) or [ProductUID](https://dev.blues.io/api-reference/glossary.md#productuid) of a Notehub project. |
| Minimum Notehub [project-level role:](https://dev.blues.io/notehub/notehub-walkthrough.md#collaborator-roles) | viewer |
| Required HTTP Headers: | `Authorization: Bearer <token>`, where the token is a valid [authentication token](https://dev.blues.io/api-reference/notehub-api.md#authentication). |

Arguments

None

**Example**

**Bash**

```bash
curl -X GET
     -L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors'
     -H 'Authorization: Bearer <access_token>'
```

**JS**

```javascript
import * as NotehubJs from "@blues-inc/notehub-js";

let defaultClient = NotehubJs.ApiClient.instance;
// Configure Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";

let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";

apiInstance.getMonitors(projectOrProductUID).then(
  (data) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data),
    );
  },
  (error) => {
    console.error(error);
  },
);
```

**Python**

```python
import os
from pprint import pprint

import notehub_py

configuration = notehub_py.Configuration(
    access_token=os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"

    try:
        api_response = api_instance.get_monitors(project_or_product_uid)
        print("The response of MonitorApi->get_monitors:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling MonitorApi->get_monitors: %s\n" % e)
```

**Response Members**

### `monitors` {#get-monitors--monitors}

*array*

An array of all monitors on the specified Notehub project. See [Get Monitor](#get-monitor) for a full description of the fields returned.

Example Response

```json
{
  "monitors": [
    {
      "uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
      "name": "test-monitor",
      "description": "monitor description",
      "disabled": true,
      "silenced": true,
      "notefile_filter": [
          "_track.qo"
      ],
      "source_type": "event",
      "source_selector": "temperature",
      "condition_type": "equal_to",
      "alert_routes": [
          {
              "email": "test@blues.com"
          }
      ],
      "last_routed_at": "2024-06-01 01:23:45 +0000 UTC",
      "routing_cooldown_period": "5m0s",
      "aggregate_function": "none",
      "aggregate_window": "0s"
    },
    ...
  ]
}
```

## Get Monitor (Notehub) {#get-monitor}

Get an alert monitor for a Notehub [project](https://dev.blues.io/api-reference/glossary.md#project).

| | |
| - | - |
| HTTP Method: | `GET` |
| URL: | `https://api.notefile.net/v1/projects/{projectOrProductUID}/monitors/{monitorUID}` |
| Path Parameters: | - `projectOrProductUID` - The [ProjectUID](https://dev.blues.io/api-reference/glossary.md#projectuid) or [ProductUID](https://dev.blues.io/api-reference/glossary.md#productuid) of a Notehub project.
- `monitorUID` - The MonitorUID of an existing Notehub monitor. |
| Minimum Notehub [project-level role:](https://dev.blues.io/notehub/notehub-walkthrough.md#collaborator-roles) | viewer |
| Required HTTP Headers: | `Authorization: Bearer <token>`, where the token is a valid [authentication token](https://dev.blues.io/api-reference/notehub-api.md#authentication). |

Arguments

None

**Example**

**Bash**

```bash
curl -X GET
     -L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors/<monitorUID>'
     -H 'Authorization: Bearer <access_token>'
```

**JS**

```javascript
import * as NotehubJs from "@blues-inc/notehub-js";

let defaultClient = NotehubJs.ApiClient.instance;
// Configure Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";

let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
let monitorUID = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1";

apiInstance.getMonitor(projectOrProductUID, monitorUID).then(
  (data) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data),
    );
  },
  (error) => {
    console.error(error);
  },
);
```

**Python**

```python
import os
from pprint import pprint

import notehub_py

configuration = notehub_py.Configuration(
    access_token=os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
    monitor_uid = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1"

    try:
        api_response = api_instance.get_monitor(
            project_or_product_uid, monitor_uid
        )
        print("The response of MonitorApi->get_monitor:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling MonitorApi->get_monitor: %s\n" % e)
```

**Response Members**

### `uid` {#get-monitor--uid}

*string*

The globally-unique identifier for the monitor.

### `name` {#get-monitor--name}

*string*

The name of the monitor.

### `description` {#get-monitor--description}

*string*

The description of the monitor.

### `disabled` {#get-monitor--disabled}

*boolean*

Whether the monitor is disabled.

### `silenced` {#get-monitor--silenced}

*boolean*

Whether the monitor is silenced.

### `notefile_filter` {#get-monitor--notefilefilter}

*array*

An array of the Notefile names the monitor is based on.

### `source_type` {#get-monitor--sourcetype}

*string*

The type of source the monitor watches: `"event"` or `"heartbeat"`.

### `source_selector` {#get-monitor--sourceselector}

*string*

A dot-delimited path to the value to monitor within the source Notefile's `body`.

### `condition_type` {#get-monitor--conditiontype}

*string*

The type of condition to apply to the value selected by the `source_selector`.

### `alert_routes` {#get-monitor--alertroutes}

*array*

An array of entities to notify when an alert is triggered.

### `last_routed_at` {#get-monitor--lastroutedat}

*date*

An ISO 8601 date for the last time the monitor was evaluated and routed.

### `routing_cooldown_period` {#get-monitor--routingcooldownperiod}

*string*

The time period Notehub will wait before routing another event after the monitor has been triggered.

Example Response

```json
{
  "uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
  "name": "test-monitor",
  "description": "monitor description",
  "disabled": true,
  "silenced": true,
  "notefile_filter": [
      "_track.qo"
  ],
  "source_type": "event",
  "source_selector": "temperature",
  "condition_type": "equal_to",
  "alert_routes": [
      {
          "email": "test@blues.com"
      }
  ],
  "last_routed_at": "2024-06-01 01:23:45 +0000 UTC",
  "routing_cooldown_period": "5m0s",
  "aggregate_function": "none",
  "aggregate_window": "0s"
}
```

## Create Monitor (Notehub) {#create-monitor}

Create an alert monitor for a Notehub [project](https://dev.blues.io/api-reference/glossary.md#project).

note

Notehub Essentials users can have one active heartbeat monitor per project at no cost. Additional heartbeat monitors, as well as all event monitors, require a Notehub Enterprise plan.

The API returns a `403` error if your plan doesn't allow the monitor. See [Blues pricing](https://blues.com/pricing) or [contact Blues sales](https://blues.com/contact-sales/) for more information.

| | |
| - | - |
| HTTP Method: | `POST` |
| URL: | `https://api.notefile.net/v1/projects/{projectOrProductUID}/monitors` |
| Path Parameters: | - `projectOrProductUID` - The [ProjectUID](https://dev.blues.io/api-reference/glossary.md#projectuid) or [ProductUID](https://dev.blues.io/api-reference/glossary.md#productuid) of a Notehub project. |
| Minimum Notehub [project-level role:](https://dev.blues.io/notehub/notehub-walkthrough.md#collaborator-roles) | developer |
| Required HTTP Headers: | `Authorization: Bearer <token>`, where the token is a valid [authentication token](https://dev.blues.io/api-reference/notehub-api.md#authentication). |

Arguments

### `name` {#create-monitor--name}

*string*

The name of the monitor.

### `description` {#create-monitor--description}

*string (optional)*

The description of the monitor.

This argument defaults to an empty string.

### `disabled` {#create-monitor--disabled}

*boolean (optional)*

If `true`, the monitor will be disabled in Notehub.

This argument defaults to `false`.

### `silenced` {#create-monitor--silenced}

*boolean (optional)*

If `true`, this monitor will not send alerts.

This argument defaults to `false`.

### `fleet_filter` {#create-monitor--fleetfilter}

*array (optional)*

An array of [FleetUIDs](https://dev.blues.io/api-reference/glossary.md#fleetuid) to monitor.

### `notefile_filter` {#create-monitor--notefilefilter}

*array (optional)*

An array of Notefiles names you want the monitor to be based on.

### `source_selector` {#create-monitor--sourceselector}

*string (optional)*

A dot-delimited path to a single, numeric value within the source Notefile's `body`. For example, `"temperature"` would select the `body.temperature` field from all monitored Notefiles.

This argument is required for event monitors, unless `aggregate_function` is `"count"`. A count monitor counts matching events, so it doesn't need a field to read.

### `source_type` {#create-monitor--sourcetype}

*string (optional)*

The type of source to monitor. Set to `"event"` to create an event monitor, and `"heartbeat"` to create a heartbeat monitor.

This argument defaults to `"event"`.

### `condition_type` {#create-monitor--conditiontype}

*string*

The type of condition to apply to the value selected by the `source_selector`. Possible values are `"greater_than"`, `"greater_than_or_equal_to"`, `"less_than"`, `"less_than_or_equal_to"`, `"equal_to"`, and `"not_equal_to"`.

This argument defaults to `"greater_than"`.

### `threshold` {#create-monitor--threshold}

*number*

The numeric threshold to apply to the value selected by the `source_selector`. For heartbeat monitors this is the number of seconds of inactivity.

### `alert_routes` {#create-monitor--alertroutes}

*array*

An array of entities to notify when an alert is triggered. There are three types of entities you can provide.

*Email*

To add an email notification add an object with a key of `email` and a value of the email address you'd like to use.

`{"email":"your.email@blues.com"}`

*Slack Webhook*

To add a Slack webhook notification add an object with `url`, `message_type`, and `text` properties.

Learn more about these properties in [Slack Webhook Route Type](https://dev.blues.io/notehub/messaging-and-data-pipelines/using-slack-with-notehub.md#webhook-route-type).

`{"url":"hooks.slack.com/...", "message_type": "text|blocks", "text": "Message Text"}`

*Slack Bearer*

To add a Slack bearer notification add an object with `token`, `channel`, `message_type` and `text` properties.

Learn more about these properties in [Slack Bearer Route Type](https://dev.blues.io/notehub/messaging-and-data-pipelines/using-slack-with-notehub.md#bearer-route-type).

`{"token":"<your-token>", "channel": "CXXXXXXXXXX", "message_type": "text|blocks", "text": "Message Text"}`

### `aggregate_function` {#create-monitor--aggregatefunction}

*string (optional)*

An optional aggregate function to apply to the selected values before applying the condition. Available values `"none"`, `"sum"`, `"avg"`, `"max"`, `"min"`, `"count"`.

This argument defaults to `"none"`.

### `aggregate_window` {#create-monitor--aggregatewindow}

*string (optional)*

The time window to aggregate the selected values when an aggregate function is applied. The value you provide must be one or more numbers (decimals allowed), each followed by a time unit of `ns`, `us`, `ms`, `s`, `m`, or `h`. For example, `10m` for 10 minutes, `10m30s` for 10 minutes and 30 seconds, `5h30m10s` for 5 hours 30 minutes 10 seconds, or `1.5h` for 90 minutes.

### `per_device` {#create-monitor--perdevice}

*boolean (optional)*

If enabled and an aggregate function is applied, the monitor will be evaluated per device rather than across all available devices.

This argument defaults to `false`.

### `routing_cooldown_period` {#create-monitor--routingcooldownperiod}

*string (optional)*

The time period to wait before routing another event after the monitor has been triggered. The value you provide must be one or more numbers (decimals allowed), each followed by a time unit of `ns`, `us`, `ms`, `s`, `m`, or `h`. For example, `10m` for 10 minutes, `10m30s` for 10 minutes and 30 seconds, `5h30m10s` for 5 hours 30 minutes 10 seconds, or `1.5h` for 90 minutes.

This argument defaults to `5m0s`.

**Basic Monitor**

**Bash**

```bash
curl -X POST
  -L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors'
  -H 'Authorization: Bearer <access_token>'
  -H 'Content-Type: application/json'
  -d '{"name":"<name>", "description": "<description>","notefile_filter":["data.qo"],"source_type":"event","source_selector":"temperature","condition_type":"greater_than","threshold":100,"alert_routes":[{"email":"<email>"}]}'
```

**JS**

```javascript
import * as NotehubJs from "@blues-inc/notehub-js";

let defaultClient = NotehubJs.ApiClient.instance;
// Configure Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";

let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
let createMonitor = {
  name: "Temperature Monitor",
  description: "Alert when temperature exceeds 100",
  notefile_filter: ["data.qo"],
  source_type: "event",
  source_selector: "temperature",
  condition_type: "greater_than",
  threshold: 100,
  alert_routes: [{ email: "someone@example.com" }],
}; // CreateMonitor

apiInstance.createMonitor(projectOrProductUID, createMonitor).then(
  (data) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data),
    );
  },
  (error) => {
    console.error(error);
  },
);
```

**Python**

```python
import os
from pprint import pprint

import notehub_py

configuration = notehub_py.Configuration(
    access_token=os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
    create_monitor = notehub_py.CreateMonitor(
        name="Temperature Monitor",
        description="Alert when temperature exceeds 100",
        notefile_filter=["data.qo"],
        source_type="event",
        source_selector="temperature",
        condition_type="greater_than",
        threshold=100,
        alert_routes=[
            notehub_py.MonitorAlertRoutesInner(
                notehub_py.EmailNotification(email="someone@example.com")
            )
        ],
    )

    try:
        api_response = api_instance.create_monitor(
            project_or_product_uid, create_monitor
        )
        print("The response of MonitorApi->create_monitor:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling MonitorApi->create_monitor: %s\n" % e)
```

**Response Members**

### `uid` {#create-monitor--uid}

*string*

The globally-unique identifier for the monitor.

### `name` {#create-monitor--name-2}

*string*

The name of the monitor.

### `description` {#create-monitor--description-2}

*string*

The description of the monitor.

### `disabled` {#create-monitor--disabled-2}

*boolean*

Whether the monitor is disabled.

### `silenced` {#create-monitor--silenced-2}

*boolean*

Whether the monitor is silenced.

### `notefile_filter` {#create-monitor--notefilefilter-2}

*array*

An array of the Notefile names the monitor is based on.

### `source_type` {#create-monitor--sourcetype-2}

*string*

The type of source the monitor watches: `"event"` or `"heartbeat"`.

### `source_selector` {#create-monitor--sourceselector-2}

*string*

A dot-delimited path to the value to monitor within the source Notefile's `body`.

### `condition_type` {#create-monitor--conditiontype-2}

*string*

The type of condition to apply to the value selected by the `source_selector`.

### `alert_routes` {#create-monitor--alertroutes-2}

*array*

An array of entities to notify when an alert is triggered.

### `last_routed_at` {#create-monitor--lastroutedat}

*date*

An ISO 8601 date for the last time the monitor was evaluated and routed.

### `routing_cooldown_period` {#create-monitor--routingcooldownperiod-2}

*string*

The time period Notehub will wait before routing another event after the monitor has been triggered.

Example Response

```json
{
  "uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
  "name": "test-monitor",
  "description": "monitor description",
  "disabled": true,
  "silenced": true,
  "notefile_filter": [
      "_track.qo"
  ],
  "source_type": "event",
  "source_selector": "temperature",
  "condition_type": "equal_to",
  "alert_routes": [
      {
          "email": "test@blues.com"
      }
  ],
  "last_routed_at": "2024-06-01 01:23:45 +0000 UTC",
  "routing_cooldown_period": "5m0s",
  "aggregate_function": "none",
  "aggregate_window": "0s"
}
```

## Delete Monitor (Notehub) {#delete-monitor}

Delete an alert monitor for a Notehub [project](https://dev.blues.io/api-reference/glossary.md#project).

| | |
| - | - |
| HTTP Method: | `DELETE` |
| URL: | `https://api.notefile.net/v1/projects/{projectOrProductUID}/monitors/{monitorUID}` |
| Path Parameters: | - `projectOrProductUID` - The [ProjectUID](https://dev.blues.io/api-reference/glossary.md#projectuid) or [ProductUID](https://dev.blues.io/api-reference/glossary.md#productuid) of a Notehub project.
- `monitorUID` - The MonitorUID of an existing Notehub monitor. |
| Minimum Notehub [project-level role:](https://dev.blues.io/notehub/notehub-walkthrough.md#collaborator-roles) | developer |
| Required HTTP Headers: | `Authorization: Bearer <token>`, where the token is a valid [authentication token](https://dev.blues.io/api-reference/notehub-api.md#authentication). |

Arguments

None

**Example**

**Bash**

```bash
curl -X DELETE
     -L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors/<monitorUID>'
     -H 'Authorization: Bearer <access_token>'
```

**JS**

```javascript
import * as NotehubJs from "@blues-inc/notehub-js";

let defaultClient = NotehubJs.ApiClient.instance;
// Configure Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";

let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
let monitorUID = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1";

apiInstance.deleteMonitor(projectOrProductUID, monitorUID).then(
  (data) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data),
    );
  },
  (error) => {
    console.error(error);
  },
);
```

**Python**

```python
import os
from pprint import pprint

import notehub_py

configuration = notehub_py.Configuration(
    access_token=os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
    monitor_uid = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1"

    try:
        api_response = api_instance.delete_monitor(
            project_or_product_uid, monitor_uid
        )
        print("The response of MonitorApi->delete_monitor:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling MonitorApi->delete_monitor: %s\n" % e)
```

**Response Members**

None: an empty object `{}` means success.

## Update Monitor (Notehub) {#update-monitor}

Update an alert monitor for a Notehub [project](https://dev.blues.io/api-reference/glossary.md#project).

| | |
| - | - |
| HTTP Method: | `PUT` |
| URL: | `https://api.notefile.net/v1/projects/{projectOrProductUID}/monitors/{monitorUID}` |
| Path Parameters: | - `projectOrProductUID` - The [ProjectUID](https://dev.blues.io/api-reference/glossary.md#projectuid) or [ProductUID](https://dev.blues.io/api-reference/glossary.md#productuid) of a Notehub project.
- `monitorUID` - The MonitorUID of an existing Notehub monitor. |
| Minimum Notehub [project-level role:](https://dev.blues.io/notehub/notehub-walkthrough.md#collaborator-roles) | developer |
| Required HTTP Headers: | `Authorization: Bearer <token>`, where the token is a valid [authentication token](https://dev.blues.io/api-reference/notehub-api.md#authentication). |

Arguments

### `name` {#update-monitor--name}

*string*

The name of the monitor.

### `description` {#update-monitor--description}

*string*

The description of the monitor.

### `disabled` {#update-monitor--disabled}

*boolean (optional)*

If `true`, the monitor will be disabled in Notehub.

This argument defaults to `false`.

### `silenced` {#update-monitor--silenced}

*boolean (optional)*

If `true`, this monitor will not send alerts.

This argument defaults to `false`.

### `fleet_filter` {#update-monitor--fleetfilter}

*array (optional)*

An array of [FleetUID](https://dev.blues.io/api-reference/glossary.md#fleetuid) to monitor.

### `notefile_filter` {#update-monitor--notefilefilter}

*array (optional)*

An array of Notefiles names you want the monitor to be based on.

### `source_selector` {#update-monitor--sourceselector}

*string (optional)*

A dot-delimited path to a single, numeric value within the source Notefile's `body`. For example, `"temperature"` would select the `body.temperature` field from all monitored Notefiles.

This argument is required for event monitors, unless `aggregate_function` is `"count"`. A count monitor counts matching events, so it doesn't need a field to read.

### `source_type` {#update-monitor--sourcetype}

*string (optional)*

The type of source to monitor. Set to `"event"` to create an event monitor, and `"heartbeat"` to create a heartbeat monitor.

This argument defaults to `"event"`.

### `condition_type` {#update-monitor--conditiontype}

*string*

The type of condition to apply to the value selected by the `source_selector`. Possible values are `"greater_than"`, `"greater_than_or_equal_to"`, `"less_than"`, `"less_than_or_equal_to"`, `"equal_to"`, and `"not_equal_to"`.

This argument defaults to `"greater_than"`.

### `threshold` {#update-monitor--threshold}

*number*

The numeric threshold to apply to the value selected by the `source_selector`. For heartbeat monitors this is the number of seconds of inactivity.

### `alert_routes` {#update-monitor--alertroutes}

*array*

An array of entities to notify when an alert is triggered. There are three types of entities you can provide.

*Email*

To add an email notification add an object with a key of `email` and a value of the email address you'd like to use.

`{"email":"your.email@blues.com"}`

*Slack Webhook*

To add a Slack webhook notification add an object with `url`, `message_type`, and `text` properties.

Learn more about these properties in [Slack Webhook Route Type](https://dev.blues.io/notehub/messaging-and-data-pipelines/using-slack-with-notehub.md#webhook-route-type).

`{"url":"hooks.slack.com/...", "message_type": "text|blocks", "text": "Message Text"}`

*Slack Bearer*

To add a Slack bearer notification add an object with `token`, `channel`, `message_type` and `text` properties.

Learn more about these properties in [Slack Bearer Route Type](https://dev.blues.io/notehub/messaging-and-data-pipelines/using-slack-with-notehub.md#bearer-route-type).

`{"token":"<your-token>", "channel": "CXXXXXXXXXX", "message_type": "text|blocks", "text": "Message Text"}`

### `aggregate_function` {#update-monitor--aggregatefunction}

*string (optional)*

An optional aggregate function to apply to the selected values before applying the condition. Available values `"none"`, `"sum"`, `"avg"`, `"max"`, `"min"`, `"count"`.

This argument defaults to `"none"`.

### `aggregate_window` {#update-monitor--aggregatewindow}

*string (optional)*

The time window to aggregate the selected values when an aggregate function is applied. The value you provide must be one or more numbers (decimals allowed), each followed by a time unit of `ns`, `us`, `ms`, `s`, `m`, or `h`. For example, `10m` for 10 minutes, `10m30s` for 10 minutes and 30 seconds, `5h30m10s` for 5 hours 30 minutes 10 seconds, or `1.5h` for 90 minutes.

### `per_device` {#update-monitor--perdevice}

*boolean (optional)*

If enabled and an aggregate function is applied, the monitor will be evaluated per device rather than across all available devices.

This argument defaults to `false`.

### `routing_cooldown_period` {#update-monitor--routingcooldownperiod}

*string (optional)*

The time period to wait before routing another event after the monitor has been triggered. The value you provide must be one or more numbers (decimals allowed), each followed by a time unit of `ns`, `us`, `ms`, `s`, `m`, or `h`. For example, `10m` for 10 minutes, `10m30s` for 10 minutes and 30 seconds, `5h30m10s` for 5 hours 30 minutes 10 seconds, or `1.5h` for 90 minutes.

This argument defaults to `5m0s`.

**Example**

**Bash**

```bash
curl -X PUT
     -L 'https://api.notefile.net/v1/projects/<projectOrProductUID>/monitors/<monitorUID>'
     -H 'Authorization: Bearer <access_token>'
     -H 'Content-Type: application/json'
     -d '{"name":"<name>", "description": "<description>","notefile_filter":["data.qo"],"source_type":"event","source_selector":"temperature","condition_type":"greater_than","threshold":100,"alert_routes":[{"email":"<email>"}]}'
```

**JS**

```javascript
import * as NotehubJs from "@blues-inc/notehub-js";

let defaultClient = NotehubJs.ApiClient.instance;
// Configure Bearer access token for authorization: personalAccessToken
let personalAccessToken = defaultClient.authentications["personalAccessToken"];
personalAccessToken.accessToken = "YOUR ACCESS TOKEN";

let apiInstance = new NotehubJs.MonitorApi();
let projectOrProductUID = "app:2606f411-dea6-44a0-9743-1130f57d77d8";
let monitorUID = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1";
let monitor = {
  name: "Temperature Monitor",
  description: "Alert when temperature exceeds 100",
  notefile_filter: ["data.qo"],
  source_type: "event",
  source_selector: "temperature",
  condition_type: "greater_than",
  threshold: 100,
  alert_routes: [{ email: "someone@example.com" }],
}; // Monitor

apiInstance.updateMonitor(projectOrProductUID, monitorUID, monitor).then(
  (data) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data),
    );
  },
  (error) => {
    console.error(error);
  },
);
```

**Python**

```python
import os
from pprint import pprint

import notehub_py

configuration = notehub_py.Configuration(
    access_token=os.environ["BEARER_TOKEN"]
)

# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8"
    monitor_uid = "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1"
    monitor = notehub_py.Monitor(
        name="Temperature Monitor",
        description="Alert when temperature exceeds 100",
        notefile_filter=["data.qo"],
        source_type="event",
        source_selector="temperature",
        condition_type="greater_than",
        threshold=100,
        alert_routes=[
            notehub_py.MonitorAlertRoutesInner(
                notehub_py.EmailNotification(email="someone@example.com")
            )
        ],
    )

    try:
        api_response = api_instance.update_monitor(
            project_or_product_uid, monitor_uid, monitor
        )
        print("The response of MonitorApi->update_monitor:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling MonitorApi->update_monitor: %s\n" % e)
```

**Response Members**

### `uid` {#update-monitor--uid}

*string*

The globally-unique identifier for the monitor.

### `name` {#update-monitor--name-2}

*string*

The name of the monitor.

### `description` {#update-monitor--description-2}

*string*

The description of the monitor.

### `disabled` {#update-monitor--disabled-2}

*boolean*

Whether the monitor is disabled.

### `silenced` {#update-monitor--silenced-2}

*boolean*

Whether the monitor is silenced.

### `notefile_filter` {#update-monitor--notefilefilter-2}

*array*

An array of the Notefile names the monitor is based on.

### `source_type` {#update-monitor--sourcetype-2}

*string*

The type of source the monitor watches: `"event"` or `"heartbeat"`.

### `source_selector` {#update-monitor--sourceselector-2}

*string*

A dot-delimited path to the value to monitor within the source Notefile's `body`.

### `condition_type` {#update-monitor--conditiontype-2}

*string*

The type of condition to apply to the value selected by the `source_selector`.

### `alert_routes` {#update-monitor--alertroutes-2}

*array*

An array of entities to notify when an alert is triggered.

### `last_routed_at` {#update-monitor--lastroutedat}

*date*

An ISO 8601 date for the last time the monitor was evaluated and routed.

### `routing_cooldown_period` {#update-monitor--routingcooldownperiod-2}

*string*

The time period Notehub will wait before routing another event after the monitor has been triggered.

Example Response

```json
{
  "uid": "monitor:8d19ed7e-36ae-43a1-9bb3-443bef9c02c1",
  "name": "test-monitor",
  "description": "monitor description",
  "disabled": true,
  "silenced": true,
  "notefile_filter": [
      "_track.qo"
  ],
  "source_type": "event",
  "source_selector": "temperature",
  "condition_type": "equal_to",
  "alert_routes": [
      {
          "email": "test@blues.com"
      }
  ],
  "last_routed_at": "2024-06-01 01:23:45 +0000 UTC",
  "routing_cooldown_period": "5m0s",
  "aggregate_function": "none",
  "aggregate_window": "0s"
}
```

[Jobs API](https://dev.blues.io/api-reference/notehub-api/jobs-api.md "Jobs API") [Organization API](https://dev.blues.io/api-reference/notehub-api/organization-api.md "Organization API")

Can we improve this page? [Send us feedback](mailto:devrel@blues.com)
