Recently, I had to implement deep linking in a Canvas app. The plan felt straightforward: use Param() to read query strings and jump to the right screen or record
However, to build links that work across Dev, Test, and Prod environments, I needed the App ID, Environment ID, and Tenant ID at runtime.
I searched the web for a dead-simple approach… nope. lots of workarounds, nothing truly easy. and I was also curious about something: when the same Power Automate flow is connected to multiple apps, how does the flow know which app is calling it?
While checking the Power Automate trigger headers, I found something interesting (a few useful properties).
Whenever a Power Apps call a flow, it includes the caller details in the request headers (App ID, Environment ID, and Tenant ID). Based on these headers, the Power Automate flow tailors the response to the exact app that invoked it.
The trick is:
1. Create an Instant cloud flow with the trigger When Power Apps calls a flow (V2).

2. Add three Compose actions named Compose - App ID, Compose - Environment ID, and Compose - Tenant ID.
3.In each Compose, paste these expressions:
App ID
last(split(trigger()?['Outputs/headers/x-ms-client-app-id'], '/'))
Environment ID
last(split(trigger()?['Outputs/headers/x-ms-client-environment-id'], '/'))
Tenant ID
trigger()?['Outputs/headers/x-ms-client-tenant-id']
4. Add Respond to a Power App or flow that returns { App_ID, Environment_ID, Tenant_ID } mapped from the three Compose outputs.

5. Consume it in Power Apps.
// Call the flow and capture IDs
Set(App_Details, GetAppdetails.Run()); // Sample flow name
// Build a deep link
Set(
_deepLink,
$"https://apps.powerapps.com/play/e/{App_Details.environment_id}/a/{App_Details.app_id}?tenantId={App_Details.tenant_id}"
);
// Optional: add screen/record params
Set(
DeepLinkWithParams,
_deepLink & "&screen=Details&recordId=" & Text(SomeRecord.Id)
);
Display
_deepLink in a Label or wire it to a Copy button.
Optionally, append custom query parameters like screen=Details or recordId=123 to jump to the right screen or record.
Advantages using this method:
- No maintenance for IDs found at run time.
- Reusable across apps. One flow can serve many apps.
- Easy to deploy. Move from Dev to Test to Prod without touching variables or constants.
Happy deep linking.