Microsoft: Create new navigation property to message Rules for users — users Mail Folder mail Folders Create Message Rules
Microsoft usersMailFolder.mailFoldersCreateMessageRules: arguments, response, policy and SDK examples.
← Users mail folder operations · Get started
Operation microsoft.users_mailfolders_createmessagerules
Provider route: POST /users/{user-id}/mailFolders/{mailFolder-id}/messageRules. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/microsoft with npm, or alter-sdk-microsoft with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { MicrosoftIntegration } from "@alter-ai/microsoft";
async function execute(input: Parameters<MicrosoftIntegration["usersMailFolder"]["mailFoldersCreateMessageRules"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new MicrosoftIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.usersMailFolder.mailFoldersCreateMessageRules(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_microsoft import MicrosoftIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = MicrosoftIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.users_mail_folder.mail_folders_create_message_rules(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.user-id | string | Required within parent | |
path.mailFolder-id | string | Required within parent | |
body | Model | Required within parent | Expand Create rule — request body — body |
Referenced models: Create rule — request body — body
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Get rule — response body |
Referenced models: Get rule — response body
Schemas
Section titled “Schemas”8 more schemas are linked from the tables above, on the schema pages.
Get rule — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | |
$ (allOf 1) | Model | All variants apply | Expand Get rule — response body — @odata type, id |
$ (allOf 2) | object | All variants apply | |
$ (allOf 2).@odata.type | string | Optional | |
$ (allOf 2).actions | JSON | Optional | Actions to be taken on a message when the corresponding conditions are fulfilled. |
$ (allOf 2).actions (anyOf 1) | Model | Alternative | Expand Get rule — response body — @odata type, actions, conditions, display Name, exceptions, has Error, is Enabled, is Read Only, sequence actions @odata type, assign Categories, copy To Folder, delete, forward As Attachment To, forward To, mark As Read, mark Importance, move To Folder, permanent Delete, redirect To, stop Processing Rules |
$ (allOf 2).actions (anyOf 2) | JSON | Alternative | |
$ (allOf 2).actions (anyOf 2) (anyOf 1) | object | Alternative | |
$ (allOf 2).actions (anyOf 2) (anyOf 2) | null | Alternative | |
$ (allOf 2).conditions | JSON | Optional | Conditions that when fulfilled trigger the corresponding actions for that rule. |
$ (allOf 2).conditions (anyOf 1) | Model | Alternative | Expand Get rule — response body — @odata type, actions, conditions, display Name, exceptions, has Error, is Enabled, is Read Only, sequence conditions @odata type, body Contains, body Or Subject Contains, categories, from Addresses, has Attachments, header Contains, importance, is Approval Request, is Automatic Forward, is Automatic Reply, is Encrypted, is Meeting Request, is Meeting Response, is Non Delivery Report, is Permission Controlled, is Read Receipt, is Signed, is Voicemail, message Action Flag, not Sent To Me, recipient Contains, sender Contains, sensitivity, sent Cc Me, sent Only To Me, sent To Addresses, sent To Me, sent To Or Cc Me, subject Contains, within Size Range |
$ (allOf 2).conditions (anyOf 2) | JSON | Alternative | |
$ (allOf 2).conditions (anyOf 2) (anyOf 1) | object | Alternative | |
$ (allOf 2).conditions (anyOf 2) (anyOf 2) | null | Alternative | |
$ (allOf 2).displayName | JSON | Optional | |
$ (allOf 2).displayName (anyOf 1) | string | Alternative | The display name of the rule. |
$ (allOf 2).displayName (anyOf 2) | null | Alternative | |
$ (allOf 2).exceptions | JSON | Optional | Exception conditions for the rule. |
$ (allOf 2).exceptions (anyOf 1) | Model | Alternative | Expand Get rule — response body — @odata type, actions, conditions, display Name, exceptions, has Error, is Enabled, is Read Only, sequence conditions @odata type, body Contains, body Or Subject Contains, categories, from Addresses, has Attachments, header Contains, importance, is Approval Request, is Automatic Forward, is Automatic Reply, is Encrypted, is Meeting Request, is Meeting Response, is Non Delivery Report, is Permission Controlled, is Read Receipt, is Signed, is Voicemail, message Action Flag, not Sent To Me, recipient Contains, sender Contains, sensitivity, sent Cc Me, sent Only To Me, sent To Addresses, sent To Me, sent To Or Cc Me, subject Contains, within Size Range |
$ (allOf 2).exceptions (anyOf 2) | JSON | Alternative | |
$ (allOf 2).exceptions (anyOf 2) (anyOf 1) | object | Alternative | |
$ (allOf 2).exceptions (anyOf 2) (anyOf 2) | null | Alternative | |
$ (allOf 2).hasError | JSON | Optional | |
$ (allOf 2).hasError (anyOf 1) | boolean | Alternative | Indicates whether the rule is in an error condition. Read-only. |
$ (allOf 2).hasError (anyOf 2) | null | Alternative | |
$ (allOf 2).isEnabled | JSON | Optional | |
$ (allOf 2).isEnabled (anyOf 1) | boolean | Alternative | Indicates whether the rule is enabled to be applied to messages. |
$ (allOf 2).isEnabled (anyOf 2) | null | Alternative | |
$ (allOf 2).isReadOnly | JSON | Optional | |
$ (allOf 2).isReadOnly (anyOf 1) | boolean | Alternative | Indicates if the rule is read-only and cannot be modified or deleted by the rules REST API. |
$ (allOf 2).isReadOnly (anyOf 2) | null | Alternative | |
$ (allOf 2).sequence | JSON | Optional | |
$ (allOf 2).sequence (anyOf 1) | JSON | Alternative | |
$ (allOf 2).sequence (anyOf 1) (anyOf 1) | number | Alternative | Indicates the order in which the rule is executed, among other rules. Format: int32 Maximum: 2147483647 Minimum: -2147483648 |
$ (allOf 2).sequence (anyOf 1) (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
$ (allOf 2).sequence (anyOf 2) | null | Alternative |
Referenced models: Get rule — response body — @odata type, id, Get rule — response body — @odata type, actions, conditions, display Name, exceptions, has Error, is Enabled, is Read Only, sequence actions @odata type, assign Categories, copy To Folder, delete, forward As Attachment To, forward To, mark As Read, mark Importance, move To Folder, permanent Delete, redirect To, stop Processing Rules, Get rule — response body — @odata type, actions, conditions, display Name, exceptions, has Error, is Enabled, is Read Only, sequence conditions @odata type, body Contains, body Or Subject Contains, categories, from Addresses, has Attachments, header Contains, importance, is Approval Request, is Automatic Forward, is Automatic Reply, is Encrypted, is Meeting Request, is Meeting Response, is Non Delivery Report, is Permission Controlled, is Read Receipt, is Signed, is Voicemail, message Action Flag, not Sent To Me, recipient Contains, sender Contains, sensitivity, sent Cc Me, sent Only To Me, sent To Addresses, sent To Me, sent To Or Cc Me, subject Contains, within Size Range
Get rule — response body — @odata type, actions, conditions, display Name, exceptions, has Error, is Enabled, is Read Only, sequence actions @odata type, assign Categories, copy To Folder, delete, forward As Attachment To, forward To, mark As Read, mark Importance, move To Folder, permanent Delete, redirect To, stop Processing Rules
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
@odata.type | string | Optional | |
assignCategories | array | Optional | A list of categories to be assigned to a message. |
assignCategories[] | JSON | Each item | |
assignCategories[] (anyOf 1) | string | Alternative | |
assignCategories[] (anyOf 2) | null | Alternative | |
copyToFolder | JSON | Optional | |
copyToFolder (anyOf 1) | string | Alternative | The ID of a folder that a message is to be copied to. |
copyToFolder (anyOf 2) | null | Alternative | |
delete | JSON | Optional | |
delete (anyOf 1) | boolean | Alternative | Indicates whether a message should be moved to the Deleted Items folder. |
delete (anyOf 2) | null | Alternative | |
forwardAsAttachmentTo | array | Optional | The email addresses of the recipients to which a message should be forwarded as an attachment. |
forwardAsAttachmentTo[] | Model | Each item | Expand Invoke action forward — me Event events Forward — request body — body To Recipients item |
forwardTo | array | Optional | The email addresses of the recipients to which a message should be forwarded. |
forwardTo[] | Model | Each item | Expand Invoke action forward — me Event events Forward — request body — body To Recipients item |
markAsRead | JSON | Optional | |
markAsRead (anyOf 1) | boolean | Alternative | Indicates whether a message should be marked as read. |
markAsRead (anyOf 2) | null | Alternative | |
markImportance | JSON | Optional | Sets the importance of the message, which can be: low, normal, high. |
markImportance (anyOf 1) | string | Alternative | Known values: low, normal, high |
markImportance (anyOf 2) | JSON | Alternative | |
markImportance (anyOf 2) (anyOf 1) | object | Alternative | |
markImportance (anyOf 2) (anyOf 2) | null | Alternative | |
moveToFolder | JSON | Optional | |
moveToFolder (anyOf 1) | string | Alternative | The ID of the folder that a message will be moved to. |
moveToFolder (anyOf 2) | null | Alternative | |
permanentDelete | JSON | Optional | |
permanentDelete (anyOf 1) | boolean | Alternative | Indicates whether a message should be permanently deleted and not saved to the Deleted Items folder. |
permanentDelete (anyOf 2) | null | Alternative | |
redirectTo | array | Optional | The email addresses to which a message should be redirected. |
redirectTo[] | Model | Each item | Expand Invoke action forward — me Event events Forward — request body — body To Recipients item |
stopProcessingRules | JSON | Optional | |
stopProcessingRules (anyOf 1) | boolean | Alternative | Indicates whether subsequent rules should be evaluated. |
stopProcessingRules (anyOf 2) | null | Alternative |
Referenced models: Invoke action forward — me Event events Forward — request body — body To Recipients item
Invoke action forward — me Event events Forward — request body — body To Recipients item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | discriminator: {"mapping": {"#microsoft.graph.attendee": "#/components/schemas/microsoft.graph.attendee", "#microsoft.graph.attendeeBase": "#/components/schemas/microsoft.graph.attendeeBase"}, "propertyName": "@odata.type"} |
@odata.type | string | Optional | |
emailAddress | JSON | Optional | The recipient's email address. |
emailAddress (anyOf 1) | Model | Alternative | Expand Get calendar Permission — response body — @odata type, allowed Roles, email Address, is Inside Organization, is Removable, role email Address @odata type, address, name |
emailAddress (anyOf 2) | JSON | Alternative | |
emailAddress (anyOf 2) (anyOf 1) | object | Alternative | |
emailAddress (anyOf 2) (anyOf 2) | null | Alternative |
Referenced models: Get calendar Permission — response body — @odata type, allowed Roles, email Address, is Inside Organization, is Removable, role email Address @odata type, address, name
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: microsoft.users_mailfolders_createmessagerules. Catalog operation: users_mailfolders_createmessagerules. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.