Skip to main content
Version: 1.27.19

Update the Blocklist

The EasyLife 365 Mail API replaces the mail blocklist. The blocklist prevents end users from creating resources that match or contain blocklist terms. A term is either a specific email prefix or a simple wildcard term that uses an asterisk (*) for any characters. For instance, an organization might block prefixes such as admin@, marketing@ and sales@ to reduce unsolicited email.

Permissions​

Permission typePermissionRate limit
Delegated (work or school account)Mail.Blocklist.WriteCreate, update, delete
ApplicationMail.Blocklist.ReadWrite.All or Mail.Manage.ReadWrite.All (either one)Create, update, delete

This route is part of the Admin API. Grant the application role on the EasyLife 365 Admin application in your tenant; see Call the API as an application. The delegated scope is https://api.easylife365.cloud/admin/Mail.Blocklist.Write. With the Insiders version, use api.insiders.easylife365.cloud.

HTTP request​

PUT https://api.easylife365.cloud/admin/mail/v1/blocklist
Content-Type: application/json

HTTP request headers​

HeaderValue
AuthorizationBearer token. (Required)
Content-Typeapplication/json

Request body​

The body is a JSON array of terms. The call replaces the whole blocklist, so send every term you want to keep.

RuleDetail
TermsStrings. Each term is trimmed, and blank entries and duplicates are dropped.
Maximum100 terms.
Clear the listSend an empty array [].
[ "admin", "info", "marketing", "admin*", "*test*", "*user" ]

Response​

200 OK with the array of terms that is now stored.

[ "admin", "info", "marketing", "admin*", "*test*", "*user" ]

Error responses​

Errors are application/problem+json. See Call the API as an application.

StatusCodeWhen
400Mail.InvalidBlocklistThe body is missing, has more than 100 terms, or has only blank terms. Send [] to clear the list.
401noneThe token is missing or not valid.
403noneThe token has neither the scope nor one of the roles above, or it is a read role.
429RateLimitedToo many calls.
500InfrastructureErrorThe call could not be completed. Give support the requestId.
{
"type": "https://docs.easylife365.cloud/errors/mail/invalid-blocklist",
"title": "The blocklist is not valid.",
"status": 400,
"code": "Mail.InvalidBlocklist",
"requestId": "e1d4b7a9-2c58-4f13-8a6e-7b0c9d3f5a21"
}

Audit​

This call writes no entry to the audit log. The change is stored with the settings. With an application token the calling application is not recorded.

Example 1: Replace the blocklist with curl​

curl -s -X PUT "https://api.easylife365.cloud/admin/mail/v1/blocklist" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '[ "admin", "info", "marketing", "admin*", "*test*", "*user" ]'

Example 2: Replace the blocklist as an application with PowerShell​

First get a token with the scope https://api.easylife365.cloud/admin/.default. The token must carry one of the roles above.

$headers = @{ Authorization = "Bearer $token" }

$terms = @("admin", "info", "marketing", "admin*", "*test*", "*user")
$json = ConvertTo-Json -InputObject $terms -Compress

Write-Information "Setting the blocklist to: $json" -InformationAction Continue
Invoke-RestMethod -Method Put -Headers $headers -ContentType "application/json" -Body $json `
-Uri "https://api.easylife365.cloud/admin/mail/v1/blocklist"

Example 3: Replace the blocklist as a signed-in administrator with PowerShell​

Register an application as described in Create Application Registration and note the tenant ID.

$tenantId = "<tenant-id>"
$scope = "https://api.easylife365.cloud/admin/Mail.Blocklist.Write"

az login --tenant $tenantId | Out-Null

$accessToken = az account get-access-token `
--tenant $tenantId `
--scope $scope `
--query accessToken `
--output tsv

$headers = @{ Authorization = "Bearer $accessToken" }
$json = ConvertTo-Json -InputObject @("admin", "info", "marketing") -Compress
Invoke-RestMethod -Method Put -Headers $headers -ContentType "application/json" -Body $json `
-Uri "https://api.easylife365.cloud/admin/mail/v1/blocklist"