> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobilerun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Runs and troubleshooting

> Check, test, enable, and monitor routines, then diagnose failing runs.

## Run now

Open a routine and choose **Run now** to supply input and enqueue live executions across bound devices. The adjacent menu offers **Schedule run…** for a run later. For an enabled, healthy routine, run now through the API:

```typescript TypeScript theme={null}
import { MobilerunSDK } from '@mobilerun/sdk';

const mobilerun = new MobilerunSDK();
const started = await mobilerun.api.workflows.flows.run('FLOW_ID', { payload: {} }, {
  headers: { 'Idempotency-Key': crypto.randomUUID() },
});
console.log(started.data.executionIds, started.data.enqueuedCount);
```

```python Python theme={null}
from uuid import uuid4
from mobilerun_sdk import MobilerunSDK

mobilerun = MobilerunSDK()
started = mobilerun.api.workflows.flows.run(
    "FLOW_ID", payload={}, idempotency_key=str(uuid4()),
)
print(started.data.execution_ids, started.data.enqueued_count)
```

```bash cURL theme={null}
curl --fail-with-body "https://api.mobilerun.ai/v1/flows/$FLOW_ID/run" \
  -H "Authorization: Bearer $MOBILERUN_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"payload":{}}'
```

A `202` response reports `executionIds` and `enqueuedCount`. Check `skipped` and `enqueueFailed` too: accepting the request does not mean every target started. Keep the same idempotency key when retrying the same request; use a new one for a new run.

## Runs history

In the dashboard, open the routine's **Runs** tab and select a run to inspect its status, errors, timings, screenshots, and files. Select a step to inspect **Input**, **Output**, and **Log**. The **Steps** tab shows what the routine does.

```typescript TypeScript theme={null}
import { MobilerunSDK } from '@mobilerun/sdk';

const mobilerun = new MobilerunSDK();
const runs = await mobilerun.api.workflows.executions.list({ flowId: 'FLOW_ID' });
console.log(runs.items);
const execution = await mobilerun.api.workflows.executions.retrieve('EXECUTION_ID', {
  query: { include: 'input' },
});
console.log(execution.data);
```

```python Python theme={null}
from mobilerun_sdk import MobilerunSDK

mobilerun = MobilerunSDK()
runs = mobilerun.api.workflows.executions.list(flow_id="FLOW_ID")
print(runs.items)
execution = mobilerun.api.workflows.executions.retrieve("EXECUTION_ID", extra_query={"include": "input"})
print(execution.data)
```

```bash cURL theme={null}
curl --fail-with-body "https://api.mobilerun.ai/v1/executions?flowId=$FLOW_ID" \
  -H "Authorization: Bearer $MOBILERUN_API_KEY"
curl --fail-with-body "https://api.mobilerun.ai/v1/executions/$EXECUTION_ID?include=input" \
  -H "Authorization: Bearer $MOBILERUN_API_KEY"
```

