---
title: Monitor API - Notehub API Reference
description: The Notehub monitor API provides RESTful methods that can be used to manage project 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 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"; // String |
apiInstance.getMonitors(projectOrProductUID).then((data) => {
  console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
  console.error(error);
});
```

**Python**

```python
import notehub_py
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
    host = "https://api.notefile.net"
)

# Configure Bearer authorization: personalAccessToken
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:
    # Create an instance of the API class
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str | 

    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`

*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_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 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"; // String |
let monitorUID = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad"; // String |
apiInstance.getMonitor(projectOrProductUID, monitorUID).then((data) => {
  console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
  console.error(error);
});
```

**Python**

```python
import notehub_py
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
    host = "https://api.notefile.net"
)

# Configure Bearer authorization: personalAccessToken
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:
    # Create an instance of the API class
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str | 
    monitor_uid = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad" # str | 

    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`

*string*

The globally-unique identifier for the monitor.

### `name`

*string*

The name of the monitor.

### `description`

*string*

The description of the monitor.

### `disabled`

*boolean*

Whether the monitor is disabled.

### `silenced`

*boolean*

Whether the monitor is silenced.

### `notefile_filter`

*array*

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

### `source_selector`

*string*

The JSONata expression that selects the value to monitor from the source Notefile's `body`.

### `condition_type`

*string*

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

### `alert_routes`

*array*

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

### `last_routed_at`

*date*

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

### `routing_cooldown_period`

*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_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 an alert monitor for a Notehub [project](https://dev.blues.io/api-reference/glossary.md#project).

|                                                                                                               |                                                                                                                                                                                                        |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 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`

*string*

The name of the monitor.

### `description`

*string*

The description of the monitor.

### `disabled`

*boolean (optional)*

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

This argument defaults to `false`.

### `silenced`

*boolean (optional)*

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

This argument defaults to `false`.

### `fleet_filter`

*array (optional)*

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

### `notefile_filter`

*array*

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

### `source_selector`

*string*

A valid [JSONata expression](https://dev.blues.io/guides-and-tutorials/notecard-guides/using-jsonata-to-transform-json-in-notehub.md) that selects the value to monitor from the source Notefile's `body`. For example, `"temperature"` would select the `body.temperature` field from all monitored Notefiles.

The expression must evaluate to a single, numeric value.

### `source_type`

*string*

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

### `condition_type`

*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`

*integer*

The numeric threshold to apply to the value selected by the `source_selector`.

### `alert_routes`

*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 Routes](https://dev.blues.io/notehub/messaging-and-data-pipelines/configuring-a-slack-route.md#webhook-routes).

`{"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 Routes](https://dev.blues.io/notehub/messaging-and-data-pipelines/configuring-a-slack-route.md#bearer-routes).

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

### `aggregate_function`

*string (optional)*

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

This argument defaults to `"none"`.

### `aggregate_window`

*string (optional)*

The time window to aggregate the selected values when an aggregate function is applied. The value you provide must be a number followed by a time unit. For example, `10m` for 10 minutes, `10m30s` for 10 minutes and 30 seconds, or `5h30m10s` for 5 hours 30 minutes 10 seconds.

### `per_device`

*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`

*string (optional)*

The time period to wait before routing another event after the monitor has been triggered. The value you provide must be a number followed by a time unit. For example, `10m` for 10 minutes, `10m30s` for 10 minutes and 30 seconds, or `5h30m10s` for 5 hours 30 minutes 10 seconds.

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>'
  -d '{"name":"<name>", "description": "<description>","notefile_filter":["data.qo"],"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"; // String |
let monitorProps = {
  name: "Monitor Name", // String |
  description: "Monitor Description", // String |
  notefileFilter: ["data.qo"], // [String] |
  sourceSelector: "temperature", // String |
  sourceType: "event", // String |
  conditionType: "greater_than", // String |
  threshold: 100, // Number |
  alertRoutes: [ 
    {
      email: "example@blues.com"
    }
  ] // [MonitorAlertRoutes] |
}
let body = new NotehubJs.CreateMonitor(monitorProps); // Body or payload of monitor to be created
apiInstance.createMonitor(projectOrProductUID, body).then((data) => {
  console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
  console.error(error);
});
```

**Python**

```python
import notehub_py
from notehub_py.models.create_monitor import CreateMonitor
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
    host = "https://api.notefile.net"
)

# Configure Bearer authorization: personalAccessToken
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:
    # Create an instance of the API class
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str | 
    monitor_props = {
        "name": "Monitor Name", # str |
        "description": "Monitor Description", # str |
        "source_type": "event", # str |
        "disabled": False, # bool |
        "notefile_filter": ["data.qo"], # List[str] |
        "source_selector": "temperature", # str |
        "condition_type": "greater_than", # str |
        "threshold": 100, # int | 
        "alert_routes": [ 
            {
             "email": "example@blues.com" # str |
            }
        ],
        "silenced": False, # bool |
        "routing_cooldown_period": "5m0s", # str |
        "per_device": False # bool |
        }
    body = notehub_py.CreateMonitor(monitor_props) # Body or payload of monitor to be created

    try:
        api_response = api_instance.create_monitor(project_or_product_uid, body)
        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`

*string*

The globally-unique identifier for the monitor.

### `name`

*string*

The name of the monitor.

### `description`

*string*

The description of the monitor.

### `disabled`

*boolean*

Whether the monitor is disabled.

### `silenced`

*boolean*

Whether the monitor is silenced.

### `notefile_filter`

*array*

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

### `source_selector`

*string*

The JSONata expression that selects the value to monitor from the source Notefile's `body`.

### `condition_type`

*string*

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

### `alert_routes`

*array*

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

### `last_routed_at`

*date*

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

### `routing_cooldown_period`

*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_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 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"; // String |
let monitorUID = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad"; // String |
apiInstance.deleteMonitor(projectOrProductUID, monitorUID).then((data) => {
  console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
  console.error(error);
});
```

