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

# Workflow 12: Deploy Application to Edge Device (LEM Async-Task)

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

## 12. Deploy Application to Edge Device (LEM Async-Task)

**UI trigger**: LEM -> Edge Lifecycle Management -> Applications -> *Launch Application*

LEM long-running operations (app launch, ML deploy, software update) are wrapped in an async-task envelope. The client POSTs a task description, gets a `taskId`, and polls subtask status until `SUCCESS`. Same pattern underlies multiple LEM ops.

### Step table

| Step | Name in Collection | Method | Endpoint | Body / Notes | Output |
|------|-------------------|--------|----------|-------------|--------|
| 1 | Catalogs | `GET` | `{{LEM_URL}}/mpcs/catalogs` | Header: `Authorization: {{LEM_AdminApiToken}}` (NOT X-AuthToken) | `catalogId` |
| 2 | Catalog Applications | `GET` | `{{LEM_URL}}/mpcs/catalogs/{catalogId}/applications` | Same `Authorization` header | `applicationId`, `applicationName`, `applicationVersion` |
| 3 | Launch Application to Edge Device | `POST` | `{{LEM_URL}}/api/v1/async-task/task-with-subtasks` | Header: `X-AuthToken: {{LEM_AdminApiToken}}`. Body: `{ name, companyName, projectId, type: "MARKETPLACE_APPLICATION_LAUNCH", subtasks: [{ deviceId, type: "MARKETPLACE_APPLICATION_LAUNCH", params: { applicationId, applicationName, applicationVersion, catalogId, catalogName, catalogUrl, applicationParameters } }] }` | `{ taskId }` |
| 4 | Verify If Deploy Task is Complete *(poll)* | `GET` | `{{LEM_URL}}/api/v1/async-task/{{task_id}}/subtasks` | Poll until each subtask `status == "SUCCESS"`. Other states: `PENDING`, `IN_PROGRESS`, `FAILED` | Subtask list with status |
| 5 | Apps List for Device | `GET` | `{{LEM_URL}}/api/v1/marketplace/app/plain?...` | -- | Confirm app installed on device |

> **Same async-task wrapper used by**: `Deploy ML model` (`type: "ANALYTICS_ML_MODEL_UPLOAD"`), software updates (`type: "FIRMWARE_UPDATE"`), and other long-running fleet ops. The `Software Update History` endpoint at `/api/v1/async-task/subtasks` reads recent runs across all task types.

> **Auth nuance**: steps 1 and 2 hit `/mpcs/` and require `Authorization: {{LEM_AdminApiToken}}`. Steps 3-5 hit `/api/v1/` and require `X-AuthToken: {{LEM_AdminApiToken}}`. Sending the wrong header returns 401.


---
