Showing results for 
Search instead for 
Did you mean: 
New Member

Hot to restrict access for HTTP Request Trigger

Dear Experts,
I have simple flow based on "When a HTTP request is received" trigger.


Using the link from the trigger, anyone can sent HTTP request and get response from my Flow. And this is really the problem.

How I can restrict possibility to get response from my flow for anyone except certain users?

(Note: I don't want to use some kind of Passwords which I can provide because I can't control that someone of my approved users will not share this password with someone else, and I will not be able determine who exactly use this password - the user approved by me or not.)

Sincerely ID3 

Super User
Super User

Hi @ID3,


I don't know if this will work for you situation, but you might be able to check the user-agent value of the POST request and add a trigger condition to your When a HTTP request is received trigger action.


Below is an example of a trigger condition which only allows requests from other Power Automate flows and for instance not Windows PowerShell.


@startswith(triggeroutputs()['headers']['user-agent'], 'azure-logic-apps/1.0')


Dear Expiscornovus,

In my case all permitted to access to my Flow users are members of Office 365 groups.
Maybe it is useful information for the solution finding.

One more fact - it is quite enough to restrict the access only for HTTP request been sent from Power Query (Excel). And perhaps in this case the Power Query "Access Web content" options can be used.


Super User
Super User

I actually wrote an article on how to secure the HTTP trigger, check it out and see if it of use to you:

Secure the HTTP Request Trigger in Microsoft Power Automate 

Hi @ID3,


It is still a workaround based on the user agent string, but you can probably use this trigger condition to restrict only to Power Query (web.contents source)

@startswith(triggeroutputs()['headers']['user-agent'], 'Microsoft.Data.Mashup')


@Paulie78, nice, very useful article 🙂

However, I think ID3 wanted to avoid using a key or a password like stated in the opening post.

Super User
Super User

@Expiscornovus - That will teach me not to read the question properly! Thank you for putting me straight!

New Member

Dear @Paulie78 
The article about HTTP Request Secure is realy nice. It means I am not alone who met the same problem and it is worth to work it out more.

Dear @Expiscornovus 
Your suggested Microsoft.Data.Mashup check is a good, and I think should be used in any case. 
In case of PowerQuery using with Windows or Organizational account credentials, does it mean that the data about user account (login/user name) can be taken from the trigger/Request? 

Is there any MS Services can provide information about all MS Flow transactions with more details than I can see in Power Automate Runs History?

Sincerely ID3

Super User
Super User

Hi @ID3,


As far as I could tell it wasn't showing any data about the account which was used.


Below is an example of the raw input of the received HTTP request when I was testing it with Power Query in Excel.


    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip,deflate",
        "Expect": "100-continue",
        "Host": "",
        "User-Agent": "Microsoft.Data.Mashup,(",
        "Content-Length": "2",
        "Content-Type": "application/json"
    "body": {}


Dear @Expiscornovus
Here is what I have and waht I used.

