# Litmus Edge Manager 3.0.x - Edge Lifecycle: Platform Rules

## Get Platform Rule

**GET** `{{LEM_URL}}/api/v1/platform-rule/{{platform_rule_key}}`

> **New in 2.35.**

# Get Platform Rule

Returns the effective configuration of one platform rule. Platform rules are the built-in alert rules LEM evaluates for every project (edge device offline, connector offline, DeviceHub device offline, ...); an instance admin tunes them in the Admin Console (`Platform Rules`).
## Endpoint

```http
GET {{LEM_URL}}/api/v1/platform-rule/{{platform_rule_key}}
```
## Authentication

API key in a request header (case sensitive). The value is the LEM admin API token.

| URL prefix | Auth header |
|---|---|
| `{{LEM_URL}}/api/v1/...` (main fleet API) | `X-AuthToken: <token>` |
| `{{LEM_adminURL}}/admin/v1/...` (admin console, port 8446) | `X-AuthToken: <token>` |
| `{{LEM_URL}}/mpcs/...` (Marketplace Catalog) | `Authorization: <token>` (3.0.x also accepts `X-AuthToken`) |
## Parameters

| Parameter | In | Notes |
|---|---|---|
| `ruleKey` | path | **Required.** e.g. `platform.gateway.offline`. An unknown key answers `404` `Unknown platform rule key`. |

## Response

`200 OK`.

```json
{
  "ruleKey": "platform.gateway.offline",
  "name": "Edge Device Online Status",
  "description": "Detect unexpected disconnects of an edge device",
  "summary": "Edge Device is offline more than $alertDelay seconds",
  "category": "GATEWAY",
  "templateCode": "EDGE_DEVICE_ONLINE_STATUS",
  "sourceType": "METRICS",
  "enabled": true,
  "severity": 3,
  "targetValue": null,
  "alertDelay": 60,
  "projects": "ALL",
  "attributes": []
}
```

## Errors

| HTTP status         | When it happens                                                                |
|---------------------|--------------------------------------------------------------------------------|
| `400 Bad Request`   | Missing or malformed query/body parameter.                                     |
| `401 Unauthorized`  | Missing or invalid credentials.                                                |
| `403 Forbidden`     | Token lacks permission for this operation.                                     |
| `404 Not Found`     | Target entity does not exist.                                                  |
| `5xx`               | Service is unreachable, restarting, or internally errored. Inspect device logs under `System > Support`. |

> **TLS note**: edge devices use a self-signed certificate by default. Either install the device CA in your client trust store or disable certificate verification when calling this endpoint directly.


### Response

**Status**: 200 OK

```json
{
  "ruleKey": "platform.connector.status",
  "name": "Connector Status",
  "description": "Identify unplanned disconnections",
  "summary": "CC connector $name is offline more than $alertDelay seconds",
  "category": "CONNECTOR",
  "templateCode": "CONNECTOR_ONLINE_STATUS",
  "sourceType": "METRICS",
  "enabled": true,
  "severity": 3,
  "targetValue": null,
  "alertDelay": 60,
  "projects": "ALL",
  "attributes": []
}
```

---

## List Project Platform Rules

**GET** `{{LEM_URL}}/api/v1/project/platform-rule?projectId={{project_id}}`

> **New in 2.35.**

# List Project Platform Rules

Lists the platform rules that apply to a project, each with the notification (action) templates linked to it for this project.
## Endpoint

```http
GET {{LEM_URL}}/api/v1/project/platform-rule?projectId={{project_id}}
```
## Authentication

API key in a request header (case sensitive). The value is the LEM admin API token.

| URL prefix | Auth header |
|---|---|
| `{{LEM_URL}}/api/v1/...` (main fleet API) | `X-AuthToken: <token>` |
| `{{LEM_adminURL}}/admin/v1/...` (admin console, port 8446) | `X-AuthToken: <token>` |
| `{{LEM_URL}}/mpcs/...` (Marketplace Catalog) | `Authorization: <token>` (3.0.x also accepts `X-AuthToken`) |
## Parameters

| Parameter | In | Notes |
|---|---|---|
| `projectId` | query | **Required.** An unknown id answers `404`. |

## Response

`200 OK`.

```json
[
  {
    "ruleKey": "platform.gateway.offline",
    "name": "Edge Device Online Status",
    "description": "Detect unexpected disconnects of an edge device",
    "category": "GATEWAY",
    "enabled": true,
    "severity": 3,
    "actionTemplateIds": []
  }
]
```

## Errors

| HTTP status         | When it happens                                                                |
|---------------------|--------------------------------------------------------------------------------|
| `400 Bad Request`   | Missing or malformed query/body parameter.                                     |
| `401 Unauthorized`  | Missing or invalid credentials.                                                |
| `403 Forbidden`     | Token lacks permission for this operation.                                     |
| `404 Not Found`     | Target entity does not exist.                                                  |
| `5xx`               | Service is unreachable, restarting, or internally errored. Inspect device logs under `System > Support`. |

