# alert rules — NCM API

The rules that decide which events raise an alert and where it is sent. Full lifecycle: list, create, patch and delete rules in your account. Rules deliver to the receivers configured under alert push destinations, and the alerts they raise appear under alerts.

Base URL: https://www.cradlepointecm.com/api/v2

### GET /alert_rules/

Get information about alert_rules

Use the GET method on this endpoint to retrieve alert_rules records. Use the available filtering fields to narrow or broaden your search.

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| X-ECM-API-ID | header | string | yes | <strong>ECM API app Id</strong> |
| X-ECM-API-KEY | header | string | yes | <strong>ECM API app key</strong> |
| X-CP-API-ID | header | string | yes | <strong>Cradlepoint API app Id</strong> |
| X-CP-API-KEY | header | string | yes | <strong>Cradlepoint API access key</strong> |
| alert_config_id | query | timeuuid | no | Unique ID of an Alert Rule |
| account | query | url | no | Parent account |
| schedule | query | string | no | Schedule for sending notifications |
| associated_accounts | query | integer | no | A list of account-identfier ints |
| associated_groups | query | integer | no | A list of group-identfier ints |
| filter_criteria | query | json | no | Alert types to add to the Alert Rule |
| email_destinations | query | integer | no | Email dests (list of ints) used for email notifications |
| http_destinations | query | timeuuid | no | HTTP dests (list of timeuuids) for push notifications |
| updated_at | query | timestamp | no | Last time an Alert Rule was modified |
| settings | query | json | no | Additional settings for PDP service-overage alerts |
| limit | query | integer | no | Restricts the number of records returned in a recordset to this value. Max value is 500. |

**Example request**

```bash
curl "https://www.cradlepointecm.com/api/v2/alert_rules/" \
  -H "X-CP-API-ID: <cp-api-id>" \
  -H "X-CP-API-KEY: <cp-api-key>" \
  -H "X-ECM-API-ID: <ecm-api-id>" \
  -H "X-ECM-API-KEY: <ecm-api-key>"
```

**Response 200** — Example response.

```json
{
  "data": [
    {
      "account": "https://www.cradlepointecm.com/api/v2/accounts/35065/",
      "alert_config_id": "e81f4500-1e13-11b2-bfff-ffffffffffff",
      "associated_accounts": [
        86819,
        84906,
        86737,
        36023,
        35065,
        84954
      ],
      "associated_groups": [],
      "email_destinations": [
        63944
      ],
      "external_rules": null,
      "filter_criteria": {
        "alert_type__in": [
          "geofence_proximity_change"
        ]
      },
      "http_destinations": [],
      "last_summary_ts": "2021-04-27T22:28:45.262710+00:00",
      "schedule": null,
      "settings": null,
      "updated_at": "2021-04-27T22:29:16.096135+00:00"
    }
  ],
  "meta": {
    "limit": 20,
    "next": null
  }
}
```

### POST /alert_rules/

Create an alert_rules record

Use the POST method on this endpoint to create a new alert_rules record. Include the fields/values to add for the record in the 'Content' field as a JSON object.

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| X-ECM-API-ID | header | string | yes | <strong>ECM API app Id</strong> |
| X-ECM-API-KEY | header | string | yes | <strong>ECM API app key</strong> |
| X-CP-API-ID | header | string | yes | <strong>Cradlepoint API app Id</strong> |
| X-CP-API-KEY | header | string | yes | <strong>Cradlepoint API access key</strong> |

**Request body**

**Example request**

```bash
curl -X POST "https://www.cradlepointecm.com/api/v2/alert_rules/" \
  -H "X-CP-API-ID: <cp-api-id>" \
  -H "X-CP-API-KEY: <cp-api-key>" \
  -H "X-ECM-API-ID: <ecm-api-id>" \
  -H "X-ECM-API-KEY: <ecm-api-key>" \
  -H "Content-Type: application/json" \
  -d '{ ... }'
```

**Response 200** — Example response.

```json
{
  "account": "https://www.cradlepointecm.com/api/v2/accounts/<account number>/",
  "alert_config_id": "1a5faaf8-6649-11eb-9823-42edcb7bf284",
  "associated_accounts": [],
  "associated_groups": [],
  "email_destinations": [],
  "external_rules": null,
  "filter_criteria": {
    "alert_type__in": [
      "account_locked"
    ]
  },
  "http_destinations": [
    "1cf2c024-64e5-11eb-be7d-42edcb7bf284"
  ],
  "last_summary_ts": null,
  "resource_url": "https://www.cradlepointecm.com/api/v2/alert_rules/",
  "schedule": "daily",
  "settings": null,
  "updated_at": "2021-02-03T17:56:12.605494+00:00"
}
```

### PATCH /alert_rules/{alert_config_id}/

Update an alert_rules record

<p>This operation updates an Alert Rule.</p>

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| X-ECM-API-ID | header | string | yes | <strong>ECM API app Id</strong> |
| X-ECM-API-KEY | header | string | yes | <strong>ECM API app key</strong> |
| X-CP-API-ID | header | string | yes | <strong>Cradlepoint API app Id</strong> |
| X-CP-API-KEY | header | string | yes | <strong>Cradlepoint API access key</strong> |
| alert_config_id | path | timeuuid | yes | Unique ID of an Alert Rule |

**Request body**

**Example request**

```bash
curl -X PATCH "https://www.cradlepointecm.com/api/v2/alert_rules/{alert_config_id}/" \
  -H "X-CP-API-ID: <cp-api-id>" \
  -H "X-CP-API-KEY: <cp-api-key>" \
  -H "X-ECM-API-ID: <ecm-api-id>" \
  -H "X-ECM-API-KEY: <ecm-api-key>" \
  -H "Content-Type: application/json" \
  -d '{ ... }'
```

**Response 200** — No response was specified

### DELETE /alert_rules/{alert_config_id}/

Delete an alert_rules record

<p>This operation deletes an account.</p>

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| X-ECM-API-ID | header | string | yes | <strong>ECM API app Id</strong> |
| X-ECM-API-KEY | header | string | yes | <strong>ECM API app key</strong> |
| X-CP-API-ID | header | string | yes | <strong>Cradlepoint API app Id</strong> |
| X-CP-API-KEY | header | string | yes | <strong>Cradlepoint API access key</strong> |
| alert_config_id | path | timeuuid | yes | Object ID of Alert Rule to delete |

**Example request**

```bash
curl -X DELETE "https://www.cradlepointecm.com/api/v2/alert_rules/{alert_config_id}/" \
  -H "X-CP-API-ID: <cp-api-id>" \
  -H "X-CP-API-KEY: <cp-api-key>" \
  -H "X-ECM-API-ID: <ecm-api-id>" \
  -H "X-ECM-API-KEY: <ecm-api-key>"
```

**Response 200** — No response was specified
