Create rule

Namespace: microsoft.graph


APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Create a messageRule object by specifying a set of conditions and actions.

Outlook carries out those actions if an incoming message in the user's Inbox meets the specified conditions.


One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.

Permission type Permissions (from least to most privileged)
Delegated (work or school account) MailboxSettings.ReadWrite
Delegated (personal Microsoft account) MailboxSettings.ReadWrite
Application MailboxSettings.ReadWrite

HTTP request

POST /me/mailFolders/inbox/messagerules
POST /users/{id | userPrincipalName}/mailFolders/inbox/messagerules

Request headers

Name Description
Authorization Bearer {token}. Required.

Request body

In the request body, supply the parameters that are applicable to your rule. The following are body parameters that are typically used when creating rules. You can specify any other writable messageRule properties as appropriate in the request body.

Parameter Type Description
actions messageRuleActions Actions to be taken on a message when the corresponding conditions, if any, are fulfilled. Required.
conditions messageRulePredicates Conditions that when fulfilled, will trigger the corresponding actions for that rule. Optional.
displayName String The display name of the rule. Required.
exceptions messageRulePredicates Represents exception conditions for the rule. Optional.
isEnabled Boolean Indicates whether the rule is enabled to be applied to messages. Optional.
sequence Int32 Indicates the order in which the rule is executed, among other rules. Required.


If successful, this method returns 201 Created response code and a messageRule object in the response body.



Here is an example of the request.

Content-type: application/json

    "displayName": "From partner",      
    "sequence": 2,      
    "isEnabled": true,          
    "conditions": {
        "senderContains": [
     "actions": {
        "forwardTo": [
             "emailAddress": {
                "name": "Alex Wilbur",
                "address": ""
        "stopProcessingRules": true


Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.

HTTP/1.1 201 Created
Content-type: application/json

  "displayName":"From partner",
            "name":"Alex Wilbur",