Create Outlook category
Article
07/20/2022
11 contributors
Feedback
In this article
Namespace: microsoft.graph
Create an outlookCategory object in the user's master list of categories.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
MailboxSettings.ReadWrite
Delegated (personal Microsoft account)
MailboxSettings.ReadWrite
Application
MailboxSettings.ReadWrite
HTTP request
POST /me/outlook/masterCategories
POST /users/{id|userPrincipalName}/outlook/masterCategories
Name
Description
Authorization
Bearer {token}. Required.
Content-Type
application/json. Required.
Request body
In the request body, supply a JSON representation of an outlookCategory object.
Response
If successful, this method returns a 201 Created
response code and an outlookCategory object in the response body.
Example
Request
The following is an example of a request.
POST https://graph.microsoft.com/v1.0/me/outlook/masterCategories
Content-type: application/json
Content-Length: 70
{
"displayName": "Project expenses",
"color": "preset9"
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new OutlookCategory
{
DisplayName = "Project expenses",
Color = CategoryColor.Preset9,
};
var result = await graphClient.Me.Outlook.MasterCategories.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewOutlookCategory()
displayName := "Project expenses"
requestBody.SetDisplayName(&displayName)
color := graphmodels.PRESET9_CATEGORYCOLOR
requestBody.SetColor(&color)
result, err := graphClient.Me().Outlook().MasterCategories().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
OutlookCategory outlookCategory = new OutlookCategory();
outlookCategory.displayName = "Project expenses";
outlookCategory.color = CategoryColor.PRESET9;
graphClient.me().outlook().masterCategories()
.buildRequest()
.post(outlookCategory);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const outlookCategory = {
displayName: 'Project expenses',
color: 'preset9'
};
await client.api('/me/outlook/masterCategories')
.post(outlookCategory);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestBody = new OutlookCategory();
$requestBody->setDisplayName('Project expenses');
$requestBody->setColor(new CategoryColor('preset9'));
$result = $graphServiceClient->me()->outlook()->masterCategories()->post($requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Import-Module Microsoft.Graph.Users
$params = @{
displayName = "Project expenses"
color = "preset9"
}
# A UPN can also be used as -UserId.
New-MgUserOutlookMasterCategory -UserId $userId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
The following is an example of the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('8ae6f565-0d7f-4ead-853e-7db94c912a1f')/outlook/masterCategories/$entity",
"id": "bac262b7-485d-4739-b436-e31467d64fac",
"displayName": "Project expenses",
"color": "preset9"
}