Overview
Power Automate provides many built-in connectors, but sometimes businesses need custom APIs to extend its functionality. By creating a Custom API, you can:
Connect Power Automate to internal applications
Expose business logic via REST endpoints
Enable authentication and security control
Enhance automation workflows with external data
This guide covers how to create a Custom API for Power Automate using Azure API Management and Azure Functions, and then expose it as a custom connector in Power Automate.
1️⃣ Prerequisites
Before creating a custom API, ensure you have:
✔️ Azure Subscription (for API hosting)
✔️ Power Automate License (for custom connectors)
✔️ Postman (for API testing)
✔️ Basic knowledge of REST APIs and JSON
Example: You want to create a Custom API that retrieves employee details from an internal HR system and use it in Power Automate.
2️⃣ Step-by-Step: Creating a Custom API for Power Automate
Step 1: Create an API Using Azure Functions
Azure Functions provide a serverless way to build lightweight APIs.
1️⃣ Go to Azure Portal → Search for Azure Functions
2️⃣ Click Create and configure:
- Resource Group:
CustomAPI-RG
- Function Name:
EmployeeAPI
- Runtime Stack:
.NET, Node.js, or Python
- Hosting Plan:
Consumption (serverless)
3️⃣ Click Review + Create
Step 2: Develop the API Endpoint
Modify the function to return employee details in JSON format.
Example Function (C#/.NET):
using System.Net;
public static async Task<HttpResponseMessage> Run(HttpRequest req, ILogger log)
{
string employeeId = req.Query["id"];
var employeeData = new {
Id = employeeId,
Name = "John Doe",
Position = "Software Engineer",
Department = "IT"
};
return new HttpResponseMessage(HttpStatusCode.OK) {
Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(employeeData),
System.Text.Encoding.UTF8, "application/json")
};
}
4️⃣ Deploy the function and copy the Function URL
Example API Call:GET https://employeeapi.azurewebsites.net/api/GetEmployee?id=12345
Step 3: Secure the API with Azure API Management
To control access, Azure API Management (APIM) is used.
1️⃣ Go to Azure Portal → Search for API Management Services
2️⃣ Click Create and configure:
- Resource Group:
CustomAPI-RG
- Name:
HR-API
- Pricing Tier:
Consumption
3️⃣ Click Review + Create
4️⃣ Import the Function into APIM:
- Navigate to APIM → APIs
- Click + Add API → Choose Function App
- Select EmployeeAPI
5️⃣ Enable Subscription Keys (for authentication)
- Under API settings, enable Subscription Required
Example API Gateway Endpoint:https://hr-api.azure-api.net/GetEmployee?id=12345
Step 4: Test the API with Postman
1️⃣ Open Postman
2️⃣ Make a GET request to the API:
GET https://hr-api.azure-api.net/GetEmployee?id=12345
3️⃣ Add Headers:
Ocp-Apim-Subscription-Key: YOUR-API-KEY
4️⃣ Verify the JSON response
📌 Expected Output:
{
"Id": "12345",
"Name": "John Doe",
"Position": "Software Engineer",
"Department": "IT"
}
Step 5: Create a Custom Connector in Power Automate
To integrate Power Automate with the API, create a custom connector.
1️⃣ Go to Power Automate → Data → Custom Connectors
2️⃣ Click + New custom connector → Import from OpenAPI
3️⃣ Provide:
- Connector Name:
HR Employee API
- API Base URL:
https://hr-api.azure-api.net/
- Authentication:
API Key
(use APIM key)
4️⃣ Define Actions in Power Automate:
- Click + New Action
- Name it Get Employee Details
- Set method to GET
- URL path:
/GetEmployee?id={id}
- Define response schema using JSON sample
5️⃣ Save & Test the Connector
Example Power Automate Flow:
- Trigger: “When a new request is created in SharePoint”
- Action: “Get Employee Details” (using the custom API)
- Action: “Send email with employee data”
3️⃣ Best Practices for Custom APIs in Power Automate
✔️ Use API Management (APIM) for security – Protect APIs from unauthorized access.
✔️ Enable CORS (Cross-Origin Resource Sharing) – Allow Power Automate to call the API.
✔️ Implement OAuth 2.0 authentication – Secure sensitive API endpoints.
✔️ Optimize API response times – Avoid large payloads and use pagination.
✔️ Log API requests and errors – Use Application Insights for monitoring.
✔️ Version control APIs – Maintain backward compatibility when updating APIs.
Example: If your API serves financial data, ensure role-based access control (RBAC) is implemented in APIM.