While working with SharePoint along with Power Apps or Power Automate, we may often require the SharePoint site ID. In my case, I removed some of the environment variables in the Power Apps solution, and then I got an error that contained an ID with the SharePoint connection. At that point, I was required to check my SharePoint site ID to solve that issue.
In this tutorial, I will explain the 3 best ways to get SharePoint Online Site ID like:
- Get SharePoint Online Site ID Using Microsoft Graph
- Get SharePoint Online Site ID using REST Endpoint
- Get SharePoint Online Site ID Using PnP PowerShell
Get SharePoint Online Site ID Using Microsoft Graph
In this section, we’ll see how to get the SharePoint Online site ID using Microsoft Graph. In the image below, you can see the highlighted guid, which is nothing but an ID of the SharePoint site I gave.

Follow the steps below to achieve this!
1. Open the Microsoft Graph with your credentials. Under SharePoint Sites -> Choose the get SharePoint site based on relative path option in the left navigation, like in the image below.
Note: On the right side you will get a sample URL “https://graph.microsoft.com/v1.0/sites/{host-name}:/{server-relative-path}”

2. In place of {host-name} provide your SharePoint domain address and in place of {server-relative-path} provide your site address like in the below.
Then click on the Run query button. You’ll see details about the SharePoint site below. The site ID is the second value of the “id” parameter.
https://graph.microsoft.com/v1.0/sites/tenantname.sharepoint.com:/sites/RetailManagementSite

This way you can get SharePoint site ID from the Microsoft Graph.
Get SharePoint Online Site ID using the REST Endpoint
To get the SharePoint site ID using the REST endpoint, log in to your SharePoint site, provide the URL like the one below, and hit the URL. Then, you’ll get the SharePoint site ID like in the image below.
https://{tenantname}.sharepoint.com/sites/{Sitename}/_api/site/id

This way, you can also get the SharePoint site ID from REST endpoints.
Get SharePoint Online Site ID Using PnP PowerShell
Here, we’ll see another approach to get the SharePoint online Site ID using PnP PowerShell commands.
In the image below, you can see that in the TERMINAL pane, I got the SharePoint site ID.

Run the code below in VS Code or any other platform like Windows PowerShell ISE. Make sure you registered an application in Microsoft Entra ID for SharePoint, take that application ID to interact with the SharePoint site with PnP PowerShell.
Note: If you don’t know, follow this article to register an application in Microsoft Entra ID.
$SiteURL = "https://{tenant name}.sharepoint.com/sites/{site name}"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -ClientId "Your client ID" -Interactive
#Get the site with ID property
$Site = Get-PnPSite -Includes ID
#Get Site ID
Write-host -f Green "Site Collection ID:"$Site.Id
Here, the Get-PnPSite will retrieve the provided site collection from the context. The includes parameter fetches the SharePoint site ID.
I hope you understand how to get the SharePoint Online site ID. In this article, I have explained three different approaches to getting the ID. You can follow any of the approaches.
Also, you may like:
- SharePoint Customization Examples – Customize a SharePoint Online Site
- SharePoint Site Left Navigation or Quick Launch
- Share SharePoint Site with External Users
- SharePoint Site Regional Settings
- SharePoint Site Owner

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.