There are some new SharePoint Premium Content AI Microsoft Graph API endpoints. Allowing you through code to programmatically orchestrate document processing models. This allows scenarios such as provisioning a site and then applying a model to a library or processing a file/folder using a model to now be completed using Microsoft Graph.


These commands have previously been available using Microsoft Syntex unstructured document processing model REST API which relies on making SPO REST calls. It’s great to see these commands now coming to Microsoft Graph!
I will now test all the new Content Model Graph API endpoints and provide the commands required to execute the MS Graph commands using PowerShell
Permissions Required/Connecting
To authenticate to Graph an App registration is required, below is how I did it. I am unsure the permissions required for executing the SP Premium Graph commands but I found Sites.FullControl.All worked for my testing.
1 2 3 | $yourTenant = "contoso.onmicrosoft.com" $yourUsername = "user@contoso.onmicrosoft.com" Register-PnPAzureADApp -ApplicationName SPPremiumMSGraph -Tenant $yourTenant -Store CurrentUser -Username $yourUsername -Interactive -GraphApplicationPermissions Sites.FullControl.All |
I then connected using Connect-PnPOnline using the details I obtained from creating the SPPremiumMSGraph app registration.
1 2 3 | $url = "https://contoso.sharepoint.com/sites/LeonContentCenter" $yourTenantUrl = 'contoso.onmicrosoft.com' Connect-PnPOnline -Url $url -ClientId "<App Reg Cert ID Here>" -Thumbprint '<App Reg Cert Thumbprint Here' -Tenant $yourTenantUrl |
Once connected I could then test the commands.
Get Content Model
Official Docs: Get contentModel – Microsoft Graph beta
This Graph command (GET) allows you to GET the details of Document Processing model by providing the ID.
1 2 3 4 | $SiteID = '<"Content Center Site ID"> # i.e. Site ID of the Content Centre where the model is located $modelID = '<Model ID>' # i.e Model ID of Aviation Incident Report DPM $value = Invoke-PnPGraphMethod -Url "https://graph.microsoft.com/beta/sites/$SiteID/contentModels/$modelID" -Method Get $value | ConvertTo-Json |
Result: This shows a JSON payload showing further details of the model and when it was last modfied, created modelType, createdBy etc.

Get Applied Drives
Official Docs: contentModel: getAppliedDrives – Microsoft Graph beta
This Graph command (GET) allows you to find out all the document libraries that a document processing model is applied to.
1 2 3 4 | $SiteID = '<"Content Center Site ID"> # i.e. Site ID of the Content Centre where the model is located $modelID = '<Model ID>' # i.e Model ID of Aviation Incident Report DPM $value = Invoke-PnPGraphMethod -Url "https://graph.microsoft.com/beta/sites/$SiteID/contentModels/$modelID/getAppliedDrives" -Method Get $value.value | ConvertTo-Json -Depth 3 |
Result: This returns a JSON array with all the different Drives (Document Libraries) where the model is applied to.

Get By Name
Official Docs: contentModel: getByName – Microsoft Graph beta
This Graph command (GET) allows you to retrieve a model in a Content Centre by specifying the name of the model ensuring the name includes “.classifier”.
1 2 3 4 | $SiteID = '<"Content Center Site ID"> # i.e. Site ID of the Content Centre where the model is located $modelName = 'Aviation Incident Report.classifier' # Remember to include the .classifier $value = Invoke-PnPGraphMethod -Url "https://graph.microsoft.com/beta/sites/$SiteID/contentModels/getByName(modelName='$modelName')" -Method Get $value | ConvertTo-Json |
Result: This shows a JSON payload showing further details of the model and when it was last modfied, created modelType, createdBy etc.

