Microsoft Introduces New Cloud Licensing APIs for M365

Microsoft have quietly added new documentation to the Microsoft Graph beta endpoint for the Cloud Licensing APIs. At first glance, this looks to include a simpler set of controls to manage assignments of Microsoft 365 licenses, as well as being able to identify usage rights for licenses in Microsoft 365.

Some of this functionality was released back in 2024, as you may have seen in a previous article I wrote on reporting license usage rights with Microsoft Graph PowerShell. In this article, I’ll explain some of the core new capabilities of these APIs which you can immediately benefit from.

What is the Cloud Licensing API?

While currently in preview, the Cloud Licensing API is a set of APIs which allow developers to read the data generated by Microsoft’s licensing platform. To understand the API, you must understand these two concepts:

  • Microsoft has updated how it handles subscriptions in the background. It now breaks down your tenant’s subscriptions into smaller pools called allotments. You do not create these manually; the system generates them automatically whenever you purchase or renew a subscription.
  • The Cloud Licensing API exposes the final result of those allotments via the usageRight resource.

Simply put, the core of this new capability is the usageRight resource. Unlike the traditional assignedLicenses property on a user object, which simply lists the SKU IDs a user holds, usageRight represents the actual right of a user (or group) to use a specific set of services. Interestingly, it also accounts for rights granted not just directly, but also transitively through group memberships.

Permissions required

These new APIs come with a new set of granular permissions which you need to consent to, depending on which actions you are taking with the API. Some permissions include:

  • CloudLicensing.Read: Allows you to read allotment information.

  • User-UsageRight.Read.All: Allows you to read user assignment and usage rights.

  • Group-UsageRight.Read.All: Allows you to read group assignments and usage rights.

AssignedLicenses vs usageRights

One core distinction in the old way of viewing licensing information is how you obtained details of the licences and entitlements a user held for Microsoft 365 subscriptions.

The distinction lies between the legacy assignedLicenses property on a user object (which can be retrieved for multiple users simultaneously) and the /cloudLicensing/usageRights query (which can only be run against a single user). I covered this in detail in the previous article linked at the top of this page.

If we look at the assignedLicenses property on a user:

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#users(assignedLicenses)/$entity",
  "id": "387c58a2-3fea-4e8e-979d-a49469b89100",
  "assignedLicenses": [
      {
          "disabledPlans": [],
          "skuId": "c42b9cae-ea4f-4ab7-9717-81576235ccac"
      },
      {
          "disabledPlans": [],
          "skuId": "606b54a9-78d8-4298-ad8b-df6ef4481c80"
      },
      {
          "disabledPlans": [],
          "skuId": "8c4ce438-32a7-4ac5-91a6-e22ae08d9c8b"
      },
      {
          "disabledPlans": [],
          "skuId": "639dec6b-bb19-468b-871c-c5c441c4b0cb"
      }
  ]
}
And compare it to the response from the /cloudLicensing/usageRights endpoint.
"value": [
      {
          "id": "jtc4mpic5zk2sc4n2xxoyw6tb3gdh6b3psbbsm2tzbupshjfercq",
          "skuId": "c42b9cae-ea4f-4ab7-9717-81576235ccac",
          "skuPartNumber": "DEVELOPERPACK_E5",
          "services": [
              {
                  "assignableTo": "none",
                  "planId": "b088306e-925b-44ab-baa0-63291c629a91",
                  "planName": "INSIGHTS_BY_MYANALYTICS"
              },
              {
                  "assignableTo": "none",
                  "planId": "0403bb98-9d17-4f94-b53e-eca56a7698a6",
                  "planName": "MICROSOFT_MYANALYTICS_FULL"
                },

You can see that a lot more tangible information is returned. However, to obtain this information for multiple users, you must loop through each user and perform a unique query, which is not manageable at all for large environments.

Improved subscription information

A very useful new feature of the Cloud Licensing API is an improved method to obtain subscription information for licences. Previously, you had to make two requests to the Microsoft Graph API: one to beta/subscribedSkus, where you could obtain information on the consumed number of licences, and one to the beta/directory/subscriptions endpoint, which gave you the nextLifecycleDate. These would then need to be combined.

Now, for a specific allotment (or subscription), you can make a single requests to the graph API to obtain all the information together.

Connect-MgGraph -scope CloudLicensing.Read

$uri = "beta/admin/cloudLicensing/allotments/qpsn6tzgs6zuvuf4t33pzdgtahgisuqvfwur6kzdrkpqdjgyb4gn?`$select=assignableTo,allottedUnits,consumedUnits,skuPartNumber,subscriptions"

$response = Invoke-MgGraphRequest -Uri $uri -Method GET -OutputType PSObject

As you can see from the response below, all the information is returned in a single query.

Improve cloud licensing subscription information
Improve cloud licensing subscription information

Wrapping up

Overall, I like that the Cloud Licensing API is expanding to provide more granular capabilities to manage licences and obtain licensing information. There are still some limitations when performing some of these tasks at scale, but I’m sure further developments will happen over time. For now, you can read a full overview of the API documentation at: Use the cloud licensing API in Microsoft Graph (preview).

Daniel Bradley

Daniel Bradley is a UK-based technical architect and Microsoft MVP in Security. He specialises in Microsoft Entra, Intune, and Microsoft Graph PowerShell and is the author of Microsoft Graph PowerShell for Administrators. He writes and edits Our Cloud Network using experience gained from working with Microsoft cloud environments.

Leave a Reply