# Notification rules (IRPCNotificationRules)

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/

Manages notification rules: which events on which objects send the user a notification.

- **gRPC service:** `MFiles.IRPCNotificationRules`
- **Book and level:** [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md), standard
- **Methods:** 4
- **Proto file:** [`mfiles/IRPCNotificationRules.proto`](https://developer.m-files.com/APIs/gRPC-API/downloads/proto/mfiles/IRPCNotificationRules.proto)

<a id="overview"></a>

## Overview

A notification rule ([NotificationRule](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.NotificationRule/index.md)) combines a filter
(`object_filter`, search conditions), the events to watch (`subscriptions`, such as
`EVENT_TYPE_OBJECT_CREATED` or `EVENT_TYPE_OBJECT_CHANGED`) and delivery options (`options`).
Notifications are sent by e-mail, and only when notifications are enabled on the server and in
the vault and the user has not turned them off (see
[GetNotificationConfiguration](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCEvents/GetNotificationConfiguration/index.md)).

There are two kinds of rules:

| Kind | `is_common` | Who manages it | Who it notifies |
| --- | --- | --- | --- |
| Private | false | users with the vault right `manage_private_notification_rules` | the owner |
| Common | true | users with the vault right `manage_common_notification_rules` | the users and groups in `recipients` |

Typical use:

1. [GetNotificationRules](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/GetNotificationRules/index.md) to list the
   rules that apply to the caller.
2. [AddNotificationRule](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/AddNotificationRule/index.md),
   [ModifyNotificationRule](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/ModifyNotificationRule/index.md) and
   [RemoveNotificationRule](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/RemoveNotificationRule/index.md) to change
   them. Rules are identified by `id`.

To follow a single object, use
[FollowObject](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/FollowObject/index.md) instead of building the rule
yourself. Rights are listed in [VaultAccess](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.VaultAccess/index.md); filters use the search
conditions described in
[Search](https://developer.m-files.com/APIs/gRPC-API/concepts/search/index.md).

**Filter-based rules.** A rule whose only subscription is `EVENT_TYPE_OBJECT_NOTIFICATION`
notifies about the objects that match its filter, for example as a reminder, instead of about
events. Only such rules use `options.recurring` and `notification_days_of_week`. The server keeps
these two fields only if the session was opened with
`ClientData.capabilities.recurring_notifications` set; otherwise it saves `recurring` as false and
`notification_days_of_week` as every day (127).

<a id="methods"></a>

## Methods

| Method | Summary | Facts |
|---|---|---|
| [AddNotificationRule](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/AddNotificationRule/index.md) | Creates a notification rule and returns its ID. | `write` `session` `returns metadata structure version` |
| [GetNotificationRules](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/GetNotificationRules/index.md) | Gets the caller's private notification rules and the common rules that apply to the caller. | `read` `session` `idempotent` `returns metadata structure version` |
| [ModifyNotificationRule](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/ModifyNotificationRule/index.md) | Replaces a notification rule, identified by its `id`, with the given definition. | `write` `session` `idempotent` `returns metadata structure version` |
| [RemoveNotificationRule](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/RemoveNotificationRule/index.md) | Deletes a notification rule. | `write` `session` `returns metadata structure version` |
