# IRPCNotificationRules.AddNotificationRule

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) > [Notification rules](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/index.md)

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

Badges: `Vault API / standard` `write` `session` `returns metadata structure version`

Creates a notification rule and returns its ID.

- **Service:** [Notification rules](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/index.md) `MFiles.IRPCNotificationRules`
- **gRPC method:** `/MFiles.IRPCNotificationRules/AddNotificationRule`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/add-notification-rule`
- **Request:** [`AddNotificationRuleRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/AddNotificationRule/index.md#request)
- **Response:** [`AddNotificationRuleResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCNotificationRules/AddNotificationRule/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** no
- **Returns metadata structure version:** yes (in the mfiles-metadata-version-bin trailer)
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

- A private rule (`is_common` false) requires the vault right
  `manage_private_notification_rules` and belongs to the caller. A common rule requires
  `manage_common_notification_rules`. Otherwise the call fails with "Access denied.".
- `name` must not be empty ("The parameter is incorrect."). `id` is ignored: the server assigns
  a new ID. Names need not be unique, so a retried call creates a second rule.
- `recipients` must be a plain access control list of users and groups; pseudo-users such as
  "current user" are rejected.
- See the service overview for `recurring` and `notification_days_of_week`.

<a id="request"></a>

## Request: AddNotificationRuleRequest

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page. Fields marked (recursive) refer to a type already on their path.

| Field | Type | Description |
|---|---|---|
| `utf8szrule` | [`NotificationRule`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.NotificationRule/index.md) | The rule to create. Set `name`, `subscriptions` and usually `object_filter` and `options.is_enabled`; for a common rule also `is_common` and `recipients`. `id` is ignored. |
| `utf8szrule.id` | `int32` | The ID of the rule. Assigned by the server when the rule is created. |
| `utf8szrule.name` | `string` | The name of the notification rule. |
| `utf8szrule.object_filter[]` | repeated [`SearchCondition`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SearchCondition/index.md) | The search conditions that an object must meet for the rule to apply, combined with AND. The built-in rules include a "not deleted" condition (`STATUS_TYPE_IS_DELETED` equal to false). |
| `utf8szrule.object_filter[].expression` | [`Expression`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.Expression/index.md) | The left side of the condition: what is evaluated for each object, such as a property value, a status value or any field (full-text search). |
| `utf8szrule.object_filter[].type` | [`ConditionType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.ConditionType/index.md) | The comparison operator. |
| `utf8szrule.object_filter[].value` | [`TypedValue`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValue/index.md) | The right side of the condition: the value to compare with. Its data type must suit the expression, for example a lookup for a lookup property, Boolean for `STATUS_TYPE_IS_DELETED`. |
| `utf8szrule.subscriptions[]` | repeated [`EventSubscription`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.EventSubscription/index.md) | The events that trigger a notification. A single `EVENT_TYPE_OBJECT_NOTIFICATION` subscription makes the rule filter-based: it then notifies about the objects that match `object_filter`. |
| `utf8szrule.subscriptions[].type` | [`EventType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.EventType/index.md) | The type of the event. [ switch_is( eventtype ) ] EventTypeSpecificDataUnion etsdu;  //!< Additional event type -specific data as a union. |
| `utf8szrule.options` | [`NOTIFICATIONFLAGS`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.NOTIFICATIONFLAGS/index.md) | `is_enabled` turns the rule on, `send_digest` combines the day's notifications into one message, `exclude_self_triggered` leaves out events caused by the user, and `recurring` (filter-based rules only) repeats the notification for objects that still match. |
| `utf8szrule.options.all` | `bool` | Specifies all flags set; Including any future flags. |
| `utf8szrule.options.is_enabled` | `bool` | Notifications enabled. |
| `utf8szrule.options.send_digest` | `bool` | Combine the day's notifications into a single message. |
| `utf8szrule.options.exclude_self_triggered` | `bool` | Exclude notifications of events caused by me. |
| `utf8szrule.options.recurring` | `bool` | Notifications are recurring (not only appear once per a matching object). |
| `utf8szrule.is_common` | `bool` | True for a common rule that notifies the users and groups in `recipients`; false for a private rule of its owner. |
| `utf8szrule.recipients` | [`AccessControlList`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.AccessControlList/index.md) | For a common rule, the users and groups to notify. Not used by private rules. |
| `utf8szrule.recipients.checked_out_to_user` | `int32` | Specifies the ID of the user who has extended rights because of the checkout operation performed by her. 0 if such user does not exist. |
| `utf8szrule.recipients.is_fully_authoritative` | `bool` | Specifies whether this access control list is set to ignore the secondary permissions that come from the latest checked in version. |
| `utf8szrule.recipients.custom_component` | [`AccessControlListComponent`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.AccessControlListComponent/index.md) | Accesses the custom component of this ACL. |
| `utf8szrule.recipients.restrictive_components[]` | repeated [`AccessControlListComponentMapEntry`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.AccessControlListComponentMapEntry/index.md) | Accesses the restrictive automatic components of this ACL. |
| `utf8szrule.recipients.secondary_access_control_list` | [`AccessControlList`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.AccessControlList/index.md) (recursive) | Secondary ACL used for latest version ACL. Not used for access check if null. |
| `utf8szrule.recipients.additive_components[]` | repeated [`AccessControlListComponentMapEntry`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.AccessControlListComponentMapEntry/index.md) | Accesses the additive automatic components of this ACL. |
| `utf8szrule.notification_days_of_week` | `uint32` | For filter-based rules, the days on which the rule is processed, as a bit mask: 1 Sunday, 2 Monday, 4 Tuesday, 8 Wednesday, 16 Thursday, 32 Friday, 64 Saturday. 127 means every day. |

<a id="response"></a>

## Response: AddNotificationRuleResponse

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `id` | `int32` | The ID of the new rule. |
