Skip to main content
Version: 1.27.19

Create Distribution List

The EasyLife 365 Mail API creates distribution lists and mail-enabled security groups. The template you send decides which of the two is created. The template, naming rules and blocked names apply as in EasyLife 365 Admin and EasyLife 365 Mail. An approval applies when the template has one and approvals are turned on for your tenant. The API does not check who a template is meant for: an application can use any active template of the right type.

Permissions​

Permission typePermissionRate limit
Delegated (work or school account)App.ReadWrite.All (a signed-in user)Create, update, delete
ApplicationMail.DistributionList.Provisioning.ReadWrite.All or Mail.Provisioning.ReadWrite.All (either one)Create, update, delete
  • This route is part of the App API. Grant the role on the EasyLife 365 Mail application in your tenant, not on EasyLife 365 Admin.
  • Get the token with the scope https://api.easylife365.cloud/mail/.default; see Get a token.
  • Only the versioned route (/mail/v1/groups/lists) accepts an application role. The route without v1 is for signed-in users and answers 403 Forbidden to an application token.
  • An Admin API role, such as Mail.Manage.ReadWrite.All, does not work here.

What an application sends​

An application has no signed-in user, so nothing is taken from "who is calling":

  • At least one owner is required. Send at least one user object ID in owners. Without an owner, the call answers 400 with the code Mail.OwnerRequired. An owner must be an enabled member user of your tenant, and an owner is not added as a member.
  • A requestor is optional, unless the template has an approval and approvals are turned on for your tenant. In that case, send requestorId, the object ID of the person the request is for. Without it, the call answers 400 with the code Mail.RequestorRequired and nothing is created. The requestor is shown in the approval and is recorded on the request. Without a requestor, the {user:...} tokens of the naming conventions of the template resolve to nothing, so a name or description built from them can come out blank or odd.
  • A template with an approval still goes to approval when approvals are turned on for your tenant. Nothing is created until it is approved. The response then has "isApproval": true.
  • When audit logging is turned on, the creation is audited once, by the engine. The entry (CREATE-GROUP) is written when the list exists. In rare cases a list exists without an entry. Its actor is the EasyLife engine, not your application. The description names the requestor and "requested by application" with your application (client) ID, so search the description. A request that fails or is never approved leaves no entry.
warning

Treat every holder of a create role as a privileged identity, and give the role only to trusted automation. The API does not verify the requestor an application names, and the approver is worked out from that person, so the application decides who is asked to approve. The approver sees the requestor you name, not your application. The application also decides the owners and the members of the new list or group. For a mail-enabled security group, membership grants access, so the application decides who gets that access.

HTTP request​

POST https://api.easylife365.cloud/mail/v1/groups/lists
Content-Type: application/json
Authorization: Bearer <token>

HTTP request headers​

HeaderValue
AuthorizationBearer token. Required
Content-Typeapplication/json

Request Body​

PropertyTypeDescription
namestringUnique name of the distribution list. Required
templateIdstring (UUID)Template identifier for predefined settings. Use a distribution list template or a mail-enabled security group template. Required
domainstringDomain for the distribution list. Required
displayNamestringDisplay name for the distribution list. Required, unless the display name naming convention of the template builds it. Without one, the call answers 400 with the code Mail.ValueRequired.
descriptionstringDescription of the distribution list. Optional
metadataobjectCustom key-value pairs for additional metadata. Optional
ownersarray<string (UUID)>List of owner UUIDs for the distribution list. An owner is not added as a member automatically. Required for an application, at least one
membersarray<string (UUID)>List of member UUIDs in the distribution list. Optional
requestorIdstring (UUID)Object ID of the person the request is for. Required for an application when the template has an approval and approvals are turned on for your tenant. Ignored for a signed-in user. Optional
allowOutsideSendersbooleanIf true, allows external users to send emails to the list. Only used when the template lets the requester choose. Optional
hideFromGALbooleanIf true, hides the distribution list from the Global Address List (GAL). Optional
termsAcceptedbooleanSend true when the template has terms of use. Without it the call answers 400 with the code Mail.TermsNotAccepted. Optional
reasonstringReason for creating the distribution list. Optional

Expanded object type definitions​

metadata (Object)​

Stores additional information about the distribution list in a key-value format.