Add To Drive
Official Docs: contentModel: addToDrive – Microsoft Graph beta
This Graph command (POST) allows you add a SharePoint Premium document processing model to a drive (document library. Use the Graph command GET /sites/{site Id}/drives (To fetch drive IDs for a particular site).
1 2 3 4 5 6 7 8 | $SiteID = '<"Content Center Site ID"> # i.e. Site ID of the Content Centre where the model is located $modelID = '<Model ID>' # i.e Model ID of Aviation Incident Report DPM $driveid = "b!QGCb0Snvo0ClMVxcDV4FXDmdC6dMLepBgtROKCFZIz1oF9Imf_bFSoWC7Bk4Sn5K" # Library to apply the model towards. Use GET /sites/{siteId}/drives (To fetch drives for a particular site) $json = "{ ""driveId"": ""$driveid"" }" $value = Invoke-PnPGraphMethod -Url "https://graph.microsoft.com/beta/sites/$SiteID/contentModels/$modelID/addToDrive" -Method Post -Content $json -ContentType "application/json" $value |
Result: This shows details of the library & model applied along with created/modified details.

Remove From Drive
Official Docs: contentModel: removeFromDrive – Microsoft Graph beta
This graph commands allows you to remove a SharePoint Premium document processing model from being applied to a library.
1 2 3 4 5 6 7 8 | $SiteID = '<"Content Center Site ID"> # i.e. Site ID of the Content Centre where the model is located $modelID = '<Model ID>' # i.e Model ID of Aviation Incident Report DPM $driveid = "b!QGCb0Snvo0ClMVxcDV4FXDmdC6dMLepBgtROKCFZIz1oF9Imf_bFSoWC7Bk4Sn5K" # Library to apply the model towards. Use GET /sites/{siteId}/drives (To fetch drives for a particular site) $json = "{ ""driveId"": ""b!QGCb0Snvo0ClMVxcDV4FXDmdC6dMLepBgtROKCFZIz1oF9Imf_bFSoWC7Bk4Sn5K"" }" $value = Invoke-PnPGraphMethod -Url "https://graph.microsoft.com/beta/sites/$SiteID/contentModels/$modelID/removeFromDrive" -Method Post -Content $json -ContentType "application/json" $value # Returns Null |
Result: No payload is returned on success
Create Document Processing Job
Official Docs: Create documentProcessingJob – Microsoft Graph beta
This command is used to initiate a file or a folder for re-processing with any models applied to the library.
File
1 2 3 4 5 6 7 8 9 10 | #Process a file $SiteID = '<Destination Site ID>' # Site ID of where the file to be processed is located in. $listItemUniqueId = "dea60b95-c97d-4507-9eeb-68d60c7374f4" #i.e. dea60b95-c97d-4507-9eeb-68d60c7374f4 is Aviation Incident Report - AA-1498-14062021.docx $json = "{ ""@odata.type"": ""#microsoft.graph.documentProcessingJob"", ""jobType"": ""File"", ""listItemUniqueId"": ""$listItemUniqueId"", }" $value = Invoke-PnPGraphMethod -Url "https://graph.microsoft.com/beta/sites/$SiteID/documentProcessingJobs" -Method Post -Content $json -ContentType "application/json" $value |

Result: This shows details of the file marked for reprocessing.
Folder
1 2 3 4 5 6 7 8 9 10 | #Process a folder $SiteID = '<Destination Site ID>' # Site ID of where the file to be processed is located in. $listItemUniqueId = "b1947de3-e679-4b7f-adbe-cac77e981869" #Folder named "Folder" $json = "{ ""@odata.type"": ""#microsoft.graph.documentProcessingJob"", ""jobType"": ""Folder"", ""listItemUniqueId"": ""$listItemUniqueId"", }" $value = Invoke-PnPGraphMethod -Url "https://graph.microsoft.com/beta/sites/$SiteID/documentProcessingJobs" -Method Post -Content $json -ContentType "application/json" $value |

Result: This shows details of the folder marked for reprocessing.
Summary
It’s great that SP Premium is now coming to MS Graph and a very welcome addition. This should help with some orgs who are wanting to use MS Graph first and not rely on the older SPO REST API calls for models.
I personally cannot wait for other SP Premium commands i.e. trigger Content Assembly document generation to become available. This will be a killer to allow document generation from code at a large scale – Imagine contracts, job sheets etc being generated automatically!
Although the Graph commands are in beta and are subject to change – they were easy to follow and execute. I look forward to implementing document processing model MS Graph commands into provisioning solutions to ensure models are also provisioned at the same time.