Per my research, you don't need site id, only need the file URL to check whether a document is inside a document library through Graph.
Here is an example:
POST https://graph.microsoft.com/v1.0/search/query
{
"requests": [
{
"entityTypes": [
"driveItem"
],
"query": {
"queryString": "path:\"https://tenant.sharepoint.com/sites/emilytest/doc1/Book1.xlsx\""
}
}
]
}
If the document is inside a document library, it will return "total": 1.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.