curl --request POST \
--url https://api.example.com/v2/mailbox-settings/microsoft/consent-callback \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"admin_consent": true,
"tenant": "<string>",
"state": "<string>",
"scope": "<string>",
"error": "<string>",
"error_description": "<string>"
}
'import requests
url = "https://api.example.com/v2/mailbox-settings/microsoft/consent-callback"
payload = {
"admin_consent": True,
"tenant": "<string>",
"state": "<string>",
"scope": "<string>",
"error": "<string>",
"error_description": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
admin_consent: true,
tenant: '<string>',
state: '<string>',
scope: '<string>',
error: '<string>',
error_description: '<string>'
})
};
fetch('https://api.example.com/v2/mailbox-settings/microsoft/consent-callback', 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://api.example.com/v2/mailbox-settings/microsoft/consent-callback",
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([
'admin_consent' => true,
'tenant' => '<string>',
'state' => '<string>',
'scope' => '<string>',
'error' => '<string>',
'error_description' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.example.com/v2/mailbox-settings/microsoft/consent-callback"
payload := strings.NewReader("{\n \"admin_consent\": true,\n \"tenant\": \"<string>\",\n \"state\": \"<string>\",\n \"scope\": \"<string>\",\n \"error\": \"<string>\",\n \"error_description\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.example.com/v2/mailbox-settings/microsoft/consent-callback")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"admin_consent\": true,\n \"tenant\": \"<string>\",\n \"state\": \"<string>\",\n \"scope\": \"<string>\",\n \"error\": \"<string>\",\n \"error_description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v2/mailbox-settings/microsoft/consent-callback")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"admin_consent\": true,\n \"tenant\": \"<string>\",\n \"state\": \"<string>\",\n \"scope\": \"<string>\",\n \"error\": \"<string>\",\n \"error_description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"transport_provider": "nylas",
"hybrid_mode_enabled": true,
"microsoft": {
"enabled": true,
"admin_consented": true,
"admin_consented_at": "2023-11-07T05:31:56Z",
"application_scopes": [
"<string>"
],
"delegated_scopes": [
"<string>"
],
"azure_tenant_id": "<string>",
"azure_client_id": "<string>",
"is_byo": true,
"uses_legacy_entra_app": true
},
"google": {
"enabled": true
},
"centralized_inbox": {
"auto_assign": true,
"auto_assign_threshold": 123,
"matching_guidelines": "<string>"
},
"sendgrid": {
"domain_name": "<string>",
"inbound_parse_hostname": "<string>",
"effective_inbound_hostname": "<string>",
"has_api_key": true
}
}{
"type": "request-validation",
"status": 422,
"title": "<string>",
"errors": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
],
"detail": "<string>"
}Handle Admin Consent Callback
Unauthenticated: Microsoft redirects the browser here without a Stuut
session, so the signed state token is the only proof of who started
the flow. We verify it, derive the org from its claims, and open a tenant
session for that org. On success, stamps the consent timestamp and stores
the granted scopes; on failure, raises with the provider error.
curl --request POST \
--url https://api.example.com/v2/mailbox-settings/microsoft/consent-callback \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"admin_consent": true,
"tenant": "<string>",
"state": "<string>",
"scope": "<string>",
"error": "<string>",
"error_description": "<string>"
}
'import requests
url = "https://api.example.com/v2/mailbox-settings/microsoft/consent-callback"
payload = {
"admin_consent": True,
"tenant": "<string>",
"state": "<string>",
"scope": "<string>",
"error": "<string>",
"error_description": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
admin_consent: true,
tenant: '<string>',
state: '<string>',
scope: '<string>',
error: '<string>',
error_description: '<string>'
})
};
fetch('https://api.example.com/v2/mailbox-settings/microsoft/consent-callback', 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://api.example.com/v2/mailbox-settings/microsoft/consent-callback",
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([
'admin_consent' => true,
'tenant' => '<string>',
'state' => '<string>',
'scope' => '<string>',
'error' => '<string>',
'error_description' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.example.com/v2/mailbox-settings/microsoft/consent-callback"
payload := strings.NewReader("{\n \"admin_consent\": true,\n \"tenant\": \"<string>\",\n \"state\": \"<string>\",\n \"scope\": \"<string>\",\n \"error\": \"<string>\",\n \"error_description\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.example.com/v2/mailbox-settings/microsoft/consent-callback")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"admin_consent\": true,\n \"tenant\": \"<string>\",\n \"state\": \"<string>\",\n \"scope\": \"<string>\",\n \"error\": \"<string>\",\n \"error_description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v2/mailbox-settings/microsoft/consent-callback")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"admin_consent\": true,\n \"tenant\": \"<string>\",\n \"state\": \"<string>\",\n \"scope\": \"<string>\",\n \"error\": \"<string>\",\n \"error_description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"transport_provider": "nylas",
"hybrid_mode_enabled": true,
"microsoft": {
"enabled": true,
"admin_consented": true,
"admin_consented_at": "2023-11-07T05:31:56Z",
"application_scopes": [
"<string>"
],
"delegated_scopes": [
"<string>"
],
"azure_tenant_id": "<string>",
"azure_client_id": "<string>",
"is_byo": true,
"uses_legacy_entra_app": true
},
"google": {
"enabled": true
},
"centralized_inbox": {
"auto_assign": true,
"auto_assign_threshold": 123,
"matching_guidelines": "<string>"
},
"sendgrid": {
"domain_name": "<string>",
"inbound_parse_hostname": "<string>",
"effective_inbound_hostname": "<string>",
"has_api_key": true
}
}{
"type": "request-validation",
"status": 422,
"title": "<string>",
"errors": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
],
"detail": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
True if Microsoft returned admin_consent=True.
Authoritative tenant GUID returned by Microsoft's native admin-consent redirect.
The signed state token from the consent URL, echoed back.
Scopes consented, space-delimited.
OAuth error code on failure.
Response
Successful Response
How mail is transported — 'nylas' (OAuth sync/send) or 'sendgrid' (domain send).
nylas, sendgrid The org's Microsoft mailbox connection: consent state and Entra details.
Show child attributes
Show child attributes
The org's Google mailbox connection state.
Show child attributes
Show child attributes
Routing / auto-assignment config for the centralized inbox.
Show child attributes
Show child attributes
SendGrid transport configuration.
Show child attributes
Show child attributes
