Hi,
It is possible to set Microsoft Information Protection sensitivity labels by appending a singleValueExtendedProperties block, although in a slightly different way that Glen mentions above. You'll need:
- Entra tenant ID
- The human-readable name of your sensitivity label
- The GUID associated with that label. This can be obtained from the M365 admin interface or using a browser's dev tools to view the response from PolicyHandler.ashx?action=getpolicylabels when assigning a label to a Word document, for example
This is the updated request body...
{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [
{
"emailAddress": {
"address": "******@domain.com"
}
}
],
"singleValueExtendedProperties": [
{
"id": "String {00020386-0000-0000-C000-000000000046} Name msip_labels",
"value": "MSIP_Label_<SENSITIVITY_LABEL_GUID>_Enabled=True;MSIP_Label_<SENSITIVITY_LABEL_GUID>_SiteId=<ENTRA_TENANT_ID>;MSIP_Label_<SENSITIVITY_LABEL_GUID>_SetDate=<ISO_8601_TIMESTAMP>;MSIP_Label_<SENSITIVITY_LABEL_GUID>_Name=<SENSITIVITY_LABEL_NAME>;MSIP_Label_<SENSITIVITY_LABEL_GUID>_ContentBits=1;MSIP_Label_<SENSITIVITY_LABEL_GUID>_Method=Privileged;"
}
]
}
This is a Powershell representation of the message object, where it's perhaps easier to read the singleValueExtendedProperties details:
$timeStamp = (Get-Date -Format "yyyy-MM-ddTHH:mm:ss.fffZ")
$tenantId = "11111111-1111-1111-1111-111111111111"
$label = @{
name = "Confidential"
guid = "22222222-2222-2222-2222-222222222222"
}
$emailPayload = @{
message = @{
subject = "Meet for lunch?"
body = @{
contentType = "Text"
content = "The new cafeteria is open."
}
toRecipients = @(
@{
emailAddress = @{
address = "******@domain.com"
}
}
)
singleValueExtendedProperties = @(
@{
id = "String {00020386-0000-0000-C000-000000000046} Name msip_labels"
value = "MSIP_Label_$($label.guid)_Enabled=True;`
MSIP_Label_$($label.guid)_SiteId=$($tenantId);`
MSIP_Label_$($label.guid)_SetDate=$($timeStamp);`
MSIP_Label_$($label.guid)_Name=$($label.name);`
MSIP_Label_$($label.guid)_ContentBits=1;`
MSIP_Label_$($label.guid)_Method=Privileged;"
}
)
}
}
Hope that's useful.