How to Create a Power Automate Loop Based on HTTP Message Count
Question details
The user needs to process an entire batch of messages returned by a MuleSoft HTTP API in Power Automate, rather than consuming just a single message from the queue.

- Product
- Power Automate
- Device & OS
- not provided
- Scenario
- Integrating a MuleSoft HTTP API with a Power Automate flow to retrieve and handle multiple queued messages consecutively.
- Observed behavior
- The current flow setup only processes one queue message at a time, failing to iterate through the complete HTTP response message count or array.
Ensure you have the exact JSON response structure from your MuleSoft HTTP API, as the correct loop configuration depends on whether the API returns an array of messages or a specific total count property.
Configure an Apply to each or Do until Loop in Power Automate
Use Power Automate's built-in looping actions to iterate through the HTTP response array or count property, ensuring all messages are processed.
To process multiple messages from an API call, you must dynamically instruct Power Automate to repeat your processing logic for every item returned. This prevents the flow from stopping after reading only the first message in the queue.
Add a 'Parse JSON' action immediately after your HTTP request. Provide the response body and the corresponding schema so Power Automate can identify the message array or the message count property.
If your parsed JSON contains a list of messages, add an 'Apply to each' control and select the message array from the dynamic content. If the API provides a message count, initialize a variable and use a 'Do until' control that runs while the variable is less than the total count.
Inside the loop, insert your desired actions to process the data. Critically, add an HTTP or API action to acknowledge or delete the processed message from the MuleSoft queue so the flow does not repeatedly consume the identical item.

Boost Your Productivity with WPS Office
While Power Automate handles your complex API workflows, you still need a reliable, fast, and free office suite to document your integrations, analyze API data in spreadsheets, and prepare presentations.
- 1. Download WPS Office: Visit the official WPS website and download the free installer for your operating system.
- 2. Install the Software: Run the setup file and follow the quick installation prompts to get the suite ready on your device.
- 3. Start Creating: Open WPS Office to instantly create, view, or edit Microsoft Office formats without compatibility issues.

Frequently Asked Questions
Why does my Power Automate flow only process one message?
Your flow might be missing a looping action. If the HTTP request returns a batch or array of messages, you must use an 'Apply to each' action to iterate over the entire array instead of just reading the first index item.
What is the difference between Apply to each and Do until in Power Automate?
'Apply to each' runs a set of actions for every item present in a specified array (like a list of API messages). 'Do until' repeats actions endlessly until a specific condition evaluates to true, such as a variable for the processed message count reaching the total limit.
How do I prevent processing the same queue message multiple times?
Inside your loop, you must include an action to acknowledge, update, or delete the message from the source queue immediately after it is processed. This ensures the next iteration or flow run does not fetch the exact same item.




