# Document Rules Document Rules are automated policies that govern how documents behave as they are created or updated in the platform. Each rule defines **conditions** (when to fire) and **actions** (what to do). Rules are evaluated asynchronously by the Action & Media Flows service whenever a matching document event occurs. **Condition matching:** Rules evaluate conditions against document fields. The `matchType` controls how multiple conditions combine: | Match Type | Behavior | |---|---| | `MATCH_ALL` | All conditions must be true (AND logic) | | `MATCH_ANY` | At least one condition must be true (OR logic) | | `MATCH_NONE` | No conditions may be true (NOT logic) | **Condition operators:** | Operator | Description | |---|---| | `OP_EQ` | Field equals the specified value | | `OP_NE` | Field does not equal the specified value | | `OP_MATCHES` | Field matches a regular expression | | `OP_NOT_MATCHES` | Field does not match a regular expression | | `OP_IS_EMPTY` | Field is absent or null | | `OP_IS_NOT_EMPTY` | Field is present and non-null | **Condition sources** — what the condition evaluates against: | Source | Description | |---|---| | `SOURCE_KIND` | The document kind (type) | | `SOURCE_DOC_VALUE` | The current value of a document field | | `SOURCE_PREV_DOC_VALUE` | The previous value of a field (before the triggering update) | **Available actions:** | Action | Description | |---|---| | `setProperty` | Write a metadata field value on the document | | `setLink` | Create a link edge between the document and another document | | `setPolicy` | Apply an access policy grant (`READ` or `MODIFY`) to the document | **Rule lifecycle:** - `create / update` — define or revise rule conditions and actions - `enable / disable` — activate or pause a rule without deleting it - `test` — evaluate a rule against a sample document payload before enabling in production - `delete` — permanently remove a rule ## Search content rules - [POST /api/v1/rule/list-rules](https://api.tenovos.com/openapi/content-intelligence/document-rules/tenovos.document.ruleservice.listrules.md): Lists all rules as lightweight summaries including name, enabled state, and priority. Request: (no parameters) Response: rules - List of RuleSummary objects for all rules in the organization. ## Get a content rule - [POST /api/v1/rule/retrieve-rule](https://api.tenovos.com/openapi/content-intelligence/document-rules/tenovos.document.ruleservice.retrieverule.md): Retrieves a full rule definition by ID, including its conditions, actions, and priority. Request: id - ID of the rule to retrieve. Response: rule - The full Rule object including id, name, enabled state, conditions, actions, priority, timestamps, and any validation error. ## Create a content rule - [POST /api/v1/rule/create-rule](https://api.tenovos.com/openapi/content-intelligence/document-rules/tenovos.document.ruleservice.createrule.md): Creates a new rule defining conditions and actions to apply when documents change. Request: rule - A CreateRule definition specifying name, conditions (DocumentRule.Conditions), actions (DocumentRule.Actions), and priority. Response: rule - The full Rule object that was created. ## Update a content rule - [POST /api/v1/rule/update-rule](https://api.tenovos.com/openapi/content-intelligence/document-rules/tenovos.document.ruleservice.updaterule.md): Updates an existing rule's conditions, actions, or priority. Request: rule - An UpdateRule payload identifying the rule by ID and providing the replacement conditions, actions, and/or priority. Response: rule - The full Rule object reflecting the applied updates. ## Delete a content rule - [POST /api/v1/rule/delete-rule](https://api.tenovos.com/openapi/content-intelligence/document-rules/tenovos.document.ruleservice.deleterule.md): Permanently deletes a rule by ID. Request: id - ID of the rule to permanently delete. Response: (empty) ## Enable a content rule - [POST /api/v1/rule/enable-rule](https://api.tenovos.com/openapi/content-intelligence/document-rules/tenovos.document.ruleservice.enablerule.md): Activates a disabled rule so it is evaluated against document changes. Request: id - ID of the rule to enable. Response: rule - The updated Rule object with enabled set to true. ## Disable a content rule - [POST /api/v1/rule/disable-rule](https://api.tenovos.com/openapi/content-intelligence/document-rules/tenovos.document.ruleservice.disablerule.md): Deactivates an active rule, preventing it from being evaluated, without deleting it. Request: id - ID of the rule to disable. Response: rule - The updated Rule object with enabled set to false. ## Test a content rule - [POST /api/v1/rule/test-rule](https://api.tenovos.com/openapi/content-intelligence/document-rules/tenovos.document.ruleservice.testrule.md): Tests a rule against a sample document to verify whether its conditions match and previews the resulting actions. Request: ruleId - ID of the rule to test. documentKind - Kind name of the sample document being tested against. sampleDocument - Optional current state of the document as a JSON value. previousDocument - Optional previous state of the document for change-detection conditions. Response: matched - Whether the rule's conditions matched the sample document. actions - List of ActionType values that would be triggered if the rule matched. error - Optional error message if the rule could not be evaluated.