---
parent: /workflows/agents.md
back_out_url: /workflows/agents.md
---

# Workflow 14: Create LEM Project Alert (Trigger + Action)

> You are at https://api.litmus.io/workflows/create-project-alert.md
> Parent: https://api.litmus.io/workflows/agents.md
> If this is the wrong workflow, back out to the index above.

## 14. Create LEM Project Alert (Trigger + Action)

**UI trigger**: LEM -> Edge Lifecycle Management -> Alerts -> *Add Action* -> *Add Trigger*

A LEM alert has two halves that must be created in order: the **action template** (how to notify -- email, Slack, webhook, PagerDuty) is created first and returns an `id`; the **trigger** (when to fire -- metrics threshold or event match) references that `id` in its `actions` array.

### Step table

| Step | Name in Collection | Method | Endpoint | Body / Notes | Output |
|------|-------------------|--------|----------|-------------|--------|
| 1 | Add Action - Email *(or Slack / Webhook / Pagerduty)* | `POST` | `{{LEM_URL}}/api/v1/project/action/templates/{{project_id}}` | Body shape varies by channel; see saved examples | Action `id` (e.g. `bp0pgdjum4l1ltore344h9j1p`) |
| 2 | Project Triggers *(optional pre-flight)* | `GET` | `{{LEM_URL}}/api/v1/project/trigger/definition` | -- | Existing triggers (avoid duplicates) |
| 3 | Create Trigger - Metrics *(or Event)* | `POST` | `{{LEM_URL}}/api/v1/project/trigger/definition/{{project_id}}` | Body must include `actions: ["<action_id_from_step_1>"]`. Set `sourceType: "METRICS"` or `"EVENTS"`, `scopeType: "USER"` or `"PROJECT"`, `deviceId: null` (all devices) or specific deviceId | Trigger `id` |
| 4 *(verify)* | List of Incidents | `GET` | `{{LEM_URL}}/api/v1/project/incident/{{project_id}}` | Incidents accumulate as triggers fire | Incident list with severity, timestamp, action result |

### Cleanup

| Operation | Endpoint |
|---|---|
| Delete Action | `DELETE /api/v1/project/action/templates/{{project_id}}/{{alert_id}}` |
| Delete Trigger | `DELETE /api/v1/project/trigger/definition/{{project_id}}/{{trigger_id}}` |

> **Project alerts vs Instance alerts**: this chain creates **project-scoped** alerts that notify project members about edge metric/event conditions. For **LEM-instance-level** alerts (notify ops about LEM itself), use the parallel chain at `/admin/v1/instance-alert/trigger/...` and `/admin/v1/instance-alert/action/templates/...`.


---