`include=input` adds recorded inputs to `result.steps` when available. Redaction is best effort; keep secrets out of inputs and logs. See [Results](https://docs.mobilerun.ai/agents/results.md) for how Matty presents files and structured output.

## Find and download files

Open **Routines → your routine → Runs**, then select a run. In **Files**, inspect the files its
steps produced and their delivery status. **Saved copies** lists ready files in Mobilerun storage;
open a file's action menu and choose **Download** or **Delete file**. A step's **Output** also
contains the `files.upload` result. If a saved copy is not there yet, check delivery status:
copying to storage can finish after the steps. See [Save files](https://docs.mobilerun.ai/routines/functions.md#save-files-filesupload)
for the required Delivery destination and folder.

SDK 6.3.2 or later provides `routineFiles` (Python `routine_files`). List by `executionId` to find
one run's saved copies, then call the file object's `download()` to get bytes. These examples
list the first page and download its first file; replace the execution ID with a run you own.

```typescript TypeScript theme={null}
import { writeFile } from 'node:fs/promises';
import { MobilerunSDK } from '@mobilerun/sdk';

const mobilerun = new MobilerunSDK();
const page = await mobilerun.routineFiles.list({ executionId: 'EXECUTION_ID' });
for (const file of page.items) console.log(file.id, file.filename, file.folder);
const first = page.items[0];
if (first) await writeFile('routine-output.bin', await first.download());
```

```python Python theme={null}
from pathlib import Path
from mobilerun_sdk import MobilerunSDK

mobilerun = MobilerunSDK()
page = mobilerun.routine_files.list(execution_id="EXECUTION_ID")
for file in page.items:
    print(file.id, file.filename, file.folder)
if page.items:
    Path("routine-output.bin").write_bytes(page.items[0].download())
```

```bash cURL theme={null}
curl --fail-with-body --get https://api.mobilerun.ai/v1/routine-files \
  -H "Authorization: Bearer $MOBILERUN_API_KEY" \
  --data-urlencode "executionId=$EXECUTION_ID" > routine-files.json
FILE_ID=$(jq -er '.items[0].id' routine-files.json)
curl --fail-with-body --location \
  "https://api.mobilerun.ai/v1/routine-files/$FILE_ID/download" \
  -H "Authorization: Bearer $MOBILERUN_API_KEY" \
  --output routine-output.bin
```

The download endpoint redirects to a short-lived link; the SDK follows it and returns bytes.
Request a fresh download rather than storing the signed URL. Lists support `folder`, `flowId`,
and `executionId` filters. Iterate `routineFiles.list()` with `for await` (Python `for`) to load
all pages automatically. Saved file handles have no `get()` or `refresh()`; read their metadata
from list results.

| Operation | TypeScript | Python | HTTP |
| - | - | - | - |
| List folders | `routineFiles.listFolders({ flowId })` | `routine_files.list_folders(flow_id=flow_id)` | `GET /v1/routine-files/folders` |
| Delete one file | `routineFiles.fromId(fileId).delete()` | `routine_files.from_id(file_id).delete()` | `DELETE /v1/routine-files/{fileId}` |
| Delete a run's files | `routineFiles.deleteMany({ executionId })` | `routine_files.delete_many(execution_id=execution_id)` | `DELETE /v1/routine-files?executionId=…` |
| Delete a folder's files | `routineFiles.deleteMany({ folder })` | `routine_files.delete_many(folder=folder)` | `DELETE /v1/routine-files?folder=…` |

Deletion is permanent. Bulk deletion takes exactly one of `folder` or `executionId`.
Saved files count toward [storage](https://docs.mobilerun.ai/credits.md#storage) and remain until you delete them or their routine.

## Fix a blocked or failing routine

A routine's health is `healthy`, `failing`, or `blocked`; a blocked routine does not run. Read `GET /v1/flows/{flowId}` for its status, last failure, and health settings. Fix the underlying problem, such as a missing device, invalid step input, or deleted function.

* Inspect configured steps with `GET /v1/flows/{flowId}/actions`; add, remove, or replace actions through the same API.
* Inspect repair attempts with `GET /v1/flows/{flowId}/repairs`. Automatic repair depends on the routine's settings and failure type; it is not guaranteed for every error.
* After fixing the cause, call `POST /v1/flows/{flowId}/unblock`. The API checks the routine again and returns `still_broken` if it cannot resume.

For Matty's repair and approval behavior, see [When a run fails](https://docs.mobilerun.ai/agents/workflows.md#when-a-run-fails-or-repairs-itself).

## Recording

Choose **Recording** → **Off**, **Every run**, or **Selected steps** to control capture. Inspect available recordings alongside screenshots and files in **Runs**. See [Results](https://docs.mobilerun.ai/agents/results.md) for how Matty presents output.

## Check vs Test run

**Check** is a side-effect-free dry run. Send the create body to `POST /v1/flows/validate` and inspect `data.valid`, `errors`, and `warnings`. Call `POST /v1/flows/{flowId}/dry-run` with `{"payload": {}}` to inspect resolved steps and trigger gates without executing work. A disabled routine can report `wouldFire: false`; this alone does not mean its steps are invalid.

**Test run** performs real verification, including on a disabled routine. Call `POST /v1/flows/{flowId}/verify` with a fresh UUID `invocationId`, a bound `deviceId`, and `payload`. Inspect the execution and wait for success.

## Enable

For verified activation, send the successful execution ID as `verificationExecutionId` to `POST /v1/flows/{flowId}/activate`. Verification must cover the unchanged graph; if you edit it, verify again. Owners can alternatively enable a routine with steps directly through `PATCH /v1/flows/{flowId}` with `{"enabled": true}`.

## Self-healing

**Self-healing** controls appear only for routines with an agent. Repairs require eligible configuration and failures, and repair availability; they are not guaranteed for every error. Inspect repair attempts and resolve the underlying cause as described above.

## Capacity and cost

Check `GET /v1/flows/capacity` before creating or cloning routines. Capacity counts enabled and disabled routines in each owner/agent bucket; pausing a routine does not free its slot. See [Credits & usage](https://docs.mobilerun.ai/credits.md) for device minutes, function minutes, and agent usage.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.