Handle Outlook (Microsoft Graph) change notification
curl --request POST \
--url https://your-instance.example.com/api/webhook/email/outlook \
--header 'Content-Type: application/json' \
--data '
{
"value": [
{
"subscriptionId": "7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e",
"subscriptionExpirationDateTime": "2026-05-20T15:04:01.135Z",
"changeType": "created",
"resource": "Users/ops@acme.example/Messages/AAMkAGI2T..==",
"resourceData": {
"@odata.type": "#Microsoft.Graph.Message",
"@odata.id": "Users/ops@acme.example/Messages/AAMkAGI2T..==",
"id": "AAMkAGI2T..=="
},
"clientState": "tether-outlook-secret",
"tenantId": "5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e"
}
]
}
'import requests
url = "https://your-instance.example.com/api/webhook/email/outlook"
payload = { "value": [
{
"subscriptionId": "7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e",
"subscriptionExpirationDateTime": "2026-05-20T15:04:01.135Z",
"changeType": "created",
"resource": "Users/ops@acme.example/Messages/AAMkAGI2T..==",
"resourceData": {
"@odata.type": "#Microsoft.Graph.Message",
"@odata.id": "Users/ops@acme.example/Messages/AAMkAGI2T..==",
"id": "AAMkAGI2T..=="
},
"clientState": "tether-outlook-secret",
"tenantId": "5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
value: [
{
subscriptionId: '7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e',
subscriptionExpirationDateTime: '2026-05-20T15:04:01.135Z',
changeType: 'created',
resource: 'Users/ops@acme.example/Messages/AAMkAGI2T..==',
resourceData: {
'@odata.type': '#Microsoft.Graph.Message',
'@odata.id': 'Users/ops@acme.example/Messages/AAMkAGI2T..==',
id: 'AAMkAGI2T..=='
},
clientState: 'tether-outlook-secret',
tenantId: '5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e'
}
]
})
};
fetch('https://your-instance.example.com/api/webhook/email/outlook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/webhook/email/outlook",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'value' => [
[
'subscriptionId' => '7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e',
'subscriptionExpirationDateTime' => '2026-05-20T15:04:01.135Z',
'changeType' => 'created',
'resource' => 'Users/ops@acme.example/Messages/AAMkAGI2T..==',
'resourceData' => [
'@odata.type' => '#Microsoft.Graph.Message',
'@odata.id' => 'Users/ops@acme.example/Messages/AAMkAGI2T..==',
'id' => 'AAMkAGI2T..=='
],
'clientState' => 'tether-outlook-secret',
'tenantId' => '5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/webhook/email/outlook"
payload := strings.NewReader("{\n \"value\": [\n {\n \"subscriptionId\": \"7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e\",\n \"subscriptionExpirationDateTime\": \"2026-05-20T15:04:01.135Z\",\n \"changeType\": \"created\",\n \"resource\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"resourceData\": {\n \"@odata.type\": \"#Microsoft.Graph.Message\",\n \"@odata.id\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"id\": \"AAMkAGI2T..==\"\n },\n \"clientState\": \"tether-outlook-secret\",\n \"tenantId\": \"5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your-instance.example.com/api/webhook/email/outlook")
.header("Content-Type", "application/json")
.body("{\n \"value\": [\n {\n \"subscriptionId\": \"7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e\",\n \"subscriptionExpirationDateTime\": \"2026-05-20T15:04:01.135Z\",\n \"changeType\": \"created\",\n \"resource\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"resourceData\": {\n \"@odata.type\": \"#Microsoft.Graph.Message\",\n \"@odata.id\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"id\": \"AAMkAGI2T..==\"\n },\n \"clientState\": \"tether-outlook-secret\",\n \"tenantId\": \"5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/webhook/email/outlook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"value\": [\n {\n \"subscriptionId\": \"7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e\",\n \"subscriptionExpirationDateTime\": \"2026-05-20T15:04:01.135Z\",\n \"changeType\": \"created\",\n \"resource\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"resourceData\": {\n \"@odata.type\": \"#Microsoft.Graph.Message\",\n \"@odata.id\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"id\": \"AAMkAGI2T..==\"\n },\n \"clientState\": \"tether-outlook-secret\",\n \"tenantId\": \"5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body"A1B2C3D4-E5F6-7890-ABCD-EF1234567890""Accepted"{
"error": "Webhook processing failed"
}Webhooks
Handle Outlook (Microsoft Graph) change notification
Inbound webhook called by Microsoft Graph when a subscribed mailbox receives a new message. On subscription creation Graph performs a validation handshake by sending a validationToken query parameter, which the endpoint echoes back as plain text. Notification payloads are accepted with 202 and processed asynchronously.
POST
/
api
/
webhook
/
email
/
outlook
Handle Outlook (Microsoft Graph) change notification
curl --request POST \
--url https://your-instance.example.com/api/webhook/email/outlook \
--header 'Content-Type: application/json' \
--data '
{
"value": [
{
"subscriptionId": "7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e",
"subscriptionExpirationDateTime": "2026-05-20T15:04:01.135Z",
"changeType": "created",
"resource": "Users/ops@acme.example/Messages/AAMkAGI2T..==",
"resourceData": {
"@odata.type": "#Microsoft.Graph.Message",
"@odata.id": "Users/ops@acme.example/Messages/AAMkAGI2T..==",
"id": "AAMkAGI2T..=="
},
"clientState": "tether-outlook-secret",
"tenantId": "5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e"
}
]
}
'import requests
url = "https://your-instance.example.com/api/webhook/email/outlook"
payload = { "value": [
{
"subscriptionId": "7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e",
"subscriptionExpirationDateTime": "2026-05-20T15:04:01.135Z",
"changeType": "created",
"resource": "Users/ops@acme.example/Messages/AAMkAGI2T..==",
"resourceData": {
"@odata.type": "#Microsoft.Graph.Message",
"@odata.id": "Users/ops@acme.example/Messages/AAMkAGI2T..==",
"id": "AAMkAGI2T..=="
},
"clientState": "tether-outlook-secret",
"tenantId": "5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
value: [
{
subscriptionId: '7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e',
subscriptionExpirationDateTime: '2026-05-20T15:04:01.135Z',
changeType: 'created',
resource: 'Users/ops@acme.example/Messages/AAMkAGI2T..==',
resourceData: {
'@odata.type': '#Microsoft.Graph.Message',
'@odata.id': 'Users/ops@acme.example/Messages/AAMkAGI2T..==',
id: 'AAMkAGI2T..=='
},
clientState: 'tether-outlook-secret',
tenantId: '5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e'
}
]
})
};
fetch('https://your-instance.example.com/api/webhook/email/outlook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/webhook/email/outlook",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'value' => [
[
'subscriptionId' => '7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e',
'subscriptionExpirationDateTime' => '2026-05-20T15:04:01.135Z',
'changeType' => 'created',
'resource' => 'Users/ops@acme.example/Messages/AAMkAGI2T..==',
'resourceData' => [
'@odata.type' => '#Microsoft.Graph.Message',
'@odata.id' => 'Users/ops@acme.example/Messages/AAMkAGI2T..==',
'id' => 'AAMkAGI2T..=='
],
'clientState' => 'tether-outlook-secret',
'tenantId' => '5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/webhook/email/outlook"
payload := strings.NewReader("{\n \"value\": [\n {\n \"subscriptionId\": \"7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e\",\n \"subscriptionExpirationDateTime\": \"2026-05-20T15:04:01.135Z\",\n \"changeType\": \"created\",\n \"resource\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"resourceData\": {\n \"@odata.type\": \"#Microsoft.Graph.Message\",\n \"@odata.id\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"id\": \"AAMkAGI2T..==\"\n },\n \"clientState\": \"tether-outlook-secret\",\n \"tenantId\": \"5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your-instance.example.com/api/webhook/email/outlook")
.header("Content-Type", "application/json")
.body("{\n \"value\": [\n {\n \"subscriptionId\": \"7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e\",\n \"subscriptionExpirationDateTime\": \"2026-05-20T15:04:01.135Z\",\n \"changeType\": \"created\",\n \"resource\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"resourceData\": {\n \"@odata.type\": \"#Microsoft.Graph.Message\",\n \"@odata.id\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"id\": \"AAMkAGI2T..==\"\n },\n \"clientState\": \"tether-outlook-secret\",\n \"tenantId\": \"5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/webhook/email/outlook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"value\": [\n {\n \"subscriptionId\": \"7f4b2c1d-9e0a-4b3c-8d5e-6f7a8b9c0d1e\",\n \"subscriptionExpirationDateTime\": \"2026-05-20T15:04:01.135Z\",\n \"changeType\": \"created\",\n \"resource\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"resourceData\": {\n \"@odata.type\": \"#Microsoft.Graph.Message\",\n \"@odata.id\": \"Users/ops@acme.example/Messages/AAMkAGI2T..==\",\n \"id\": \"AAMkAGI2T..==\"\n },\n \"clientState\": \"tether-outlook-secret\",\n \"tenantId\": \"5f7b1c2e-8a1d-4e00-12c3-b4a55f7b1c2e\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body"A1B2C3D4-E5F6-7890-ABCD-EF1234567890""Accepted"{
"error": "Webhook processing failed"
}Query Parameters
Sent by Microsoft Graph during subscription validation. When present the endpoint echoes it back as text/plain and skips notification processing.
Body
application/json
Microsoft Graph change notification batch.
Array of change notifications Microsoft Graph batches into one request.
Show child attributes
Show child attributes
Response
Validation handshake — the supplied validationToken is echoed back as plain text.
The response is of type string.
⌘I