# Managing Power Automate flows

List the flows of an environment, read one flow's details and turn flows on and off.

This page shows how to work with the flows of an environment from a Python service:

1. Listing the flows
2. Reading one flow's details
3. Turning a flow off and back on

## Connection and IDs {#connection-and-ids}

The app registration, the Power Automate connection in the Zato Dashboard and the flow ID are the same as in the [tutorial](https://zato.io/docs/dev/examples/cloud/power-automate/tutorial.html), so set them up as described there first.

## Listing flows {#listing-flows}

[`conn.list_flows`](https://zato.io/docs/dev/examples/cloud/power-automate/api/flows.html#list_flows) returns every flow in the connection's environment. The flows are under `value`, each flow's ID is its `name`, and its display name and state are under `properties`.

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class ListFlows(Service):

    name = 'power-automate.list-flows'

    def handle(self):

        conn = self.microsoft.power_platform['Zato Power Automate']

        response = conn.list_flows()

        flows = []
        for flow in response['value']:
            flows.append({
                'id': flow['name'],
                'display_name': flow['properties']['displayName'],
                'state': flow['properties']['state'],
            })

        self.response.payload = {'flows': flows}
```

```json
{"flows": [
  {"id": "8f3c1a2e-5b7d-4e9a-b6c0-2d4f7a9e1c35", "display_name": "Discount eligibility", "state": "Started"},
  {"id": "c41d9b07-2e6f-4a83-9d15-7b0e3f6a8c92", "display_name": "Order confirmation", "state": "Stopped"}
]}
```

## Reading one flow {#reading-one-flow}

[`conn.get_flow`](https://zato.io/docs/dev/examples/cloud/power-automate/api/flows.html#get_flow) returns one flow with the same `properties` the listing has, plus the flow's definition and its triggers.

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class GetFlow(Service):

    name = 'power-automate.get-flow'
    input = 'flow_id'

    def handle(self):

        conn = self.microsoft.power_platform['Zato Power Automate']

        flow = conn.get_flow(self.request.input.flow_id)

        self.response.payload = {
            'display_name': flow['properties']['displayName'],
            'state': flow['properties']['state'],
            'created': flow['properties']['createdTime'],
        }
```

```json
{"display_name": "Discount eligibility", "state": "Started", "created": "2026-08-14T10:22:07.5312906Z"}
```

## Turning a flow off and on {#turning-a-flow-off-and-on}

[`conn.disable_flow`](https://zato.io/docs/dev/examples/cloud/power-automate/api/flows.html#disable_flow) stops a flow, so that its triggers no longer start runs, and [`conn.enable_flow`](https://zato.io/docs/dev/examples/cloud/power-automate/api/flows.html#enable_flow) starts it again. Both return nothing. The service below takes the flow ID and the state to put it in.

```python
# -*- coding: utf-8 -*-

# Zato
from zato.server.service import Service

class SetFlowState(Service):

    name = 'power-automate.set-flow-state'
    input = 'flow_id', 'is_enabled'

    def handle(self):

        flow_id = self.request.input.flow_id
        is_enabled = self.request.input.is_enabled

        conn = self.microsoft.power_platform['Zato Power Automate']

        if is_enabled:
            conn.enable_flow(flow_id)
        else:
            conn.disable_flow(flow_id)

        # Read the state back to confirm it.
        flow = conn.get_flow(flow_id)

        self.response.payload = {'state': flow['properties']['state']}
```

Invoked with `{"flow_id": "8f3c1a2e-5b7d-4e9a-b6c0-2d4f7a9e1c35", "is_enabled": false}`, the service returns:

```json
{"state": "Stopped"}
```

## See also {#see-also}

- [Power Automate API - Flows](https://zato.io/docs/dev/examples/cloud/power-automate/api/flows.html) - list\_flows, get\_flow, enable\_flow and disable\_flow, with every parameter
- [Monitoring Power Automate runs](https://zato.io/docs/dev/examples/cloud/power-automate/monitoring-runs.html) - The runs of a flow - reading, cancelling and resubmitting them
- [Power Automate API - Connection](https://zato.io/docs/dev/examples/cloud/power-automate/api/connection.html) - invoke, for the parts of the API without a method of their own

## Learn more {#learn-more}

- [Development documentation](https://zato.io/docs/dev/) - The complete reference for writing services
- [Requests and responses](https://zato.io/docs/dev/request-response/) - What a service receives, what it returns and how both are structured
- [Integration examples](https://zato.io/docs/dev/examples/) - Ready-made code for the systems you are likely to connect to
- [IDE and debugging](https://zato.io/docs/dev/ide/) - Write services in the Dashboard or in your own editor
- [Data models](https://zato.io/docs/dev/model/) - Declare inputs and outputs and have them validated for you
- [In-depth API tutorial](https://zato.io/tutorials/main/01.html) - The full platform tutorial, from installation to production patterns
