How to Find Documents with a Retention Label Using Microsoft Graph
Question details
The user wants to retrieve all documents assigned to a specific retention label using the Microsoft Graph API.

- Product
- Microsoft Graph API
- Device & OS
- not provided
- Scenario
- Attempting to query files by retention label via a standard OneDrive drive search endpoint.
- Observed behavior
- The standard search query does not reliably return documents because retention labels are compliance metadata and are not indexed for standard file search endpoints.
Ensure you have the appropriate administrative permissions and Microsoft Purview access, as querying compliance metadata often requires higher-level tenant privileges than standard file read permissions.
Utilize Microsoft Purview Content Search or eDiscovery
Since standard OneDrive search endpoints do not index retention labels, Microsoft Purview provides robust compliance search capabilities designed specifically to find labeled documents.
Retention labels are considered compliance metadata within the Microsoft ecosystem. Relying on standard drive search endpoints is not recommended for comprehensive compliance audits.
Log in to the Microsoft Purview compliance portal using an administrator account with eDiscovery or Content Search privileges.
Select 'Content search' or 'eDiscovery' from the left-hand navigation menu.
Create a new search query and add a condition to filter by 'Retention label', selecting the specific label ID you want to locate.
Run the query to generate a report. Once complete, you can review or export the list of documents assigned to that retention label.

Enumerate Files and Inspect Metadata via Microsoft Graph API
If no dedicated API is available for filtering by label directly, you can iterate through files and check their specific metadata programmatically.
Consult Microsoft Graph Security and Compliance Endpoints
Check for updated Microsoft Graph endpoints specifically designed for compliance records management.
Manage Your Documents Efficiently with WPS Office
While enterprise compliance and retention labels require complex Microsoft integrations, your daily document creation and editing tasks do not. WPS Office provides a lightweight, highly compatible, and free alternative to Microsoft Office for editing Word, Excel, and PowerPoint files without the enterprise overhead.
- 1. Download the software: Visit the official WPS Office website and download the free installation package.
- 2. Install WPS Office: Run the downloaded installer and follow the simple on-screen instructions to set up the software.
- 3. Edit your documents: Open WPS Office to seamlessly view, edit, and save your DOCX, XLSX, and PPTX documents.

Frequently Asked Questions
Why doesn't standard OneDrive search find documents by retention label?
Retention labels are stored as compliance metadata rather than standard file attributes. Because of this, the regular OneDrive file search endpoint does not reliably index or query this information, requiring the use of specialized compliance endpoints like Microsoft Purview.
Can I use Microsoft Graph to apply a retention label to a file?
Yes, Microsoft Graph allows applying retention labels to SharePoint and OneDrive items using the setLabel action on the driveItem endpoint, provided the application or user has the necessary compliance permissions.
Where can I get specialized help for the Microsoft Graph API?
You can post your specific development and API questions in the Microsoft Q&A community using the 'ms-graph' tag, where Microsoft engineers and community experts provide detailed assistance.