And here is the data.

    "variables": [
            "name": "Trigger",
            "type": "String",
            "value": "{\"name\":\"manual\",\"inputs\":{\"method\":\"POST\"},\"outputs\":{\"headers\":{\"Connection\":\"Keep-Alive\",\"Accept\":\"application/json\",\"Accept-Encoding\":\"gzip,deflate\",\"Expect\":\"100-continue\",\"Host\":\"\",\"User-Agent\":\"Microsoft.Data.Mashup,(\",\"Content-Length\":\"39\",\"Content-Type\":\"application/json\"},\"body\":{\"Type\":\"MyData\",\"Param\":\"MyData\"}},\"startTime\":\"2021-04-24T09:25:56.997722Z\",\"endTime\":\"2021-04-24T09:25:56.997722Z\",\"trackingId\":\"4xxxxxxb-5xxx-4xxe-xxxxxxxx1\",\"clientTrackingId\":\"0XXXXXXXXXXXXXXXXXXXXXXXXXX4\",\"originHistoryName\":\"0XXXXXXXXXXXXXXXXXXXXXXX\",\"status\":\"Succeeded\"}{\"Type\":\"MyData\",\"Param\":\"MyData\"}"

For sending I used this one request

    Request = Json.Document(Web.Contents(urlApi, [ Headers=[#"Accept"="application/json", #"content-type" = "application/json"], Content=Text.ToBinary("{""Type"": ""SiteInfo"", ""Param"": """& Site_Param &"""}")])),
    #"Converted to Table" = Record.ToTable(Request),
    #"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Name", "Parameter"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Value", type text}, {"Parameter", type text}})

#"Changed Type"

With this permissions:


It is pretty interesting why you have not "originHistoryName" and "clientTrackingId" but I have. Did you use POST or GET?
But however, I don't know are these values can help with my problem or not. ...

The problem is still not solved and important.

Sincerely ID3.

Hi Expiscornovus,

 I've got a question for you, is there any way to send back an error such as 400 Bad Request or 401 Forbidden if the request doesn't satisfay the conditional trigger?

A the moment if I call the https endpoint I receive a standar "202 Accepted" code...


Thank you,


Super User
Super User

Hi @ZaffaSte,


You can remove that trigger condition and use a condition action instead. Use that startswith expression in there and use a response action to send back a HTTP 400.


Below is an example of that.



Regular Visitor

Hi @Expiscornovus ,

 thank you for your reply: easy peasy lemon squeezy and it's true, but in this way the flow start, there's no way to default 202 reply other than start a flow?


Thank you so much,


Super User
Super User

Hi @ZaffaSte,


I know there is a schema validation setting which you can enable in the settings which can return a HTTP 400 instead of a 200 if there is a mismatch.


But as far as I am aware that is only for the body, not the headers like user-agent.



Thank you @Expiscornovus I knew the "Schema Validation" option, but as you wrote in your reply is all about the body of the request not the header.

Frequent Visitor

You are really asking about something very important here @ID3 . I have been thinking a lot about this lately too. And my first thought was to use logic apps, Azure functions and API management. But the posts and replies here are very good and maybe there is another way. Here are my toughs.


The problem is if someone gets the Uri for the flow, they can trigger the flow.

The Uri is built like this:

Url parameters:
&sig=<43 letter random generated secret>
If someone copies the trigger Uri and shares it, all of the above needed parameters are shared.
This can be a problem if the person misuses it or shares it with other unknown people.
PS! The only way to change the secret code, is to create a new flow. You cannot change the secret code on an existing flow.
If attackers does NOT have the URI, they need to guess the workflow GUID and the secret code for the sig parameter. This is extremely unlikely and not really a problem.
Risk: Sharing the Uri

An "attacker" needs the Uri for the flow itself to exploit the weakness. 

For this to happen, it requires a person with edit access to the flow and that this person shares the Uri.


  • Securing the edit access to a flow that contains HTTP actions, should be first priority. Use Environments and Solutions, and do not share the owner role of the flow with everyone.
  • You should store the Uri in Azure Key vault. This will stop storing of sensitive values in clear text in the flow definition code.

If these mitigation does not make the risk acceptable, the mitigations below must be evaluated.


Trigger Conditions

I really like the article from @Paulie78, since using trigger conditions. It can check the headers and the body for keys and values and act upon them. This is most useful for NOT running the flow at all.


Risk: HTTP response giving information back

The high risk is if you do not use the question mark "?" in the condition, it will reply with the value it needs. This actually gives the "attacker" everything it needs.

You need to store the conditions in clear text!

These risk are so bad I would not recommend using them, unless the mitigations in the first risk is acceptable and done. A person with edit access to the flow can expose the information.

The only good reason to use this method is if the condition can check for a non-fakeable value in the header.

Or maybe to just add an extra value that must be shared by a rouge person, making the sharing less intuitive.



  • Same mitigations as the risk of sharing the Uri.
  • + Manual and automatic checks for the ? mark in the condition.
  • Use ONLY conditions on header values that cannot be "faked" from the client using the Uri. (Do they exist?) A user agent header can easily be faked.
  • Turn on "Suppress workflow headers" to avoid sending information back to the client.


Conditions in Actions

@Expiscornovus suggest a solution using conditions as actions.

This can mitigate the problem with the flow sending secrets to the client as a response.

It will not mitigate the problem stopping an user with edit access to send the needed information.

It will mitigate the risk that secrets are in clear text in the flow definition, since it can pull those secrets from Azure Key Vault.

It will also add a second layer of security check, using a secret that can be changed frequently.

It will not stop an attacker from starting a flow run, consuming runs and causing throttling.


I am sure there is more possibilities and that I am missing something to consider. 


Please comment and correct me! 🙂

Frequent Visitor

Would there be an option to implement IP restrictions?  I'm not an expert in HTTP, so I don't know.  Is source IP address available in the headers, or some other way that could be used in a trigger condition?

Although, if wanting to restrict to being called from other Power Automates, what is the IP range for MS365/Power Automate as a source?  (I'm thinking, use IP filtering on top of the agent that was mentioned in a previous post.)

Helpful resources

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,635)