See Extended properties overview for more information about when to use
open extensions or extended properties, and how to specify extended properties.
Depending on the resource you're creating the extended property in and the permission type (delegated or application) you request, the permission specified in the following table is the minimum required to call this API. To learn more, including how to choose permissions, see Permissions.
You can create extended properties in a new or existing resource instance.
To create one or more extended properties in a new resource instance, use the same REST request as creating the
instance, and include the properties of the new resource instance and extended property in the request body.
Some resources support creation in more than one way. For more information on creating these resource instances,
see the corresponding articles for creating a message, mailFolder,
event, calendar,
contact, contactFolder,
group event, and group post.
The following is the syntax of the requests.
POST /me/messages
POST /users/{id|userPrincipalName}/messages
POST /me/mailFolders/{id}/messages
POST /me/mailFolders
POST /users/{id|userPrincipalName}/mailFolders
POST /me/events
POST /users/{id|userPrincipalName}/events
POST /me/calendars
POST /users/{id|userPrincipalName}/calendars
POST /me/contacts
POST /users/{id|userPrincipalName}/contacts
POST /me/contactFolders
POST /users/{id|userPrincipalName}/contactFolders
POST /groups/{id}/events
POST /groups/{id}/threads/{id}/posts/{id}/reply
POST /groups/{id}/conversations/{id}/threads/{id}/posts/{id}/reply
POST /groups/{id}/threads/{id}/reply
POST /groups/{id}/conversations/{id}/threads/{id}/reply
POST /groups/{id}/threads
POST /groups/{id}/conversations
To create one or more extended properties in an existing resource instance, specify the instance in the
request, and include the extended property in the request body.
Note You can't create an extended property in an existing group post.
Provide a JSON body of each singleValueLegacyExtendedProperty object in the
singleValueExtendedProperties collection property of the resource instance.
An array of one or more single-valued extended properties.
id
String
For each property in the singleValueExtendedProperties collection, specify this to identify the property. It must follow one of the supported formats. See Outlook extended properties overview for more information. Required.
value
string
For each property in the singleValueExtendedProperties collection, specify the property value. Required.
When creating an extended property in a new resource instance, in addition to the
new singleValueExtendedProperties collection, provide a JSON representation of that resource instance (that is, a message,
mailFolder, event, etc.)
Response
Response code
An operation successful in creating an extended property in a new resource instance returns 201 Created, except in a new group post,
depending on the method used, the operation can return 200 OK or 202 Accepted.
In an existing resource instance, a successful create operation returns 200 OK.
Response body
When creating an extended property, the response includes only the new or existing instance but not the new extended property. To see the newly
created extended property, get the instance expanded with the extended property.
When creating an extended property in a newgroup post by replying to a thread or post, the response includes only
a response code but not the new post nor the extended property.
Examples
Example 1: Create a new event and a single-value extended property
Request
The first example creates a new event and a single-value extended property in the same POST operation. Apart from the properties you'd normally
include for a new event, the request body includes the singleValueExtendedProperties collection that contains one single-value
extended property, and the following for the property:
id specifies the property type as String, the GUID, and the property named Fun.
value specifies Food as the value of the Fun property.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Event
{
Subject = "Celebrate Thanksgiving",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Let's get together!",
},
Start = new DateTimeTimeZone
{
DateTime = "2015-11-26T18:00:00",
TimeZone = "Pacific Standard Time",
},
End = new DateTimeTimeZone
{
DateTime = "2015-11-26T23:00:00",
TimeZone = "Pacific Standard Time",
},
Attendees = new List<Attendee>
{
new Attendee
{
EmailAddress = new EmailAddress
{
Address = "Terrie@contoso.com",
Name = "Terrie Barrera",
},
Type = AttendeeType.Required,
},
},
SingleValueExtendedProperties = new List<SingleValueLegacyExtendedProperty>
{
new SingleValueLegacyExtendedProperty
{
Id = "String {66f5a359-4659-4830-9070-00040ec6ac6e} Name Fun",
Value = "Food",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Events.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Event event = new Event();
event.setSubject("Celebrate Thanksgiving");
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("Let's get together!");
event.setBody(body);
DateTimeTimeZone start = new DateTimeTimeZone();
start.setDateTime("2015-11-26T18:00:00");
start.setTimeZone("Pacific Standard Time");
event.setStart(start);
DateTimeTimeZone end = new DateTimeTimeZone();
end.setDateTime("2015-11-26T23:00:00");
end.setTimeZone("Pacific Standard Time");
event.setEnd(end);
LinkedList<Attendee> attendees = new LinkedList<Attendee>();
Attendee attendee = new Attendee();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setAddress("Terrie@contoso.com");
emailAddress.setName("Terrie Barrera");
attendee.setEmailAddress(emailAddress);
attendee.setType(AttendeeType.Required);
attendees.add(attendee);
event.setAttendees(attendees);
LinkedList<SingleValueLegacyExtendedProperty> singleValueExtendedProperties = new LinkedList<SingleValueLegacyExtendedProperty>();
SingleValueLegacyExtendedProperty singleValueLegacyExtendedProperty = new SingleValueLegacyExtendedProperty();
singleValueLegacyExtendedProperty.setId("String {66f5a359-4659-4830-9070-00040ec6ac6e} Name Fun");
singleValueLegacyExtendedProperty.setValue("Food");
singleValueExtendedProperties.add(singleValueLegacyExtendedProperty);
event.setSingleValueExtendedProperties(singleValueExtendedProperties);
Event result = graphClient.me().events().post(event);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Event;
use Microsoft\Graph\Generated\Models\ItemBody;
use Microsoft\Graph\Generated\Models\BodyType;
use Microsoft\Graph\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Generated\Models\Attendee;
use Microsoft\Graph\Generated\Models\EmailAddress;
use Microsoft\Graph\Generated\Models\AttendeeType;
use Microsoft\Graph\Generated\Models\SingleValueLegacyExtendedProperty;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Event();
$requestBody->setSubject('Celebrate Thanksgiving');
$body = new ItemBody();
$body->setContentType(new BodyType('hTML'));
$body->setContent('Let\'s get together!');
$requestBody->setBody($body);
$start = new DateTimeTimeZone();
$start->setDateTime('2015-11-26T18:00:00');
$start->setTimeZone('Pacific Standard Time');
$requestBody->setStart($start);
$end = new DateTimeTimeZone();
$end->setDateTime('2015-11-26T23:00:00');
$end->setTimeZone('Pacific Standard Time');
$requestBody->setEnd($end);
$attendeesAttendee1 = new Attendee();
$attendeesAttendee1EmailAddress = new EmailAddress();
$attendeesAttendee1EmailAddress->setAddress('Terrie@contoso.com');
$attendeesAttendee1EmailAddress->setName('Terrie Barrera');
$attendeesAttendee1->setEmailAddress($attendeesAttendee1EmailAddress);
$attendeesAttendee1->setType(new AttendeeType('required'));
$attendeesArray []= $attendeesAttendee1;
$requestBody->setAttendees($attendeesArray);
$singleValueExtendedPropertiesSingleValueLegacyExtendedProperty1 = new SingleValueLegacyExtendedProperty();
$singleValueExtendedPropertiesSingleValueLegacyExtendedProperty1->setId('String {66f5a359-4659-4830-9070-00040ec6ac6e} Name Fun');
$singleValueExtendedPropertiesSingleValueLegacyExtendedProperty1->setValue('Food');
$singleValueExtendedPropertiesArray []= $singleValueExtendedPropertiesSingleValueLegacyExtendedProperty1;
$requestBody->setSingleValueExtendedProperties($singleValueExtendedPropertiesArray);
$result = $graphServiceClient->me()->events()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.event import Event
from msgraph.generated.models.item_body import ItemBody
from msgraph.generated.models.body_type import BodyType
from msgraph.generated.models.date_time_time_zone import DateTimeTimeZone
from msgraph.generated.models.attendee import Attendee
from msgraph.generated.models.email_address import EmailAddress
from msgraph.generated.models.attendee_type import AttendeeType
from msgraph.generated.models.single_value_legacy_extended_property import SingleValueLegacyExtendedProperty
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Event(
subject = "Celebrate Thanksgiving",
body = ItemBody(
content_type = BodyType.Html,
content = "Let's get together!",
),
start = DateTimeTimeZone(
date_time = "2015-11-26T18:00:00",
time_zone = "Pacific Standard Time",
),
end = DateTimeTimeZone(
date_time = "2015-11-26T23:00:00",
time_zone = "Pacific Standard Time",
),
attendees = [
Attendee(
email_address = EmailAddress(
address = "Terrie@contoso.com",
name = "Terrie Barrera",
),
type = AttendeeType.Required,
),
],
single_value_extended_properties = [
SingleValueLegacyExtendedProperty(
id = "String {66f5a359-4659-4830-9070-00040ec6ac6e} Name Fun",
value = "Food",
),
],
)
result = await graph_client.me.events.post(request_body)
A successful response is indicated by an HTTP 201 Created response code, and includes the new event in the response body, similar to the response from creating just an event. The response doesn't include any newly created extended properties.
Example 2: Create a single-value extended property for a message
Request
The second example creates one single-value extended property for the specified existing message. That extended property is the only element in the singleValueExtendedProperties array. The request body includes the following for the extended property:
id specifies the property type as String, the GUID, and the property named Color.
value specifies Green as the value of the Color property.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new Message
{
SingleValueExtendedProperties = new List<SingleValueLegacyExtendedProperty>
{
new SingleValueLegacyExtendedProperty
{
Id = "String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color",
Value = "Green",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Messages["{message-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewMessage()
singleValueLegacyExtendedProperty := graphmodels.NewSingleValueLegacyExtendedProperty()
id := "String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color"
singleValueLegacyExtendedProperty.SetId(&id)
value := "Green"
singleValueLegacyExtendedProperty.SetValue(&value)
singleValueExtendedProperties := []graphmodels.SingleValueLegacyExtendedPropertyable {
singleValueLegacyExtendedProperty,
}
requestBody.SetSingleValueExtendedProperties(singleValueExtendedProperties)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
messages, err := graphClient.Me().Messages().ByMessageId("message-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
Message message = new Message();
LinkedList<SingleValueLegacyExtendedProperty> singleValueExtendedProperties = new LinkedList<SingleValueLegacyExtendedProperty>();
SingleValueLegacyExtendedProperty singleValueLegacyExtendedProperty = new SingleValueLegacyExtendedProperty();
singleValueLegacyExtendedProperty.setId("String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color");
singleValueLegacyExtendedProperty.setValue("Green");
singleValueExtendedProperties.add(singleValueLegacyExtendedProperty);
message.setSingleValueExtendedProperties(singleValueExtendedProperties);
Message result = graphClient.me().messages().byMessageId("{message-id}").patch(message);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\Message;
use Microsoft\Graph\Generated\Models\SingleValueLegacyExtendedProperty;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new Message();
$singleValueExtendedPropertiesSingleValueLegacyExtendedProperty1 = new SingleValueLegacyExtendedProperty();
$singleValueExtendedPropertiesSingleValueLegacyExtendedProperty1->setId('String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color');
$singleValueExtendedPropertiesSingleValueLegacyExtendedProperty1->setValue('Green');
$singleValueExtendedPropertiesArray []= $singleValueExtendedPropertiesSingleValueLegacyExtendedProperty1;
$requestBody->setSingleValueExtendedProperties($singleValueExtendedPropertiesArray);
$result = $graphServiceClient->me()->messages()->byMessageId('message-id')->patch($requestBody)->wait();
Import-Module Microsoft.Graph.Mail
$params = @{
singleValueExtendedProperties = @(
@{
id = "String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color"
value = "Green"
}
)
}
# A UPN can also be used as -UserId.
Update-MgUserMessage -UserId $userId -MessageId $messageId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.message import Message
from msgraph.generated.models.single_value_legacy_extended_property import SingleValueLegacyExtendedProperty
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = Message(
single_value_extended_properties = [
SingleValueLegacyExtendedProperty(
id = "String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color",
value = "Green",
),
],
)
result = await graph_client.me.messages.by_message_id('message-id').patch(request_body)
A successful response is indicated by an HTTP 200 OK response code, and includes the specified message in the response body, similar to the response from updating a message. The response doesn't include the newly created extended property.