Skip to main content
Version: 1.27.19

Retrieve the Blocklist

The EasyLife 365 Mail API reads 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.ReadRead
ApplicationMail.Blocklist.Read.All, Mail.Blocklist.ReadWrite.All or Mail.Manage.ReadWrite.All (any one of them)Read

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.Read. With the Insiders version, use api.insiders.easylife365.cloud.

HTTP request​

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

HTTP request headers​

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

Request body​

This request does not take a body.

Response​

200 OK with the array of blocklist terms. An empty array means that nothing is blocked.

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

Error responses​

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

StatusCodeWhen
401noneThe token is missing or not valid.
403noneThe token has neither the scope nor one of the roles above.
429RateLimitedToo many calls.
500InfrastructureErrorThe call could not be completed. Give support the requestId.
{
"type": "https://docs.easylife365.cloud/errors/infrastructure-error",
"title": "The request could not be completed. Support can look it up with the request id.",
"status": 500,
"code": "InfrastructureError",
"requestId": "5c0e8d3a-71b4-4f2e-a3c6-9d1f2b8e4a07"
}

Example 1: Retrieve the blocklist with curl​

curl -s "https://api.easylife365.cloud/admin/mail/v1/blocklist" \
-H "Authorization: Bearer $TOKEN"

Response:

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

Example 2: Retrieve 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" }

$blocklist = Invoke-RestMethod -Method Get -Headers $headers `
-Uri "https://api.easylife365.cloud/admin/mail/v1/blocklist"
Write-Information "Current blocklist: $($blocklist -join ', ')" -InformationAction Continue

Example 3: Retrieve 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.Read"

az login --tenant $tenantId | Out-Null

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

$headers = @{ Authorization = "Bearer $accessToken" }
$blocklist = Invoke-RestMethod -Method Get -Headers $headers `
-Uri "https://api.easylife365.cloud/admin/mail/v1/blocklist"
Write-Information "Current blocklist: $($blocklist -join ', ')" -InformationAction Continue