How to retrieve Power Automate flows with trigger as “When an HTTP request is received”

Microsoft recently announced important changes to how Power Automate HTTP trigger URLs are handled. If you’re using flows with the trigger “When an HTTP request is received”, these updates may impact you.

For many organizations, HTTP triggers are a critical part of integrations and automation scenarios. But with the recent updates, admins and developers need a way to quickly identify and audit which flows are using these triggers — and retrieve their callback URLs for review.

The Challenge

The Microsoft 365 CLI (m365) is a great tool to list and manage Power Automate flows. However, it does not return callback URLs for HTTP triggers. These URLs are necessary when auditing flows, especially if you need to revalidate or update them.

The Solution: Custom Script

To fill this gap, we’ve created a simple script that:

  • Uses M365 CLI to fetch a list of Power Automate flows
  • Calls the api.flow.microsoft.com endpoint directly to fetch callback URLs for flows using HTTP triggers
  • Outputs all flows and their trigger URLs for auditing

This allows admins to quickly review flows impacted by the recent changes and take corrective action.

Here is the script

<# 
=====================================================================================
 PowerShell Script: Fetch HTTP Trigger Callback URLs for Specific Power Automate Flows
 Author: Siddharth Vaghasia(siddharth-vaghasia)
=====================================================================================

 PREREQUISITES:
 1. Install Node.js (https://nodejs.org) → Required for npm.
 2. Install Microsoft 365 CLI globally:
       npm install -g @pnp/cli-microsoft365
    or use:
       npx @pnp/cli-microsoft365 <command>

 3. Install Az PowerShell module:
       Install-Module Az.Accounts -Scope CurrentUser -Force

 This script:
 - Checks prerequisites (Az.Accounts, M365 CLI).
 - Logs into Microsoft 365 CLI 
 - Gets all flows in the specified environment.
 - Fetches HTTP trigger callback URL for each flow.
 - Exports results to CSV.

=====================================================================================
#>

# ===============================
# Check & Install Prerequisites
# ===============================

# Ensure Microsoft 365 CLI is available
if (-not (Get-Command m365 -ErrorAction SilentlyContinue)) {
    Write-Host "⚠️ Microsoft 365 CLI not found." -ForegroundColor Yellow
    Write-Host " Please install manually using npm:" -ForegroundColor Cyan
    Write-Host "   npm install -g @pnp/cli-microsoft365" -ForegroundColor Cyan
    Write-Host "   (Requires Node.js: https://nodejs.org)" -ForegroundColor Cyan
    # Continue anyway, but 'm365' commands will fail if not installed
}else {
    Write-Host "✅ Microsoft 365 CLI is available." -ForegroundColor Green
}

# Ensure Az.Accounts module is available
if (-not (Get-Module -ListAvailable Az.Accounts)) {
    Write-Host "⚠️ Az.Accounts module not found. Installing..." -ForegroundColor Yellow
    try {
        Install-Module Az.Accounts -Scope CurrentUser -Force -AllowClobber
        Write-Host "✅ Az.Accounts module installed successfully." -ForegroundColor Green
    }
    catch {
        Write-Host "❌ Failed to install Az.Accounts. Please install manually with:" -ForegroundColor Red
        Write-Host "   Install-Module Az.Accounts -Scope CurrentUser -Force" -ForegroundColor Cyan
    }
}else {
    Write-Host "✅ Az.Accounts module already available." -ForegroundColor Green
}

# Import Az.Accounts
Import-Module Az.Accounts -ErrorAction SilentlyContinue


# ===============================
# Global Variables
# ===============================

# Environment ID
$environmentId = "6efebc14-a15f-eeda-bc96-d2f70a81fe09"

# API URL for Flow
$flowUrl = "https://api.flow.microsoft.com"

# Output path
$outputCsv = "C:\testpath\ProdFlows_Output.csv"

# Number of flows to process
$maxFlowsToProcess = 50


# ===============================
# Main Script
# ===============================

# Step 1: Log in to Microsoft 365 CLI (interactive)
Write-Host " Ensure you're logged into Microsoft 365 CLI (run 'm365 login' before running this script)" -ForegroundColor Cyan

# Step 2: Get all flows in environment
$allFlows = m365 flow list --environmentName $environmentId --asAdmin --output json | ConvertFrom-Json

# Step 3: Take first N flows (or less if total < N)
$flows = $allFlows | Select-Object -First $maxFlowsToProcess
Write-Host "ℹ️ Processing $($flows.Count) flows (max requested: $maxFlowsToProcess)" -ForegroundColor Yellow

# Step 4: Login to Azure to fetch access token
Login-AzAccount -UseDeviceAuthentication
$accessToken = (Get-AzAccessToken -ResourceUrl "https://service.flow.microsoft.com/").Token

# Step 5: Prepare results array
$results = @()

# Step 6: Loop through each flow and fetch callback URL
foreach ($flow in $flows) {
    $flowId        = $flow.name
    $flowName      = $flow.properties.displayName
    $flowState     = $flow.properties.state
    $createdTime   = $flow.properties.createdTime
    $modifiedTime  = $flow.properties.lastModifiedTime
    $ownerId       = $flow.properties.creator.userId
    
    
    # --- Fetch full flow details ---
    $flowDetails = m365 flow get --name $flowId --environmentName $environmentId --asAdmin --output json | ConvertFrom-Json
    
    $triggerKind   = $flowDetails.triggers

    Write-Host " Fetching trigger URL for Flow: $flowName ($flowId)" -ForegroundColor Cyan

    $newTriggerUrl = ""
    $path = "providers/Microsoft.ProcessSimple/environments/$environmentId/flows/$flowId/triggers/manual/listCallbackUrl?api-version=2016-11-01"

    try {
        $response = Invoke-RestMethod -Uri "$flowUrl/$path" `
            -Method POST `
            -Headers @{
                "Authorization" = "Bearer $accessToken"
                "Content-Type"  = "application/json"
            }

        # Parse response schema
        if ($response.response.value) {
            $newTriggerUrl = $response.response.value
        }
        elseif ($response.'$content') {
            $newTriggerUrl = $response.'$content'
        }
    }
    catch {
        Write-Host "❌ Failed to fetch trigger URL for Flow: $flowId" -ForegroundColor Red
    }

    # Add new property to results
    $results += [PSCustomObject]@{
        FlowId        = $flowId
        FlowName      = $flowName
        State         = $flowState
        CreatedTime   = $createdTime
        ModifiedTime  = $modifiedTime
        OwnerId       = $ownerId
        TriggerType   = $triggerKind
        NewTriggerURL = $newTriggerUrl
    }
}

# Step 7: Export results
$results | Export-Csv -Path $outputCsv -NoTypeInformation -Force
Write-Host "✅ Report generated at: $outputCsv" -ForegroundColor Green

Benefits

  • Faster audits of all flows using HTTP request triggers

  • Visibility into callback URLs not available directly in CLI

  • Preparedness for Microsoft’s URL changes, ensuring minimal disruption

Conclusion

With these changes from Microsoft, now is the right time to review and audit your HTTP-triggered flows. This script makes it much easier to find affected flows and update them before issues occur.

(Visited 1 times, 1 visits today)