Assign sensitivity label through office addin

Andreas Davros 71 Reputation points
2025-11-25T11:02:40.25+00:00

Hello,

We are trying to set the sensitivity label of an office file through an office add-in.

Our main problem is that, we cannot find a graph api supported in US Gov (https://learn.microsoft.com/en-us/graph/api/driveitem-assignsensitivitylabel?view=graph-rest-1.0&tabs=http) and even for global cloud, while the document is opened we get an error till the file is closed from all users.

Our main questions are:

  • Is there a way to apply a sensitivity label to a file through an office add-in in gov?
  • Is there some way (maybe a leveraged permission?) to go around the error that the file is currently open and apply the. label..? Thanks!

Moved from "Microsoft 365 and Office | Development | Other"

Microsoft Security | Microsoft Purview
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-11-25T11:02:55.3633333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Currently, there is no specific Graph API documented for assigning sensitivity labels to files through an Office add-in in the US Government cloud. The API you referenced is applicable to the global cloud, and it appears that similar functionality may not be available or fully supported in the US Gov environment.

    Regarding the error you encounter when trying to apply a sensitivity label while the file is open, this is a common limitation in many file handling scenarios. Typically, files must be closed by all users before certain operations can be performed. As of now, there is no documented workaround or permission that would allow you to bypass this restriction.

    For your specific needs, it may be beneficial to monitor the Microsoft Graph documentation for any updates or new API releases that could support your requirements in the future. Additionally, consider reaching out to Microsoft support for more tailored assistance regarding your use case in the US Gov cloud.


    References:

    0 comments No comments

  2. Swapnesh Panchal 1,380 Reputation points Microsoft External Staff Moderator
    2025-12-04T00:35:50.5366667+00:00

    Hi @Andreas Davros,
    Welcome to the Microsoft Q&A and thank you for posting your questions here.
    driveItem-assignSensitivityLabel is not supported in US Gov clouds (GCC, GCC High, DoD). There is no configuration to enable it. For US Gov tenants, use Microsoft Information Protection (MIP) SDK in your Office add-in or rely on Purview auto-labeling policies for files at rest.
    In global cloud, the Graph API call fails if the file is open because SharePoint/OneDrive locks the file. There is no elevated permission to override this lock. Implement retry logic after the file is closed.
    References:

    Please let us know in the comments if you have any further questions or would like to continue the discussion. We’ll be happy to assist.


Your answer

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