Designing Custom Actions
Earn 25 points (50 with Pro) in two steps
- ① Read through the lesson — each section gets a ✓ as you scroll through it.
- ② When every section has a ✓, tap Complete lesson.
0 of 12 read · keep scrolling
✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro
Designing Custom Actions in Power Automate
Introduction: Why Custom Actions Matter
In the world of workflow automation, we often find ourselves hitting a wall where the out-of-the-box connectors provided by platforms like Microsoft Power Automate simply cannot bridge the gap between our unique business requirements and our existing software ecosystem. While Power Automate provides a vast library of pre-built connectors for services like SharePoint, Outlook, and Salesforce, real-world business processes often involve legacy systems, proprietary databases, or specialized API structures that standard connectors don't support. This is where designing custom actions becomes a critical skill for any automation developer.
A custom action is essentially a user-defined function that extends the capabilities of Power Automate, allowing it to interact with systems or perform logic that isn't native to the platform. By building custom actions—often wrapped within Custom Connectors—you transform Power Automate from a simple "if-this-then-that" tool into an enterprise-grade integration engine. Understanding how to design these actions is not just about writing code; it is about architecting a clean, maintainable, and secure bridge between your automation platform and the rest of your technical infrastructure.
This lesson will guide you through the architectural principles, the technical implementation steps, and the best practices for designing custom actions. Whether you are dealing with a REST API that requires complex authentication or a internal microservice that needs to perform data transformation, the techniques covered here will provide you with the foundation to build sophisticated, reusable automation components.
Not read yet
The Anatomy of a Custom Action
To design effective custom actions, you must first understand that they are usually delivered via a "Custom Connector." A custom connector acts as a wrapper around a REST API. When you design a custom action, you are essentially defining a contract between Power Automate and your target service.
Key Components of a Custom Action
- The Request Definition: This defines the HTTP method (GET, POST, PUT, DELETE), the URL path, and the query parameters. It tells Power Automate exactly where to send the data and how to request it.
- Headers: Many APIs require specific headers for content types, authorization tokens, or versioning. Defining these correctly is the most common point of failure for beginners.
- Request Body (Schema): This is the JSON structure that the API expects. A well-designed action uses a strict schema, which enables Power Automate’s Dynamic Content feature, making the action easy to use for other team members.
- Response Handling: Just as important as sending data is interpreting what comes back. You must define the expected JSON response so that the subsequent steps in your flow can access the returned data.
Callout: Custom Actions vs. Expressions It is important to distinguish between a custom action and an expression. Expressions (like
add,concat, orformatDateTime) are internal logic tools within Power Automate. Custom actions represent external communication. If you need to perform math, use an expression. If you need to talk to a SQL database or a custom web service, you need a custom action.
Not read yet
Step-by-Step: Designing Your First Custom Action
Designing a custom action begins long before you open the Power Automate portal. It requires a clear understanding of the API you are targeting. Let’s walk through the process of creating an action that interacts with a hypothetical "Employee Directory API."
Phase 1: Planning the API Interaction
Before building, you need to have the API documentation available. You need to know:
- The Base URL: The root address of the service.
- Authentication Method: Is it API Key, OAuth 2.0, or Basic Auth?
- Endpoint Path: The specific URL for the action (e.g.,
/employees/get-details). - Payload Requirements: What fields are mandatory in the request?
Phase 2: Defining the Action in Power Automate
- Navigate to Data > Custom Connectors in the Power Automate sidebar.
- Select New custom connector and choose Create from blank.
- In the General tab, define the host (e.g.,
api.company.com). - In the Security tab, select the authentication type. If you are using API Keys, define the parameter name and location (Header or Query).
- In the Definition tab, click New Action. This is where the magic happens.
Phase 3: Configuring the Definition
When you create a new action, you provide an "Operation ID." This ID is how the action is identified internally. Keep it simple and descriptive (e.g., GetEmployeeByID).
In the Request section, click Import from sample. If your API expects a POST request, paste a sample JSON body here. Power Automate will automatically generate the schema for you. This is a massive time-saver and ensures your data types (strings, integers, booleans) are correctly mapped.
Tip: Always use descriptive summaries and descriptions for your actions. When a colleague uses your connector later, the "Summary" field appears as the action name, and the "Description" serves as the tooltip. Good documentation prevents support requests.
Not read yet
Advanced Logic: Handling Data Transformations
Often, the data coming from an API is not in the format your flow needs. You might get a nested JSON object when you only need a single field, or you might need to combine three separate API calls into one workflow action.
Implementing Data Mapping
You can use Policy Templates within the custom connector definition to transform data on the fly. For instance, if your API returns a date in a non-standard format, you can apply a logic policy to convert that date before it ever touches your flow.
However, for more complex logic, it is often better to use an Azure Function as a middleman. You can design your Custom Action to call the Azure Function, which then performs the "heavy lifting" of data transformation, normalization, or complex business calculation, and returns a clean, simplified JSON object to Power Automate.
Code Example: A Simple Transformation Logic
If you are using an Azure Function to act as a proxy for your custom action, your code might look like this (Node.js example):
// This function acts as a wrapper for a legacy SOAP service
module.exports = async function (context, req) {
const rawData = req.body;
// Transform the incoming payload to match the expected format
const transformedData = {
employeeName: rawData.FirstName + " " + rawData.LastName,
status: rawData.Active ? "Active" : "Terminated",
joinedDate: new Date(rawData.HireDate).toISOString()
};
context.res = {
status: 200,
body: transformedData
};
};
This approach keeps your Power Automate flows clean. Instead of having dozens of "Compose" or "Parse JSON" actions in your flow, the custom action does the work, and the flow simply receives the final, usable data.
Not read yet
Best Practices for Professional Custom Actions
Designing custom actions is an exercise in software engineering. If you treat it as such, your automations will be resilient and easy to maintain.
1. Versioning
Always include a version number in your API endpoints (e.g., /v1/employees). If you need to change the behavior of an action, create a new version rather than modifying the existing one. This prevents your existing flows from breaking when you update the connector.
2. Error Handling
An action that fails silently is a nightmare to debug. Ensure your custom action defines appropriate response codes. If your API returns a 404 or a 500, your custom connector should pass that back to the flow so you can use the "Configure Run After" setting to trigger error-handling logic (like sending an email to an admin).
3. Security
Never hardcode API keys or credentials in your connector definition. Always use the secure input fields provided by the Power Automate security tab. If your API requires OAuth, use the built-in OAuth providers for services like Azure Active Directory.
Warning: Never log sensitive data in your custom connector. If you are using debug logs in an external service, ensure that PII (Personally Identifiable Information) is masked before it leaves your network.
4. Reusability
Design your actions to be atomic. An action should do one thing and do it well. Instead of an action called ProcessEmployeeData, create three separate actions: GetEmployee, UpdateEmployeeStatus, and CalculateBonus. This makes your flows much more modular.
Not read yet
Common Pitfalls and How to Avoid Them
Even experienced developers fall into common traps when designing custom actions. Awareness is the first step toward avoidance.
The "Over-Engineering" Trap
The most common mistake is trying to do too much inside the custom connector. If you find yourself writing hundreds of lines of code to transform data inside a connector or an Azure Function, stop. Ask yourself if this logic belongs in the API itself. If you own the API, modify the API to return the data in the format you need. Don't use Power Automate to fix poor API design.
Ignoring Rate Limits
If your custom action calls an external service, you are subject to that service's rate limits. If your flow runs every minute and makes 10 calls to an API, you might accidentally trigger a rate-limiting block. Always check the API documentation for "Throttling" or "Rate Limits" and design your flows to handle 429 (Too Many Requests) error codes.
Lack of Documentation
Power Automate custom connectors do not have a built-in "ReadMe" file. If you are working in a team, create a separate document or a Wiki page that explains what each action does, what the expected inputs are, and what the outputs represent. Your future self will thank you.
Table: Comparison of Integration Methods
| Method | Complexity | Flexibility | Maintenance |
|---|---|---|---|
| HTTP Action | Low | High | High (per flow) |
| Custom Connector | Medium | High | Low (centralized) |
| Azure Function | High | Unlimited | Medium |
- HTTP Action: Good for one-off calls, but a maintenance burden if you use it in 20 different flows.
- Custom Connector: The "Goldilocks" solution. Reusable, manageable, and easy to share.
- Azure Function: Use this when the logic is too complex for standard JSON manipulation or requires heavy libraries.
Not read yet
Deep Dive: Authentication Patterns
The security of your custom action is paramount. Power Automate supports several authentication types, and choosing the right one depends on the security requirements of your target service.
API Key Authentication
This is the most straightforward method. You provide a key in the header or the query string.
- Best for: Internal services or low-risk APIs.
- Risk: If the key is intercepted, the attacker has full access. Rotate these keys periodically.
OAuth 2.0 (Authorization Code Grant)
This is the industry standard. It involves a redirection flow where the user logs into the target service, and Power Automate receives an access token.
- Best for: SaaS applications (Salesforce, Zendesk, etc.).
- Benefit: The user’s credentials are never stored in Power Automate. The token is time-bound and can be revoked.
Service Principal / Client Credentials
This is used for machine-to-machine communication.
- Best for: Background services where no user interaction is required.
- Benefit: Highly secure, as it relies on certificates or client secrets stored in secure vaults.
Callout: The Importance of Scopes When configuring OAuth, always request the minimum scope necessary. If your action only needs to read data, don't request "Write" or "Admin" permissions. This is the principle of least privilege, and it is a fundamental pillar of secure system design.
Not read yet
Handling Complex Payloads with JSON Schema
One of the most powerful features of Custom Connectors is the ability to define a JSON schema. When you define a schema, Power Automate understands the structure of your data. This allows you to use the "Dynamic Content" picker in your flows.
If you do not define a schema, Power Automate treats the response as a generic string. You would then have to use the json() expression to parse it, which is prone to errors and makes your flow difficult to read.
Defining a Schema
When you are in the Definition tab of your custom connector, look at the Response section. Click Add default response. You can paste a sample JSON response here.
{
"id": 12345,
"name": "Jane Doe",
"department": "Engineering",
"metadata": {
"lastLogin": "2023-10-27T10:00:00Z",
"isActive": true
}
}
Once this is saved, when you use this action in a flow, Power Automate will show id, name, department, and metadata as selectable fields. Without this, you would have to manually type body('Get_Employee')?['name'], which is much more fragile.
Not read yet
Building for Resilience: "Run After" Logic
In a production environment, things will go wrong. APIs will time out, services will go down, and data will be malformed. Designing your custom actions is only half the battle; you must also design how your flows react when those actions fail.
By default, a flow stops when an action fails. However, you can change this behavior by clicking the three dots on the next step in your flow and selecting Configure Run After.
Common "Run After" Scenarios
- Success: The standard path.
- Has failed: Use this to trigger error-handling steps (e.g., log the error to a SharePoint list or send an alert via Teams).
- Has timed out: Useful for long-running processes that might exceed the API's response window.
- Is skipped: Use this if you have conditional logic that might bypass certain steps.
By creating a robust "catch-all" block at the end of your flow that handles failures, you ensure that your automation doesn't just "die" without anyone knowing.
Not read yet
Industry Standards and Governance
When you start creating custom actions for your organization, you are essentially creating a new piece of infrastructure. This requires a level of governance.
Naming Conventions
Establish a naming convention for your connectors. Use a prefix (e.g., CORP_) to distinguish internal connectors from standard ones. Use consistent naming for actions (e.g., Get[EntityName], Post[EntityName]).
Testing Environments
Never build or test custom connectors in your production environment. Create a separate Power Platform environment where you can test your actions against a staging or development API. Once verified, you can export the connector as a solution and import it into your production environment.
Documentation Requirements
For every custom connector, maintain a document that includes:
- Purpose: Why does this connector exist?
- Dependencies: What systems does it connect to?
- Contact: Who is the owner/developer?
- Changelog: What has changed in the latest version?
Not read yet
Troubleshooting Common Errors
Even with the best design, you will encounter errors. Here is a quick guide to common issues:
401 Unauthorized
- Check: Your credentials or API keys.
- Common fix: Ensure the header name matches exactly what the API expects (e.g.,
AuthorizationvsX-API-KEY).
400 Bad Request
- Check: Your JSON schema.
- Common fix: Ensure that mandatory fields are included and that data types match. If the API expects an integer, do not send a string.
500 Internal Server Error
- Check: The API logs.
- Common fix: This usually means the problem is on the server side of the API, not in your connector. Contact the API provider.
Timeout Errors
- Check: The volume of data.
- Common fix: If you are requesting too much data, look for ways to implement pagination or filtering in your API request.
Advanced Strategy: Handling Pagination
Many APIs return data in chunks, especially when dealing with lists of items. If your custom action is meant to fetch a list of items, you need to account for pagination.
If you don't handle pagination, your flow might only receive the first 50 or 100 items, and you will miss the rest. Most modern APIs use "Link" headers or "NextPageToken" fields in the response.
Implementing Pagination in Custom Connectors
Power Automate has a built-in "Pagination" setting in the custom connector definition.
- Go to the Definition tab.
- Scroll to the Pagination section.
- Choose the pagination type (e.g.,
ODataorLink header). - Define the parameter that the API uses to track the page (e.g.,
skiporpage).
By configuring this, Power Automate will automatically loop through the pages for you, aggregating all the results into a single array that your flow can then iterate through using an "Apply to Each" loop.
Not read yet
Key Takeaways
- Custom Actions as Infrastructure: Treat custom actions as a bridge between platforms. They require the same care, documentation, and versioning as any other software code.
- Schema Definition is Key: Always define your JSON request and response schemas. This enables Power Automate's dynamic content features, making your flows significantly easier to build and maintain.
- Atomic Design: Create small, focused, and reusable actions. Avoid the temptation to build "God actions" that do everything; instead, build a library of simple, specific tools.
- Prioritize Security: Never hardcode credentials. Use secure input fields and always follow the principle of least privilege when selecting OAuth scopes.
- Build for Failure: Use "Run After" logic to handle API errors gracefully. An automation that reports its own failure is far more valuable than one that silently crashes.
- Governance Matters: Use separate environments for development and production. Establish naming conventions and maintain documentation for all custom connectors to ensure longevity.
- Leverage Native Features: Utilize built-in pagination support and policy templates to handle common API challenges before resorting to custom code or Azure Functions.
By mastering the design of custom actions, you shift from being a user of Power Automate to an architect of automation solutions. You gain the ability to unlock data from any system, creating flows that are not limited by the standard catalog of connectors, but are instead defined by the needs of your business. Start small, follow these best practices, and build your custom connectors with a focus on reliability and clarity.
Not read yet
Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.
- Leveraging the Power Automate Ecosystem
- Leveraging the Power Automate Ecosystem Quiz5q
- Cloud Flows vs Desktop Flows
- Cloud Flows vs Desktop Flows Quiz5q
- Designing Desktop and Cloud Flow Automations
- Designing Desktop and Cloud Flow Automations Quiz5q
- Trigger Types for Cloud Flows
- Trigger Types for Cloud Flows Quiz5q
- Target Application and Browser Interactions
- Target Application and Browser Interactions Quiz5q
- Methods for Running Desktop Flows
- Methods for Running Desktop Flows Quiz5q
- Concurrent Flow Execution
- Concurrent Flow Execution Quiz5q
- Attended vs Unattended Desktop Flows
- Attended vs Unattended Desktop Flows Quiz5q
- HTTP Actions in Cloud and Desktop Flows
- HTTP Actions in Cloud and Desktop Flows Quiz5q
- Work Queues for Automation
- Work Queues for Automation Quiz5q
- Designing Custom Actions
- Designing Custom Actions Quiz5q
- Cloud Flow Calling Desktop Flow
- Cloud Flow Calling Desktop Flow Quiz5q
- Child Cloud Flows and Data Passing
- Child Cloud Flows and Data Passing Quiz5q
- External API Calls in Cloud Flows
- External API Calls in Cloud Flows Quiz5q
- Trigger Conditions and Concurrency
- Trigger Conditions and Concurrency Quiz5q
- Timeout and Retry Policies
- Timeout and Retry Policies Quiz5q
- Data Objects and Operations in Cloud Flows
- Data Objects and Operations in Cloud Flows Quiz5q
- Text Parsing JSON XML CSV
- Text Parsing JSON XML CSV Quiz5q
- UI Options in Desktop Flows
- UI Options in Desktop Flows Quiz5q
- Datatables Lists and Custom Objects
- Datatables Lists and Custom Objects Quiz5q
- Subflows in Desktop Flows
- Subflows in Desktop Flows Quiz5q
- External APIs in Desktop Flows
- External APIs in Desktop Flows Quiz5q
- Timeout and Retry in Desktop Flows
- Timeout and Retry in Desktop Flows Quiz5q
- Custom Actions in Desktop Flows
- Custom Actions in Desktop Flows Quiz5q
- Flow Control and Loops
- Flow Control and Loops Quiz5q
- Expressions in Cloud Flows
- Expressions in Cloud Flows Quiz5q
- Variable Actions for Flows
- Variable Actions for Flows Quiz5q
- Secure Input and Output Data
- Secure Input and Output Data Quiz5q
- Desktop Flow Priority and Queues
- Desktop Flow Priority and Queues Quiz5q
- Exception Handling Blocks
- Exception Handling Blocks Quiz5q
- Business Exception Error Handling
- Business Exception Error Handling Quiz5q
- Work Queues in Flows
- Work Queues in Flows Quiz5q
- Building a Custom Connector
- Building a Custom Connector Quiz5q
- Custom Connector Authentication
- Custom Connector Authentication Quiz5q
- Custom Connector Policy Templates
- Custom Connector Policy Templates Quiz5q
- Code in Custom Connectors
- Code in Custom Connectors Quiz5q
- Credential Management Practices
- Credential Management Practices Quiz5q
- On-Premises Data Gateway
- On-Premises Data Gateway Quiz5q
- Dataverse Solutions Components
- Dataverse Solutions Components Quiz5q
- Machine and Machine Group Requirements
- Machine and Machine Group Requirements Quiz5q
- Machine Registration Management
- Machine Registration Management Quiz5q
- Machine Group Management
- Machine Group Management Quiz5q
- Load Balancing Desktop Flows
- Load Balancing Desktop Flows Quiz5q
- Run Queue Operations
- Run Queue Operations Quiz5q
- Analyzing Flow Run History
- Analyzing Flow Run History Quiz5q
- Power Automate Analytics Dashboard
- Power Automate Analytics Dashboard Quiz5q
- Desktop Flow Monitoring
- Desktop Flow Monitoring Quiz5q
- Automation Performance Optimization
- Automation Performance Optimization Quiz5q
- Troubleshooting Flow Failures
- Troubleshooting Flow Failures Quiz5q
- Center of Excellence RPA Analytics
- Center of Excellence RPA Analytics Quiz5q
No PL-500 practice exam yet
Your points already work on 76 Amazon, CompTIA and Microsoft exams.
See the exams