Power Automate API
Power Automate API
Source :
https://learn.microsoft.com/en-us/power-automate/web-api
Organization ID: A unique name for the environment that stores your flows.
To learn how to get an Azure AD Bearer token for Dataverse, go to Use OAuth authentication with
Microsoft Dataverse.
HTTP:
GET https://org00000000.crm0.dynamics.com/api/data/v9.1/workflows
Accept: application/json
The response contains the list of flows from within that environment (HTTP):
{
"@odata.context": "https://org00000000.crm0.dynamics.com/api/data/v9.1/$metadata#workflows",
"value": [{
"@odata.etag": "W/\"12116760\"",
"category": 5,
"statecode": 0,
"workflowidunique": "00000000-0000-0000-0000-000000000001",
"workflowid" : "00000000-0000-0000-0000-000000000002",
"createdon": "2018-11-15T19:45:51Z",
"_ownerid_value": "00000000-0000-0000-0000-000000000003",
"modifiedon": "2018-11-15T19:45:51Z",
"ismanaged": false,
"_modifiedby_value": "00000000-0000-0000-0000-000000000003",
"_createdby_value": "00000000-0000-0000-0000-000000000003",
"type": 1,
"clientdata": "{\"properties\":{\"connectionReferences\":{\"shared_commondataservice\":
{\"source\":\"NotSpecified\",\"id\":\"/providers/Microsoft.PowerApps/apis/
shared_commondataservice\",\"tier\":\"NotSpecified\"}},\"definition\":{...}},\"schemaVersion\":\"1.0.0.0\"}"
}]
List flows:
As shown previously, you can get the list of workflows by calling GET on workflows. Each workflow has
many properties, but the most relevant are listed in the following table.
You can also request specific properties, filter the list of flows, and more, as described in Query data
using the Web API. For example, this query returns only the automated, instant, or scheduled flows that
are currently on:
HTTP:
Accept: application/json
HTTP:
POST https://org00000000.crm0.dynamics.com/api/data/v9.1/workflows
Accept: application/json
Content-type: application/json
"category": 5,
"statecode": 0,
"type": 1,
"primaryentity":"none",
"clientdata": "{\"properties\":{\"connectionReferences\":{\"shared_commondataservice\":
{\"connectionName\":\"shared-commondataser-00000000-0000-0000-0000-
000000000004\",\"source\":\"Invoker\",\"id\":\"/providers/Microsoft.Power
Apps/apis/shared_commondataservice\"}},\"definition\":{\"$schema\":
\"https:\/\/fanyv88.com:443\/https\/schema.management.azure.com\/providers\/Microsoft.Logic\/schemas\/2016-06-01\/
workflowdefinition.json#\",\"contentVersion\": \"1.0.0.0\",\"parameters\": {\"$connections\":
{\"defaultValue\": {},\"type\": \"Object\"},\"$authentication\": {\"defaultValue\":
{},\"type\": \"SecureObject\"}},\"triggers\": {\"Recurrence\": {\"recurrence\":
{\"frequency\": \"Minute\",\"interval\": 1},\"type\": \"Recurrence\"}},\"actions\": {\"List_records\":
{\"runAfter\": {},\"metadata\": {\"flowSystemMetadata\":
{\"swaggerOperationId\": \"GetItems_V2\"}},\"type\": \"ApiConnection\",\"inputs\": {\"host\": {\"api\":
{\"runtimeUrl\": \"https:\/\/fanyv88.com:443\/https\/firstrelease-001.azure-apim.net\/apim\/commondataservice\"},\"connection\":
{\"name\": \"@parameters('$connections')['shared_commondataservice']
['connectionId']\"}},\"method\": \"get\",\"path\":
\"\/v2\/datasets\/@{encodeURIComponent(encodeURIComponent('default.cds'))}\/tables\/
@{encodeURIComponent(encodeURIComponent('accounts'))}\/items\",\"queries\": {\"$top\":
1},\"authentication\": \"@parameters('$authentication')\"}}},\"outputs\":
{}}},\"schemaVersion\":\"1.0.0.0\"}"
The most important section is the clientdata, which contains the connectionReferences that the flow
uses, and the definition of the flow. The connectionReferences are the mappings to each connection
that the flow uses.
Once you execute the POST request, you'll receive the OData-EntityId header, which will contain
the workflowid for your new flow.
HTTP:
PATCH https://org00000000.crm0.dynamics.com/api/data/v9.1/workflows(00000000-0000-0000-0000-
000000000002)
Accept: application/json
Authorization: Bearer ey...
Content-type: application/json
"[email protected]": "systemusers(00000000-0000-0000-0000-000000000005)"
Note:
The syntax for changing the owner uses the odata.bind format. This means instead of patching the
_ownerid_value field directly, you append @odata.bind to the property name and then wrap the ID
with systemusers().
In another example, you can turn on a cloud flow with this call:
HTTP:
PATCH https://org00000000.crm0.dynamics.com/api/data/v9.1/workflows(00000000-0000-0000-0000-
000000000002)
Accept: application/json
Content-type: application/json
"statecode" : 1
HTTP:
DELETE https://org00000000.crm0.dynamics.com/api/data/v9.1/workflows(00000000-0000-0000-0000-
000000000002)
Accept: application/json
Authorization: Bearer ey...
Note
You can't delete a cloud flow that's turned on. You must first turn off the flow or else you'll see this
error: Cannot delete an active workflow definition. To learn more, go to Update a cloud
flow in this article.
HTTP:
GET
https://org00000000.crm0.dynamics.com/api/data/v9.1/RetrieveSharedPrincipalsAndAccess(Target=@ti
d)?@tid={'@odata.id':'workflows(00000000-0000-0000-0000-000000000002)'}
Accept: application/json
HTTP :
"@odata.context":
"https://org00000000.crm0.dynamics.com/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.RetrieveS
haredPrincipalsAndAccessResponse",
"PrincipalAccesses": [
"AccessMask": "ReadAccess",
"Principal": {
"@odata.type": "#Microsoft.Dynamics.CRM.systemuser",
"ownerid": "00000000-0000-0000-0000-000000000005"
}
}
HTTP:
POST https://org00000000.crm0.dynamics.com/api/data/v9.1/GrantAccess
Accept: application/json
Content-type: application/json
"Target" : {
"@odata.type": "Microsoft.Dynamics.CRM.workflow",
"workflowid" : "00000000-0000-0000-0000-000000000002"
},
"PrincipalAccess": {
"Principal": {
"@odata.type" : "Microsoft.Dynamics.CRM.systemuser",
"ownerid" : "00000000-0000-0000-0000-000000000005"
},
"AccessMask": "ReadAccess"
The AccessMask parameter is a field with the following values for different permission levels:
Name Description
None No access.
ReadAccess The right to read the flow.
WriteAccess The right to update the flow.
DeleteAccess The right to delete the flow.
ShareAccess The right to share the flow.
AssignAccess The right to change the owner of the flow.
You can combine permissions with a comma. For example, you can provide the ability to read and
update a cloud flow by passing ReadAccess,WriteAccess.
HTTP:
POST https://org00000000.crm0.dynamics.com/api/data/v9.1/RevokeAccess
Accept: application/json
Content-type: application/json
"Target" : {
"@odata.type": "Microsoft.Dynamics.CRM.workflow",
"workflowid" : "00000000-0000-0000-0000-000000000002"
},
"Revokee": {
"@odata.type" : "Microsoft.Dynamics.CRM.systemuser",
"ownerid" : "00000000-0000-0000-0000-000000000005"
Export flows:
Use the ExportSolution action to export flows to a .zip file. First, add the flows that you want to
a solution.
HTTP:
POST https://org00000000.crm0.dynamics.com/api/data/v9.1/ExportSolution
Accept: application/json
Content-type: application/json
"Managed": false
HTTP:
"@odata.context":
"https://org00000000.crm0.dynamics.com/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.ExportSol
utionResponse",
"ExportSolutionFile": "UEsDBBQAAgAI..."
You can then save this file into source control and/or use whatever version management or distribution
system you want.
Import flows:
Call the ImportSolution action to import a solution.
HTTP:
POST https://org00000000.crm0.dynamics.com/api/data/v9.1/ImportSolution
Accept: application/json
Content-type: application/json
"OverwriteUnmanagedCustomizations": false,
"PublishWorkflows" : true,
"ImportJobId" : "00000000-0000-0000-0000-000000000006",
"CustomizationFile" : "UEsDBBQAAgAI..."
Since import is a long-running operation, the response to the ImportSolution action will be a 204 No
content. To track the progress, call a GET on the importjobs object, providing the ImportJobId that
you included in the original ImportSolution action.
HTTP:
GET https://org00000000.crm0.dynamics.com/api/data/v9.1/importjobs(00000000-0000-0000-0000-
000000000006)
Accept: application/json
This call returns the status of the import operation, including progress (the percentage of
completion), startedon, and completedon (if import finished).
Once import has completed successfully, you'll need to set up the connections for the flow. The reason
is that the connectionNames likely will be different in the destination environment (if the connections
exist at all). If you're setting up new connections in the destination environment, then the owner of the
flows must create them in the Power Automate designer. If the connections are already set up in the
new environment, then you can PATCH the clientData of the flow with the names of the connections.
Power Automate Management
Source:
https://learn.microsoft.com/en-us/connectors/flowmanagement/
#first-party
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Run ID runId True string The ID of the flow run to resubmit.
Create Connection
Operation ID:
CreateConnection
Returns
The outputs of this operation are dynamic.
Create Flow
Operation ID:
CreateFlow
Create flow
Parameters
Name Key Required Type Description
Environment environmentName True string Select
environment
Flow Name name string
Flow Display displayName True string
Name
Flow State state True string
Connection Name connectionName string
Connection displayName string
Display Name
Connector Id id True string
Either Embedded source string
or Invoker
connection
Logical name of connectionReferenceLogicalName string
the connection
reference
Connector Name name string
Connector displayName string
Display Name
Connection createdTime date-time
Created Time
Connector primaryRuntimeUrl string
Runtime Url
Connector Icon iconUri string
Url
Connector is isCustomApi boolean
Custom Api
Connector Tier tier string
Flow Created createdTime date-time
Time
Flow Modified lastModifiedTime date-time
Time
Flow Template templateName string
Name
Flow Trigger flowTriggerUri string
Uri
Flow installationStatus string
Installation
Status
Creator tenant tenantId True string
ID
Creator object objectId string
ID
Creator user ID userId True string
Creator user userType True string
type
Flow trigger type string
type
Flow trigger kind string
kind
Action type type string
Swagger swaggerOperationId string
operation Id
Action Api name name string
Action Api id id string
Action Api type type string
Returns
Body Flow
Delete Flow
Operation ID:
DeleteFlow
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Get Connector
Operation ID:
GetApi
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Connector apiName True string Select connector
Returns
The outputs of this operation are dynamic.
Get Flow
Operation ID:
GetFlow
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Returns
Body FlowWithConnectionReferences
Get the given flow from an environment you have admin access to.
Parameters
Returns
Body AdminFlowWithConnectionReferences
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Returns
Body FlowListCallbackUrlResponse
List Connectors
Operation ID:
ListApis
Lists all of the connectors available in the given environment. This list will include custom connectors as well as
the built-in connectors.
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Returns
Body ResourceArray[ApiWithoutConnectionParameters]
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Returns
Body ResourceArray[FlowPermission]
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Returns
Body ResourceArray[FlowPermission]
List all flows in the given environment you have admin access to.
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Returns
Body ResourceArray[AdminFlow]
List all flows in the given environment you have admin access to. This V2 action is a higher performance action
that returns only the identifying information about the flow. The flow definition and much of the metadata is not
returned. For additional metadata and the flow definition, make a subsequent call to the Get Flows as Admin
action.
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Returns
Body ResourceArray[AdminFlowWithoutDefinition]
List My Connections
Operation ID:
ListConnections
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Returns
Body ResourceArray[ConnectionWithoutConnectionParameters]
List My Environments
Operation ID:
ListUserEnvironments
Returns
Body ResourceArray[Environment]
List My Flows
Operation ID:
ListMyFlows
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Returns
Body ResourceArray[AdminFlow]
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Add User Object Id id True string
Add User Type type True string
Remove User Object Id id True string
Modify owners of the given flow created in an environment you have admin access to.
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Restore the given soft-deleted flow in an environment you have admin access to.
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Returns
Body AdminFlowWithConnectionReferences
Resubmit Flow
Operation ID:
ResubmitFlow
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Trigger Name triggerName True string Name of the flow trigger to resubmit.
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Turn On Flow
Operation ID:
StartFlow
Parameters
Name Key Required Type Description
Environment environmentName True string Select environment
Flow flowName True string Select flow
Update Flow
Operation ID:
UpdateFlow
Parameters
Name Key Require Type Description
d
Environment environmentName True string Select
environment
Flow flowName True string Select flow
Flow Name name string
Flow Display Name displayName True string
Flow State state True string
Connection Name connectionName string
Connection Display Name displayName string
Connector Id id True string
Either Embedded or source string
Invoker connection
Returns
Body Flow
Definitions :
ResourceArray[ApiWithoutConnectionParameters]
ResourceArray[ConnectionWithoutConnectionParameters]
ResourceArray[Environment]
ResourceArray[AdminFlow]
ResourceArray[AdminFlowWithoutDefinition]
FlowPermission
PermissionProperties
Principal
Flow
FlowProperties
FlowListCallbackUrlResponse
FlowWithConnectionReferences
Name Path Type Description
Flow Name name string
properties properties FlowWithConnectionReferencesProperties
FlowWithConnectionReferencesProperties
AdminFlow
AdminFlowWithoutDefinition
AdminFlowProperties
AdminFlowWithoutDefinitionProperties
AdminFlowWithConnectionReferences
AdminFlowWithConnectionReferencesProperties
EstimatedSuspensionData
DefinitionSummary
UserIdentity
Environment
Name Path Type Description
Environment Name name string
Environment Location location string
properties properties EnvironmentProperties
EnvironmentProperties
ConnectionReferencesArray
ConnectionReferencesDictionary
ConnectionReference
ApiWithoutConnectionParameters
ApiPropertiesWithoutConnectionParameters
ConnectionWithoutConnectionParameters
ConnectionPropertiesWithoutConnectionParameters
Source:
https://learn.microsoft.com/en-us/connectors/microsoftflowfora
dmins/?source=recommendations
Disable-AdminFlow
Disables a Flow.
Parameters
Name Key Required Type Description
Environment Name environment True string Name field of the Environment.
Flow Name flow True string Name field of the Flow.
Field API Version api-version string The date value of the API version.
Edit-AdminFlowOwnerRole
Parameters
Name Key Required Type Description
Environment Name environment True string Name field of the Environment.
Enable-AdminFlow
Enables a Flow.
Parameters
Name Key Required Type Description
Name field of the Environment environment True string Environment Name.
Get-AdminFlowOwnerRole
Parameters
Name Key Required Type Description
Environment Name environment True string Name field of the Environment.
Flow Name flow True string Name field of the flow.
Field API Version api-version string The date value of the API version.
Returns
Name Path Type Description
value value array of object Flow permission value object array.
Get-AdminFlowUserDetails
Parameters
Name Key Required Type Description
Field userId userId True string Flow user principal object ID.
Returns
Name Path Type Description
Tenant ID tenantId string Flow user tenantId.
PUID puid string Flow user puid.
Object ID objectId string Flow user principal object ID.
Is Disallowed for isDisallowedForInternalPlans boolean Flow user isDisallowedForInternalPlans.
Internal Plans
Remove-AdminFlowApproval
Parameters
Name Key Required Type Description
Field userId userId True string Flow user principal object ID.
Field API Version api-version string The date value of the API version.
Remove-AdminFlow
Deletes a Flow.
Parameters
Name Key Required Type Description
Remove-AdminFlowUserDetails
Field UserId userId True string Flow user principal object ID.
Power Automate has a connector called 'HTTP' that is used to invoke the REST API to the workflow and get the
responses as needed, but this action is only for a premium connection. There is another action called 'Send an
HTTP request to SharePoint' that constructs a SharePoint REST API to invoke. ¹
RESTful APIs can return data that you need for your app in a convenient format (for example JSON or XML). By
using the HTTP action in Power Automate, we can invoke/call an API by using methods GET (read), POST (write),
PUT (update), PATCH (update, but only partially) or DELETE (remove). ⁴
Here are some examples of how to use REST API in Power Automate:
I hope this helps. Let me know if you have any other questions.
Source: Conversation with Bing, 21/03/2023(1) How to use Rest API in Power Automate [With 23 Examples].
https://www.spguides.com/rest-api-in-power-automate/ Accessed 21/03/2023.
(2) How to get started with HTTP requests in Power Automate. https://www.m365princess.com/blogs/2021-02-
10-how-to-get-started-with-http-requests-in-power-automate/ Accessed 21/03/2023.
(3) Manage flows with the Power Automate Web API - Power Automate ....
https://learn.microsoft.com/en-us/power-automate/web-api Accessed 21/03/2023.
(4) How to use an API with Power Automate - Forward Forever. https://forwardforever.com/how-to-use-an-api-
with-power-automate/ Accessed 21/03/2023.
(5) How to use Rest API in Power Automate [With 23 Examples]. https://www.spguides.com/rest-api-in-power-
automate/ Accessed 21/03/2023.
(6) Manage flows with the Power Automate Web API - Power Automate.
https://learn.microsoft.com/en-us/power-automate/web-api Accessed 21/03/2023.
(7) How to use an API with Power Automate - Forward Forever. https://forwardforever.com/how-to-use-an-api-
with-power-automate/ Accessed 21/03/2023.