> **TLS note**: edge devices use a self-signed certificate by default. Either install the device CA in your client trust store or disable certificate verification when calling this endpoint directly.


### Response

**Status**: 200 OK

```json
[
  {
    "ruleKey": "platform.connector.status",
    "name": "Connector Status",
    "description": "Identify unplanned disconnections",
    "category": "CONNECTOR",
    "enabled": true,
    "severity": 3,
    "actionTemplateIds": []
  },
  {
    "ruleKey": "platform.devicehub.device.offline",
    "name": "DeviceHub Device Online",
    "description": "Identify unplanned disconnections of DH devices",
    "category": "DEVICE",
    "enabled": true,
    "severity": 2,
    "actionTemplateIds": []
  },
  {
    "ruleKey": "platform.gateway.offline",
    "name": "Edge Device Online Status",
    "description": "Detect unexpected disconnects of an edge device",
    "category": "GATEWAY",
    "enabled": true,
    "severity": 3,
    "actionTemplateIds": []
  },
  {
    "ruleKey": "platform.marketplace.app.state",
    "name": "Marketplace App Lifecycle",
    "description": "Detect marketplace app lifecycle changes. Requires event forwarding to be enabled on edge devices",
    "category": "APP",
    "enabled": true,
    "severity": 2,
    "actionTemplateIds": []
  },
  {
    "ruleKey": "platform.gateway.license.expiring",
    "name": "Edge Device License Expiration",
    "description": "Detect when the license for an edge device has expired",
    "category": "LICENSE",
    "enabled": true,
    "severity": 3,
    "actionTemplateIds": []
  },
  {
    "ruleKey": "platform.gateway.disk.low",
    "name": "Edge Device Free Disk Space",
    "description": "Monitor the available disk space on an edge device",
    "category": "GATEWAY",
    "enabled": true,
    "severity": 3,
    "actionTemplateIds": []
  },
  {
    "ruleKey": "platform.gateway.memory.low",
    "name": "Edge Device Memory Available",
    "description": "Monitor the available memory on an edge device",
    "category": "GATEWAY",
    "enabled": true,
    "severity": 3,
    "actionTemplateIds": []
  },
  {
    "ruleKey": "platform.gateway.cpu.busy",
    "name": "Edge Device CPU Idle",
    "description": "Monitor the CPU usage on an edge device",
    "category": "GATEWAY",
    "enabled": true,
    "severity": 2,
    "actionTemplateIds": []
  }
]
```

---

## Set Platform Rule Notifications

**POST** `{{LEM_URL}}/api/v1/project/platform-rule/{{platform_rule_key}}/notifications?projectId={{project_id}}`

> **New in 2.35.**

# Set Platform Rule Notifications

Replaces the notification (action) templates linked to a platform rule for one project. The list replaces the previous one; send `[]` to unlink all.
## Endpoint

```http
POST {{LEM_URL}}/api/v1/project/platform-rule/{{platform_rule_key}}/notifications?projectId={{project_id}}
```
## Authentication

API key in a request header (case sensitive). The value is the LEM admin API token.

| URL prefix | Auth header |
|---|---|
| `{{LEM_URL}}/api/v1/...` (main fleet API) | `X-AuthToken: <token>` |
| `{{LEM_adminURL}}/admin/v1/...` (admin console, port 8446) | `X-AuthToken: <token>` |
| `{{LEM_URL}}/mpcs/...` (Marketplace Catalog) | `Authorization: <token>` (3.0.x also accepts `X-AuthToken`) |
## Parameters

| Parameter | In | Notes |
|---|---|---|
| `ruleKey` | path | **Required.** |
| `projectId` | query | **Required.** |

## Request body

```json
{
  "actionTemplateIds": ["e0g2nwz0dtq0t19nq2r5roet3"]
}
```
## Response

`200 OK`. `{"code": "...", "message": "..."}`.
## Errors

| HTTP status         | When it happens                                                                |
|---------------------|--------------------------------------------------------------------------------|
| `400 Bad Request`   | Missing or malformed query/body parameter.                                     |
| `401 Unauthorized`  | Missing or invalid credentials.                                                |
| `403 Forbidden`     | Token lacks permission for this operation.                                     |
| `404 Not Found`     | Target entity does not exist.                                                  |
| `5xx`               | Service is unreachable, restarting, or internally errored. Inspect device logs under `System > Support`. |

> **TLS note**: edge devices use a self-signed certificate by default. Either install the device CA in your client trust store or disable certificate verification when calling this endpoint directly.


### Request Body

```json
{
  "actionTemplateIds": [
    "e0g2nwz0dtq0t19nq2r5roet3"
  ]
}
```

---

