How to get a list of Contact Categories using API

Andrew Troian 10 Reputation points
2023-02-21T05:07:25.78+00:00

On UI I see a list of "Categories"

Снимок экрана 2023-02-21 в 00.17.13

In API documentation, endpoints described endpoints to get a list of categories:

https://graph.microsoft.com/v1.0/me/outlook/masterCategories

But it is the same endpoint to get a list of categories related to emails.

https://learn.microsoft.com/en-us/graph/api/outlookuser-list-mastercategories?view=graph-rest-1.0&tabs=http

And on the response we get the next data:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('outlook_0C0DDF22D737BAEB%40outlook.com')/outlook/masterCategories",
    "value": [
        {
            "id": "9b2e1935-a325-41bc-9728-43648361096e",
            "displayName": "Red category",
            "color": "preset0"
        },
        {
            "id": "7ae6ef16-f63c-4223-8621-efa42e4d1c29",
            "displayName": "Orange category",
            "color": "preset1"
        },
        {
            "id": "ac414fa5-a7db-468c-999f-54488e313e8e",
            "displayName": "Yellow category",
            "color": "preset3"
        },
        {
            "id": "37a93909-83d7-463d-9ef1-5d1887cb9c6b",
            "displayName": "Green category",
            "color": "preset4"
        },
        {
            "id": "52581046-e7ec-4856-aafc-d9fdf39308a8",
            "displayName": "Blue category",
            "color": "preset7"
        },
        {
            "id": "26aee239-c295-4032-a2dd-df84771c4f04",
            "displayName": "Purple category",
            "color": "preset8"
        },
        {
            "id": "05f136cb-1dee-48b7-a2a2-41f1306890ae",
            "displayName": "Project expenses",
            "color": "preset9"
        },
        {
            "id": "e4cc14a7-abba-417f-996d-e14f044a7486",
            "displayName": "Projecttttsss",
            "color": "preset9"
        }
    ]
}

What is not that we see on UI.

In the API documentation, there is also have contact folder https://learn.microsoft.com/en-us/graph/api/resources/contactfolder?view=graph-rest-1.0

But it returns folders that were created earlier, and if you try to create new folders by POST request to API we will see this folder in GET response but not see on UI.

example below

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('outlook_0C0DDF22D737BAEB%40outlook.com')/contactFolders",
    "value": [
        {
            "id": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAEi6AYgAAAAA==",
            "parentFolderId": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAAAgEOAAAA",
            "displayName": "dotloop"
        },
        {
            "id": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAE3tECSgAAAA==",
            "parentFolderId": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAAAgEOAAAA",
            "displayName": "Google contact"
        },
        {
            "id": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAE7wcm8gAAAA==",
            "parentFolderId": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAAAgEOAAAA",
            "displayName": "Important contacts"
        },
        {
            "id": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAE7wcm9QAAAA==",
            "parentFolderId": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAAAgEOAAAA",
            "displayName": "Important contactsSSSS"
        },
        {
            "id": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAE7wcm9AAAAA==",
            "parentFolderId": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAAAgEOAAAA",
            "displayName": "Important contactsSSSSSS"
        },
        {
            "id": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAEyA028QAAAA==",
            "parentFolderId": "AQMkADAwATNiZmYAZC0wODI5LTlhOTgtMDACLTAwCgAuAAADlyus1LwQ9kCyZNBTzj3YnwEAlaQpULnOlkKT_nNmkipi7gAAAgEOAAAA",
            "displayName": "test app"
        }
    ]
}

Снимок экрана 2023-02-21 в 00.17.13

Please help me with that.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,005 questions
{count} vote

4 answers

Sort by: Most helpful
  1. Zehui Yao_MSFT 5,856 Reputation points
    2023-02-21T07:55:00.83+00:00

    Hi @Andrew Troian , an alternative is to use the $select query parameter to filter out all contact categories, the endpoint is https://graph.microsoft.com/v1.0/me/contacts?$select=categories, not knowing if this will meet your needs.

    User's image


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Andrew Troian 10 Reputation points
    2023-02-21T09:14:26.93+00:00

    @Zehui Yao_MSFT thanks, but I think this doesn't work for me. Снимок экрана 2023-02-21 в 11.10.03

    What we need is first get a full list of categories and then when creating a contact add to selected categories.

    How it was earlier when it was folders. It was possible to add contact into the folder when created.

    0 comments No comments

  3. Andrew Troian 10 Reputation points
    2023-02-21T09:27:49.33+00:00

    @Zehui Yao_MSFT it doesn't work for me. Снимок экрана 2023-02-21 в 11.10.03

    Or maybe it doesn't work now as earlier? Like we get a full list of folders and then when we create a contact add a contact to this folder.

    Is it possible to do the same for Categories?


  4. Marco Enxuto 331 Reputation points
    2023-04-19T15:53:21.5766667+00:00

    Hello, I have the exact same question. I opened a feedback on Feedback portal and it seems the info on docs is confusing. There is in fact two type of categories.

    1. Mail categories, which are related to MasterCategories, via
      1. GET /me/outlook/masterCategories GET /users/{id|userPrincipalName}/outlook/masterCategories
    2. Contact categories, which are Delve based. Delve is part of Microsoft 365, and its purpose is to agregate info related to a user. That info is presented as contact cards. So, looking into Contact categories, there isn't any endpoint exposed to get those. Perphaps Microsoft didn't implemented it yet. Until now, what I could figured out, is that Delve is being used even for Microsoft Accounts. Delve is a tool available for M365 Business only. But in this case, for MSAs or AAD acconts, that service returns what is being called as Contact tags. So, to get the list of these Categories, I guess we have to invoke the following: https://outlook.office.com/PeopleGraphVx/v1.0/contactTags HTTP Get, with it's header MSAuth1.0 usertoken (I do not know what is this token)
    0 comments No comments

Your answer

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