---
title: Example: Flows Manager
slug: sdk/example-usages/flows-manager
docTags: 
createdAt: 2025-03-20T19:52:55.624Z
---

End-to-end walkthrough: create a Node-RED flow, start it, download a backup of its file, then clean up.

## Setup

```python
from litmussdk import flows
```

The flow content itself (nodes, wires, tabs) is managed via Node-RED's API directly; this SDK only handles the flow lifecycle (create, start/stop, update, delete) and file download.

## 1. Create a Flow

`create_flow` returns a stopped, empty flow. The Node-RED UI or API is then used to populate its tabs.

```python
flow = flows.create_flow(
    name="My Flow",
    secret="my-flow-secret",
    memory_limit=256,
)
flow_id = flow["id"]
print(f"Created flow {flow_id}")
```

## 2. Start the Flow

```python
flows.start_flow(flow_id)
```

The flow is now running. Calling `start_flow` again raises an error.

## 3. List Flows and Find Yours

```python
all_flows = flows.list_flows()
me = next(f for f in all_flows if f["id"] == flow_id)
print(f"name={me['name']} memory_limit={me['memory_limit']}")
```

## 4. Update a Flow

```python
flows.update_flow(
    flow_id=flow_id,
    name="My Flow (renamed)",
    memory_limit=512,
)
```

## 5. Download the Flow File (4.0.x+)

The flow's `.json` definition can be downloaded as bytes for backup or air-gap deployment. **As of SDK 2.6.0**, this returns proper bytes; prior versions silently corrupted binary content via UTF-8 decode.

```python
content: bytes = flows.download_flow_file(flow_id)

with open("my_flow.json", "wb") as f:
    f.write(content)
```

Logs work the same way:

```python
logs: bytes = flows.download_flow_logs(flow_id)
with open("my_flow.logs", "wb") as f:
    f.write(logs)
```

:::BlockQuote
Both functions raise `UnsupportedVersionError` on Litmus Edge 3.x.
:::

## 6. Delete Flow Artifacts (4.0.x+)

Clean up individual files without deleting the flow itself:

```python
flows.delete_flow_logs(flow_id)
flows.delete_flow_node_modules(flow_id)
flows.delete_flow_credentials(flow_id)
flows.delete_flow_flows_json(flow_id)
```

## 7. Stop and Remove the Flow

```python
flows.stop_flow(flow_id)
flows.remove_flow(flow_id)
```

## See Also

- [Flows Manager](docId\:llYidMWF8xC7eVU7mJIk6) - full reference
- [Air gap Features](docId\:dmvQ8b6h_Macksn07230r) - bundling flows into deployment templates