**Python**

```python
import notehub_py
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
    host = "https://api.notefile.net"
)

# Configure Bearer authorization: personalAccessToken
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:
    # Create an instance of the API class
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str | 
    monitor_uid = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad" # str | 

    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 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`

*string*

The name of the monitor.

### `description`

*string*

The description of the monitor.

### `disabled`

*boolean (optional)*

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

This argument defaults to `false`.

### `silenced`

*boolean (optional)*

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

This argument defaults to `false`.

### `fleet_filter`

*array (optional)*

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

### `notefile_filter`

*array*

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

### `source_selector`

*string*

A valid [JSONata expression](https://dev.blues.io/guides-and-tutorials/notecard-guides/using-jsonata-to-transform-json-in-notehub.md) that selects the value to monitor from the source Notefile's `body`. For example, `"temperature"` would select the `body.temperature` field from all monitored Notefiles.

The expression must evaluate to a single, numeric value.

### `source_type`

*string*

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

### `condition_type`

*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`

*integer*

The numeric threshold to apply to the value selected by the `source_selector`.

### `alert_routes`

*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 Routes](https://dev.blues.io/notehub/messaging-and-data-pipelines/configuring-a-slack-route.md#webhook-routes).

`{"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 Routes](https://dev.blues.io/notehub/messaging-and-data-pipelines/configuring-a-slack-route.md#bearer-routes).

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

### `aggregate_function`

*string (optional)*

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

This argument defaults to `"none"`.

### `aggregate_window`

*string (optional)*

The time window to aggregate the selected values when an aggregate function is applied. The value you provide must be a number followed by a time unit. For example, `10m` for 10 minutes, `10m30s` for 10 minutes and 30 seconds, or `5h30m10s` for 5 hours 30 minutes 10 seconds.

### `per_device`

*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`

*string (optional)*

The time period to wait before routing another event after the monitor has been triggered. The value you provide must be a number followed by a time unit. For example, `10m` for 10 minutes, `10m30s` for 10 minutes and 30 seconds, or `5h30m10s` for 5 hours 30 minutes 10 seconds.

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>'
     -d '{"name":"<name>", "description": "<description>","notefile_filter":["data.qo"],"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"; // String |
let monitorUID = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad"; // String |
let monitorProps = {
  name: "Monitor Name", // String |
  description: "Monitor Description", // String |
  notefileFilter: ["data.qo"], // [String] |
  sourceSelector: "temperature", // String |
  conditionType: "greater_than", // String |
  threshold: 100, // Number |
  alertRoutes: [ 
    {
      email: "example@blues.com"
    }
  ] // [MonitorAlertRoutes] |
}
let monitor = new NotehubJs.Monitor(monitorProps); // Monitor | Body or payload of monitor to be created
apiInstance.updateMonitor(projectOrProductUID, monitorUID, monitor).then((data) => {
  console.log("API called successfully. Returned data: " + JSON.stringify(data));
}, (error) => {
  console.error(error);
});
```

**Python**

```python
import notehub_py
from notehub_py.models.monitor import Monitor
from notehub_py.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
    host = "https://api.notefile.net"
)

# Configure Bearer authorization: personalAccessToken
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:
    # Create an instance of the API class
    api_instance = notehub_py.MonitorApi(api_client)
    project_or_product_uid = "app:2606f411-dea6-44a0-9743-1130f57d77d8" # str | 
    monitor_uid = "monitor:8bAdf00d-000f-51c-af-01d5eaf00dbad" # str | 
    monitor_props = {
        "name": "Monitor Name", # str |
        "description": "Monitor Description", # str |
        "source_type": "event", # str |
        "disabled": False, # bool |
        "notefile_filter": ["data.qo"], # List[str] |
        "source_selector": "temperature", # str |
        "condition_type": "greater_than", # str |
        "threshold": 100, # int | 
        "alert_routes": [ 
            {
             "email": "example@blues.com" # str |
            }
        ],
        "silenced": False, # bool |
        "routing_cooldown_period": "5m0s", # str |
        "per_device": False # bool |
        }
    monitor = notehub_py.Monitor(monitor_props) # Monitor | Body or payload of monitor to be created

    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`

*string*

The globally-unique identifier for the monitor.

### `name`

*string*

The name of the monitor.

### `description`

*string*

The description of the monitor.

### `disabled`

*boolean*

Whether the monitor is disabled.

### `silenced`

*boolean*

Whether the monitor is silenced.

### `notefile_filter`

*array*

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

### `source_selector`

*string*

The JSONata expression that selects the value to monitor from the source Notefile's `body`.

### `condition_type`

*string*

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

### `alert_routes`

*array*

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

### `last_routed_at`

*date*

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

### `routing_cooldown_period`

*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_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")
