Example: Flows Manager
10 min
End-to-end walkthrough: create a Node-RED flow, start it, download a backup of its file, then clean up.
Setup
from litmussdk import flowsThe 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.
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
flows.start_flow(flow_id)The flow is now running. Calling start_flow again raises an error.
3. List Flows and Find Yours
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
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.
content: bytes = flows.download_flow_file(flow_id)
with open("my_flow.json", "wb") as f:
f.write(content)Logs work the same way:
logs: bytes = flows.download_flow_logs(flow_id)
with open("my_flow.logs", "wb") as f:
f.write(logs)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:
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
flows.stop_flow(flow_id)
flows.remove_flow(flow_id)See Also
- Flows Manager - full reference
- Air gap Features - bundling flows into deployment templates