bart2puck
bart2puck

Reputation: 2522

How can I get subscription IDs from Microsoft Graph API? Current results don't seem accurate

Assume a customer has 3 subscriptions:

Exchange Online (Plan 1)

Microsoft 365 E3

Microsoft Teams Room Pro

In the admin portal (https://admin.microsoft.com/) I can see the subs and counts and such. If I click into Exchange Online Plan 1 The url in my browser changes to:

https://admin.microsoft.com/Adminportal/Home?source=applauncher#/subscriptions/assets/1f623e61-6645-4d63-d853-XXYZ?skipReload=true

Note the ID after assets.

Now, If i use the Graph API and list all subscriptions, I do see the Exchange online Plan 1, but the subscription ID is different.

$url ="https://graph.microsoft.com/v1.0/directory/subscriptions";

stdClass Object
(
[@odata.context] => https://graph.microsoft.com/v1.0/$metadata#directory/subscriptions
[value] => Array
    (
        [0] => stdClass Object
            (
                [createdDateTime] => 2023-04-27T15:27:35Z
                [commerceSubscriptionId] => 1234567-de25-4aff-858c-AABBCCDD
                [id] => 123456-2a6d-4630-9931-SomethingNotCloseToOtherId
                [isTrial] => 
                [nextLifecycleDateTime] => 2025-04-03T00:00:00Z
                [skuId] => c5928f49-12ba-48f7-ada3-0d743a3601d5
                [skuPartNumber] => SomeExchangeSKu
                [status] => Enabled
                [totalLicenses] => 5
                [ownerTenantId] => 
                [ownerId] => 
                [ownerType] => 
                [serviceStatus] => Array

I would expect the id parameter do be the same as the id I saw in the url. Am I calling the wrong endpoint? What am I missing?

enter image description here

enter image description here

Upvotes: 0

Views: 87

Answers (1)

Rukmini
Rukmini

Reputation: 16064

The ID in the below URL when clicked on the license is commerceSubscriptionId.

  • The id of the subscription entity in the https://commerceapi.office.net/v1 API refers to a unique identifier for a specific subscription in the Microsoft 365 commerce system.

I executed the below query:

https://graph.microsoft.com/v1.0/directory/subscriptions

The ID in the URL will be displayed under commerceSubscriptionId in the response.

And you can also get the details of commerce Subscription Id by using the below query:

https://graph.microsoft.com/v1.0/directory/subscriptions/IDFromURL/commerceSubscriptionId

  • If Customer A and Customer B are on different subscriptions for Exchange Online Plan 1, their skuIds could be different (ending in 123 vs 234). This difference reflects the specific subscription or SKU instance for each customer.

Upvotes: 0

Related Questions