When I was working on a Power Apps and Power Automate solution to create SharePoint sites automatically, I needed it to work across any tenant.
The flow creates SharePoint sites via REST API calls, so we must pass the tenant name.
However, Power Automate does not provide any direct action or function to get the tenant name.
If we hardcode the tenant name, the flow will fail when the solution is imported into another tenant. That means the solution is not reusable.
To solve this problem, I used an environment variable inside a solution. When someone imports the solution, they only need to provide a SharePoint site address. From this site address, we can dynamically extract the tenant name in Power Automate and use it in REST API calls.
In this tutorial, I will show you how to get the tenant name in Power Automate using two different ways:
- Get Tenant name from an Environment variable
- Get Tenant name from a SharePoint Action input
Get Tenant Name in Power Automate
In this section, I will first show how to get the tenant name from an environment variable inside a solution. After that, I will explain how to get the tenant name from a SharePoint action input in Power Automate.
Get the Tenant Name From an Environment Variable Inside a Solution
For this example, I created a Power Apps Solution with an Environment variable named Site Address.

Now we create the flow inside the solution, then get the tenant name.
To do this, follow the steps below:
- In the Power Apps Solution, click + New -> Automation -> Cloud flow -> Instant.

- Enter a name for the flow, select the Manually trigger a flow trigger, and then click Create.

- Then add a compose action and provide the Environment Variable from the dynamic content.

Now save the flow and run it manually; you can then see the Site Address in the compose action output.

- Now, to extract the tenant name, add another Compose action and enter the expression below:
first(split(replace(outputs('Compose'),'https://',''),'.sharepoint.com'))

Save the flow and run it. You will see the tenant name in the Compose action output.

This way, you can get the tenant name from an environment variable inside a solution. You can also use this value in Power Apps if required.
Get the Tenant Name from a SharePoint Action Input in Power Automate
In this example, I created an instant cloud flow and used a Get items action for a SharePoint list.

Now, I want to get the tenant name, and I will show you how to do it.
To do this, follow the steps below:
Add a compose action and provide the following expression:
actions('Get_items').inputs.parameters.dataset
Where:
- actions(‘Get_items’): Refers to the Get items action in your flow (The name must exactly match the action’s internal name (from Peek code)).
- .inputs: Returns everything you passed into the Get items action.
- .parameters: Inside the inputs, Power Automate stores connector-specific values under parameters.
- .dataset: It returns the SharePoint Site URL used by Get items.

Now save the flow and run it manually, then you can see the Site Address in the compose action output.

Now, to extract the tenant name, add another Compose action and enter the expression below:
first(split(replace(outputs('Compose_1'),'https://',''),'.sharepoint.com'))

Save the flow and run it. You will see the tenant name in the Compose action output.

Conclusion
In this tutorial, I explained two different ways to get the tenant name in Power Automate. First, we learned how to retrieve the tenant name from an environment variable within a solution, which makes the solution reusable across different tenants. Next, we saw how to get the tenant name from a SharePoint action input by reading the site address used in the action.
You may also like:
- Create Custom Responses in Power Automate Approvals
- Forward an Outlook Meeting Invite Using Power Automate
- Remove User From SharePoint Group Using Power Automate
- Send Approvals in Microsoft Teams Using Power Automate
- Send Approval to SharePoint Group Members Using Power Automate
- Create an Approval Workflow in Power Automate Using Microsoft Forms

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.