Manage mailboxes and distribution lists
Four routes read and change the template and the policy of one shared, room or equipment mailbox, distribution list or mail-enabled security group. The template says how the mailbox or list was created and what it looks like. The policy says which rules apply to it, such as owners, confirmation and access review.
The routes accept a signed-in administrator and an application. To call them as an application, see Call the API as an application.
Permissions
| Method | Route | Delegated scope | Application roles | Rate limit |
|---|---|---|---|---|
GET | /admin/mail/v1/manage/mailboxes/{id} | Config.ReadWrite.All | Mail.Manage.Read.All, Mail.Manage.ReadWrite.All | Read |
PATCH | /admin/mail/v1/manage/mailboxes/{id} | Config.ReadWrite.All | Mail.Manage.ReadWrite.All | Create, update, delete |
GET | /admin/mail/v1/manage/lists/{id} | Config.ReadWrite.All | Mail.Manage.Read.All, Mail.Manage.ReadWrite.All | Read |
PATCH | /admin/mail/v1/manage/lists/{id} | Config.ReadWrite.All | Mail.Manage.ReadWrite.All | Create, update, delete |
{id} is the Entra ID object ID of the mailbox, list or group.
These routes are part of the Admin API. Grant the role on the EasyLife 365 Admin application; the scope of the token is https://api.easylife365.cloud/admin/.default (see Get a token). Mail.Manage.Read.All on a PATCH answers 403 Forbidden. No other role works, including Mail.Blocklist.*, Mail.Provisioning.* and the roles of other products.
HTTP request
GET https://api.easylife365.cloud/admin/mail/v1/manage/mailboxes/6d1d1b0e-0e44-4f5a-8f0e-2f6c1c7d9e11
GET https://api.easylife365.cloud/admin/mail/v1/manage/lists/3b8c9a52-5d9a-4f0c-9e57-8b0c7a1d2e44
PATCH https://api.easylife365.cloud/admin/mail/v1/manage/mailboxes/6d1d1b0e-0e44-4f5a-8f0e-2f6c1c7d9e11
PATCH https://api.easylife365.cloud/admin/mail/v1/manage/lists/3b8c9a52-5d9a-4f0c-9e57-8b0c7a1d2e44
| Header | Value |
|---|---|
| Authorization | Bearer token. Required |
| Content-Type | application/json (PATCH only) |
The response
GET answers 200 OK with the state of the mailbox or list. PATCH answers 200 OK with the same body after the change.
| Property | Type | Description |
|---|---|---|
id | string (UUID) | The Entra object ID. |
displayName | string | The display name. |
isCompliant | boolean | Whether the mailbox or list meets its policy. Left out when it is not known, for example when the mailbox or list has no policy or was not checked yet. After a PATCH that names a policy, it is the result of the check against the new policy. |
metadata | object | The EasyLife data stored on the mailbox or list, such as the template and the owner confirmations. |
policy | object | The EasyLife data stored for the policy, such as the policy ID and the state of each rule. |
schema | object | The EasyLife data stored for the type of the mailbox or list, such as its template ID, policy ID and compliance. |
A member that the mailbox or list does not store is left out. The template of a mailbox or list is schema.templateId, and its policy is schema.policyId.
metadata, policy and schema return the data as EasyLife stores it. The names of the keys inside them are short and can change with the product, without a new version of the route. Read only the keys you need, and expect them to change.
The stored data can contain personal data: the object ID, sign-in name and name of the owner who confirmed or reviewed the mailbox or list, the two owners of a mailbox, and the answers that requesters typed into the template fields. Treat the response as personal data.
Example: read a mailbox
curl -s "https://api.easylife365.cloud/admin/mail/v1/manage/mailboxes/6d1d1b0e-0e44-4f5a-8f0e-2f6c1c7d9e11" \
-H "Authorization: Bearer $TOKEN"
Invoke-RestMethod -Method Get -Headers $headers `
-Uri "https://api.easylife365.cloud/admin/mail/v1/manage/mailboxes/6d1d1b0e-0e44-4f5a-8f0e-2f6c1c7d9e11"
The example answer is shortened. The real objects list every key the mailbox or list stores.
{
"id": "6d1d1b0e-0e44-4f5a-8f0e-2f6c1c7d9e11",
"displayName": "Finance shared mailbox",
"isCompliant": true,
"metadata": { "tId": "9f0a7a2e-2b3c-4a50-8d9e-0b7a1d6c4e21" },
"policy": { "pId": "c4b8a2f1-77de-4ea8-9ab0-5b0c1f3d2a10" },
"schema": {
"resourceType": "SharedMailbox",
"templateId": "9f0a7a2e-2b3c-4a50-8d9e-0b7a1d6c4e21",
"policyId": "c4b8a2f1-77de-4ea8-9ab0-5b0c1f3d2a10",
"isCompliant": true
}
}
Example: read a distribution list
curl -s "https://api.easylife365.cloud/admin/mail/v1/manage/lists/3b8c9a52-5d9a-4f0c-9e57-8b0c7a1d2e44" \
-H "Authorization: Bearer $TOKEN"
{
"id": "3b8c9a52-5d9a-4f0c-9e57-8b0c7a1d2e44",
"displayName": "Marketing Team",
"isCompliant": false,
"metadata": { "tId": "2fd0dba8-d2fe-4b51-866b-622d7fa3c22b" },
"policy": { "pId": "e7a3d1c9-3f52-4b86-a1d4-6c2b9f0e8a15" },
"schema": {
"resourceType": "DistributionGroup",
"templateId": "2fd0dba8-d2fe-4b51-866b-622d7fa3c22b",
"policyId": "e7a3d1c9-3f52-4b86-a1d4-6c2b9f0e8a15",
"isCompliant": false
}
}
Change the template and the policy
The body names templateId, policyId, or both, and nothing else.
| Property | Type | Description |
|---|---|---|
templateId | string (UUID) | The template to assign. Leave it out to keep the current template. The all-zero GUID 00000000-0000-0000-0000-000000000000 clears it. |
policyId | string (UUID) | The policy to assign. Leave it out to keep the current policy. The all-zero GUID clears it. |
The template and the policy must be active, and they must fit the mailbox or list: a distribution list template does not fit a mailbox, and a mailbox policy does not fit a list. The template and the policy are applied the same way as in EasyLife 365 Admin. If a part of the change cannot be completed, the call still succeeds and the response carries the header X-EL-Warning. When there is more than one warning, the values are joined with a comma and a space. On a mailbox the values are:
retention-policy-not-applied: the Exchange retention policy of the mailbox template could not be applied. The template is assigned.owners-permissions-not-synced: the policy check changed an owner, and the Exchange permissions of that owner could not be changed. The owner change is saved.owners-updated-followup-failed: the owner change is saved, and the audit entries for it could not be written.
You cannot change anything else of the mailbox or list with these routes, such as its owners. A body with another member is refused instead of being ignored. The policy check can still clear or add an owner when it runs, as it does in EasyLife 365 Admin.
Example: assign a template and clear the policy
curl -s -X PATCH "https://api.easylife365.cloud/admin/mail/v1/manage/mailboxes/6d1d1b0e-0e44-4f5a-8f0e-2f6c1c7d9e11" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "templateId": "9f0a7a2e-2b3c-4a50-8d9e-0b7a1d6c4e21", "policyId": "00000000-0000-0000-0000-000000000000" }'
$body = @{
templateId = "9f0a7a2e-2b3c-4a50-8d9e-0b7a1d6c4e21"
policyId = "00000000-0000-0000-0000-000000000000"
} | ConvertTo-Json
Invoke-RestMethod -Method Patch -Headers $headers -ContentType "application/json" -Body $body `
-Uri "https://api.easylife365.cloud/admin/mail/v1/manage/mailboxes/6d1d1b0e-0e44-4f5a-8f0e-2f6c1c7d9e11"
Request body:
{
"templateId": "9f0a7a2e-2b3c-4a50-8d9e-0b7a1d6c4e21",
"policyId": "00000000-0000-0000-0000-000000000000"
}
Response 200 OK:
{
"id": "6d1d1b0e-0e44-4f5a-8f0e-2f6c1c7d9e11",
"displayName": "Finance shared mailbox",
"metadata": { "tId": "9f0a7a2e-2b3c-4a50-8d9e-0b7a1d6c4e21" },
"schema": {
"resourceType": "SharedMailbox",
"templateId": "9f0a7a2e-2b3c-4a50-8d9e-0b7a1d6c4e21"
}
}
The same change on a list uses the route /admin/mail/v1/manage/lists/{id} and the same body.
Error responses
Errors are application/problem+json. See Call the API as an application.
| Status | Code | When |
|---|---|---|
| 400 | InvalidPayload | The body names neither templateId nor policyId, or names another member. |
| 400 | Mail.MailboxTypeNotSupported | The mailbox is of a type that has no template. |
| 400 | Mail.NoEntraAssociation | The list is not connected to an Entra ID group. |
| 401 | none | The token is missing or not valid. |
| 403 | none | The token has no role that this route accepts, or the role is Mail.Manage.Read.All on a PATCH. |
| 404 | Mail.MailboxNotFound, Mail.DistributionListNotFound, NotFound | The mailbox or list does not exist in your tenant. |
| 404 | Mail.TemplateNotFound, Mail.PolicyNotFound | The template or policy does not exist. |
| 409 | Mail.TemplateNotActive, Mail.PolicyNotActive | The template or policy is not active. |
| 409 | Mail.TemplateNotApplicable, Mail.WrongPolicyType | The template or policy is for another kind of resource. |
| 429 | RateLimited | Too many calls. |
When a call is refused with InvalidPayload, 403, 404 or 409, nothing was changed. After any other 400 or a 500, read the mailbox or list again with GET to see what was saved. Example:
{
"type": "https://docs.easylife365.cloud/errors/mail/template-not-active",
"title": "The template is not active.",
"status": 409,
"code": "Mail.TemplateNotActive",
"requestId": "b3a1c5e2-0d0f-4c53-8d7b-5e2a9f6c1d70"
}
{
"type": "https://docs.easylife365.cloud/errors/invalid-payload",
"title": "The request could not be accepted.",
"status": 400,
"detail": "Only templateId and policyId can be changed here. Unknown member: owners.",
"code": "InvalidPayload",
"requestId": "0f8e2a64-1c3d-4b7a-9e55-2d6c8a1b3f90"
}
Audit
When audit logging is turned on, a change is written to the audit log of the mailbox or list, with the application as the actor when an application made the call. One event is written for each thing that changed: ASSIGN-POLICY, REMOVE-POLICY, ASSIGN-TEMPLATE or REMOVE-TEMPLATE. On a mailbox, when the policy check changes an owner, it also writes ASSIGN-OWNER, REMOVE-OWNER, ASSIGN-OWNER-PERMISSION and REMOVE-OWNER-PERMISSION, and the -FAILED variant of a permission event when Exchange refused the change. An owner that the policy check clears carries the category POLICY, not ADMIN. The follow-up entries for owners can fail to be written; that is the owners-updated-followup-failed warning. A request that repeats the current value writes no event. A read is not written to the audit log.