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

The app registration, the Power Automate connection in the Zato Dashboard and the flow ID are the same as in the tutorial, so set them up as described there first.

Listing flows

conn.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.

# -*- 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}
{"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

conn.get_flow returns one flow with the same properties the listing has, plus the flow's definition and its triggers.

# -*- 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'],
        }
{"display_name": "Discount eligibility", "state": "Started", "created": "2026-08-14T10:22:07.5312906Z"}

Turning a flow off and on

conn.disable_flow stops a flow, so that its triggers no longer start runs, and conn.enable_flow starts it again. Both return nothing. The service below takes the flow ID and the state to put it in.

# -*- 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:

{"state": "Stopped"}

See also

PageWhat it covers
Power Automate API - Flowslist_flows, get_flow, enable_flow and disable_flow, with every parameter
Monitoring Power Automate runsThe runs of a flow - reading, cancelling and resubmitting them
Power Automate API - Connectioninvoke, for the parts of the API without a method of their own

Learn more