PropertyTypeDescription & Example
Custom KeystringAny key-value pair providing extra details. Example: { "department": "HR", "createdBy": "Admin" }
Example Usage​
{
"metadata": {
"el-text-388": "Used for internal communications",
"department": "Finance",
"createdBy": "Admin"
}
}

Response​

200 OK. The list is created in the background, so the response returns the ID of the request. isApproval is true when the template needs an approval first.

{
"requestId": "72d2f4b8-76fe-4140-9460-3c7ef9091cb5",
"isApproval": false
}

Error responses​

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

StatusCodeWhen
400InvalidPayloadThe body is missing or cannot be read, or requestorId is not a GUID.
400Mail.ValueTooLongdisplayName is longer than 256 characters, description longer than 1024 or name longer than 64. The field and maxLength members of the answer name the value and its limit.
400Mail.ValueRequireddisplayName is empty, and the display name naming convention of the template does not build one.
400Mail.OwnerRequiredAn application sent no owner.
400Mail.OwnerNotAllowedAn owner is not an enabled member user, for example a guest or an ID that is not a user. The list was not created.
400Mail.RequestorRequiredThe template has an approval and an application sent no requestorId.
400Mail.DomainRequireddomain is missing.
400Mail.TemplateNotActiveThe template is switched off.
400Mail.TemplateNotApplicableThe template is not for a distribution list or a mail-enabled security group.
400Mail.InvalidNameThe name is on the blocklist or is not valid.
400Mail.TermsNotAcceptedThe template has terms of use and termsAccepted is not true.
401noneThe token is missing or not valid.
403Mail.FeatureNotEnabledThe type of the template, for example mail-enabled security groups, is not switched on for your tenant.
403noneThe token has no role that this route accepts, or the route is not the versioned route.
404Mail.TemplateNotFoundThe template does not exist, or templateId is missing.
404Mail.RequestorNotFoundrequestorId names no user.
429RateLimitedToo many calls.
{
"type": "https://docs.easylife365.cloud/errors/mail/requestor-required",
"title": "A requestor is required for a request that needs approval.",
"status": 400,
"detail": "Send requestorId.",
"code": "Mail.RequestorRequired",
"requestId": "9a2f6c14-3b85-4d07-8e1a-6f0b7c5d2e93"
}

Example: Creating a distribution list as an application with curl​

curl -s -X POST "https://api.easylife365.cloud/mail/v1/groups/lists" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "marketing-team",
"displayName": "Marketing Team",
"description": "Distribution list for the marketing team.",
"templateId": "2fd0dba8-d2fe-4b51-866b-622d7fa3c22b",
"owners": [ "49cf935a-284f-4c84-8df7-a5b11f1be527" ],
"members": [ "11111111-2222-3333-4444-555555555555", "49cf935a-284f-4c84-8df7-a5b11f1be527" ],
"allowOutsideSenders": false,
"domain": "contoso.com",
"hideFromGAL": true
}'

The owner is also in members, because an owner is not a member unless you add them.

Example: Creating a distribution list as an application with PowerShell​

First get a token with the scope https://api.easylife365.cloud/mail/.default.

$headers = @{ Authorization = "Bearer $token" }
$body = @{
name = "marketing-team"
displayName = "Marketing Team"
templateId = "2fd0dba8-d2fe-4b51-866b-622d7fa3c22b"
domain = "contoso.com"
owners = @("49cf935a-284f-4c84-8df7-a5b11f1be527")
members = @("11111111-2222-3333-4444-555555555555")
requestorId = "a9b7d6f3-c2e5-4a1b-b9e7-f1d5a3e9c6d4"
} | ConvertTo-Json

Invoke-RestMethod -Method Post -Headers $headers -ContentType "application/json" -Body $body `
-Uri "https://api.easylife365.cloud/mail/v1/groups/lists"

Example: Creating a mail-enabled security group​

Use the ID of a mail-enabled security group template. The request is the same.

{
"name": "finance-access",
"displayName": "Finance Access",
"templateId": "d5e8b3a1-6c24-4f79-9b0e-3a7c1d9f2b60",
"domain": "contoso.com",
"owners": [ "49cf935a-284f-4c84-8df7-a5b11f1be527" ],
"members": [ "11111111-2222-3333-4444-555555555555" ]
}