Skip to main content
Post

#PowerPlatformTip 172: 'One Custom Connector, Any Endpoint - Central Auth with a Dynamic HTTP Request'

#PowerPlatformTip 172: 'One Custom Connector, Any Endpoint - Central Auth with a Dynamic HTTP Request'

TL;DR: Build one Custom Connector that stores the API key on the connection and exposes a generic action that takes a relativePath, query and body (one action per HTTP method). Authenticate once, share the connection, and reach every endpoint of a token-based REST API without ever re-entering the key. Custom connectors are premium. Bonus: hand the whole definition to Copilot Studio as a tool.

Instead of building a separate action for every endpoint, create one Custom Connector that holds the authentication centrally and exposes one generic action per HTTP method where the caller passes the relative path, query and body at runtime. You build the connector once, create one connection with the credentials, and from then on every flow, app or agent just reuses it dynamically - the secret stays on the connection and out of your flow logic. The real payoff comes later: once the definition lives in a connector, you can hand it to Copilot Studio as a tool. The catch: Data Loss Prevention (DLP) applies to the whole connector, not per endpoint, so treat it as a governed building block.

Licensing: Custom connectors are a Premium feature. Every user who runs a flow or app that uses this connector needs a plan with premium connector rights (for example Power Apps or Power Automate Premium).

💡 Challenge

The example API in this tip is MOCO, a web-based time-tracking, project and invoicing service with a REST API under https://{yourcompany}.mocoapp.com/api/v1 and a token in the Authorization header. The pattern works the same for any REST API that authenticates with a key or token in a header.

You want to talk to many endpoints of the same REST API (e.g. MOCO: projects.json, activities, users) from Power Automate or Power Apps. Building and maintaining one action per endpoint is tedious, and repeating the API key in every raw HTTP action - pasting it into a header or pulling it from a vault on every call - is a security and maintenance nightmare.

✅ Solution

Create a Custom Connector that separates the two things a connector really owns: the connection (host + security scheme) and the definition (one reusable action). Configure the API key once on the connection, then send only the relative path and body per call. The key is stored, encrypted, on the connection, so it never appears in your flows again.

🔧 How It’s Done

1. General tab - set the host.

🔸 Host: yourcompany.mocoapp.com, Base URL: /api/v1.

2. Security tab - authenticate once.

🔸 Authentication type: API Key.

🔸 Parameter label: Authorization, location: Header.

🔸 MOCO expects the value Token token=YOUR_API_KEY, so the connection user pastes exactly that when creating the connection. The header is then attached to every call automatically.

3. Definition tab - one generic action.

🔸 Add an action, e.g. GenericGet, and use Import from sample with the verb GET and the URL https://yourcompany.mocoapp.com/api/v1/{relativePath}. The curly braces turn the path into a path parameter named relativePath, so the caller decides projects.json, activities, users, … at runtime.

🔸 An operation has exactly one HTTP verb. Add one generic action per verb you need, for example GenericPost and GenericPut with the same {relativePath} plus a body parameter.

🔸 Add optional query parameters (e.g. from, to, page) where the API uses them.

🔸 Slashes in the path: path parameters are URL-encoded, so a / inside relativePath reaches the API as %2F. Single-segment resources such as projects.json or activities work as they are. For nested resources such as projects/123/tasks, add a second action with the path /{resource}/{id}/{subresource}, or rewrite the request URL in the connector’s Code tab (custom code).

🔸 Write clear descriptions on every parameter - they become the connector’s self-documentation and are exactly what Copilot Studio reads later.

4. Use it in a flow.

🔸 Add the GenericPost action, set relativePath to e.g. activities and pass a JSON body. The Authorization header is already there from the connection - you never touch the key again.

🎉 Result

One connector, one shared connection, every endpoint reachable. New API areas with the same path shape need no connector change, you just pass a different relativePath. Auth lives in one place and is distributable through a Solution.

🌟 Key Advantages

🔸 Set the key once, forget it: the API key lives on the connection. You never re-enter it, never hand-build an auth header, and never fetch it from a vault in each flow.

🔸 Auth decoupled from logic: whoever builds flows or apps just picks the connection, no secret ever touches the flow definition.

🔸 Future-proof: new endpoints of the same shape work instantly, no redeploy, just a different relativePath.

🔸 Shareable & ALM-ready: package the connector in a Solution and share the connection across the team.

🔸 A ready-made Copilot Studio tool: the connector definition can be attached to an agent as a tool, so the AI browses the endpoints and builds the call itself.

🛠️ FAQ

1. Generic action vs. importing the OpenAPI spec, which is better?

Generic gives maximum flexibility with minimal setup; OpenAPI import gives typed schemas and IntelliSense-like parameters per endpoint. If your API publishes an OpenAPI spec, import it. For AI-driven agents (see #173) the typed actions are the better fit.

2. Do I have to expose the API key in every flow?

No. That’s the whole point - the key is stored once on the connection; flows only send path, query and body.

3. When is a plain HTTP action enough instead?

For a quick one-off internal call. Note that the HTTP action is a Premium feature as well. As soon as multiple people or apps must reuse the same authentication, the Custom Connector wins on sharing, security and ALM.

4. Can Copilot Studio really use this without extra work?

Yes, add the connector as a tool (Tools > Add a tool > Connector); it needs view and share permissions for your organization. Because your parameter descriptions document each endpoint, the agent can pick the path and build the body itself. Details in #PowerPlatformTip 173.

5. What’s the governance catch with a generic “call anything” connector?

DLP classification applies to the entire connector, not per endpoint, and is evaluated before any runtime host policy. A generic connector can effectively reach any REST API, so build and share it only with trusted parties and align it with your CoE before a productive rollout.

6. Can I combine several authentication types, or make the OAuth URL dynamic?

Not in the wizard. API Key, Basic and OAuth 2.0 are exclusive; multiple auth needs connectionParameterSets in apiProperties.json via the Power Platform Connectors CLI (paconn). And custom connection parameters aren’t injected into the OAuth /authorize request, so the authorize URL can’t be made dynamic - fine for MOCO’s token header, relevant if your API uses OAuth 2.0.

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy, which runs free live workshops (in German). See the next free workshop dates (in German). For companies that want this implemented for them, see KMUpower: Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.