How to Fetch Sensitivity Labels for Files in OneDrive/SharePoint and Outlook Emails

Kanwal Singh 45 Reputation points
2025-05-01T17:40:40.69+00:00

I am having difficulty fetching the sensitivity labels for files stored in Office applications like Word and Outlook emails.

For Word: I attempted to use the endpoint https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{item-id}/extractSensitivityLabels, but it returns a 404 error, despite the sensitivity label being applied to the document, which is visible when the document is opened.

For Emails: I used the endpoint https://graph.microsoft.com/v1.0/me/messages/{message-id}, but it does not provide any information regarding the sensitivity label. The email I was fetching was sent from another domain where Purview was enabled, and the email was marked with a sensitivity label before it was sent. I have verified that the information exists in the email's internet headers.

I consider that if there were any rights issues, there should have been an insufficient privileges error. I have provided the InformationProtectionPolicy.Read permission to my Azure app, so I believe the rights are set correctly.

Can anyone provide guidance on how to retrieve the sensitivity labels and suggest the best methods to do so?

Best Regards,

Kanwal Singh

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
24,690 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rukmini 2,361 Reputation points Microsoft External Staff Moderator
    2025-05-05T06:10:38.2933333+00:00

    Hi @Kanwal Singh,

    The 404 error usually occurs if you are using GET method instead of POST while fetching sensitivity labels for SharePoint file.

    Initially I got the same error, when called the extractSensitivityLabels API using GET:

    User's image

    To resolve the error, make use of POST and also make sure that you are passing the correct ItemID:

    Fetch Item ID:

    
    GET https://graph.microsoft.com/v1.0/drives/DriveID/root:/Document.docx
    
    

    User's image

    • Also make sure to grant admin consent to Files.Read.All API permission.

    I am able to fetch the sensitivity labels for SharePoint file successfully:

    
    POST https://graph.microsoft.com/v1.0/sites/SiteID/drive/items/ItemID/extractSensitivityLabels
    
    

    User's image

    Note that for emails, currently fetching sensitivity labels for mails is not supported for the endpoint https://graph.microsoft.com/v1.0/me/messages using Microsoft Graph API.

    Reference:

    driveItem: extractSensitivityLabels - Microsoft Graph v1.0 | Microsoft

    Hope this helps!


    If this answers your query, do click Accept Answer and Yes for was this answer helpful, which may help members with similar questions.

    User's image

    If you have any other questions or are still experiencing issues, feel free to ask in the "comments" section, and I'd be happy to help.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.