> For the complete documentation index, see [llms.txt](https://docs.aisuru.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aisuru.com/api/backend/governance-rule.md).

# Governance Rule

## Creates a new GovernanceRule.

> Only administrators can create GovernanceRules.

````json
{"openapi":"3.0.1","info":{"title":"Memori.ai Web API V2","version":"v2"},"paths":{"/api/v2/GovernanceRule/{strToken}":{"post":{"tags":["GovernanceRule"],"summary":"Creates a new GovernanceRule.","description":"Only administrators can create GovernanceRules.","operationId":"GovernanceRule-CreateGovernanceRule","parameters":[{"name":"strToken","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GovernanceRuleSpecs"}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateGovernanceRuleResponse"}}}}}}}},"components":{"schemas":{"GovernanceRuleSpecs":{"required":["categoryID","rationale","scopeType","status","text","title"],"type":"object","properties":{"ruleID":{"type":"string","description":"GovernanceRule ID. Unique and assigned by the system.\r\nReturned during Get operations. Ignored in other cases.","nullable":true},"tenantID":{"type":"string","description":"Tenant ID this GovernanceRule belongs to.\r\nReturned during Get operations. Ignored in other cases.","nullable":true},"title":{"maxLength":255,"minLength":1,"type":"string","description":"Short title of the rule. Required."},"text":{"minLength":1,"type":"string","description":"Full text of the rule, injected in the agent's system prompt. Required."},"categoryID":{"minLength":1,"type":"string","description":"ID of a default or tenant-defined GovernanceRuleCategory. Required."},"categoryName":{"type":"string","description":"Name of the selected category. Returned during Get operations and ignored in writes.","nullable":true},"rationale":{"minLength":1,"type":"string","description":"Rationale explaining why this rule exists. Required."},"normRef":{"type":"string","description":"Optional reference to a norm/regulation this rule derives from.","nullable":true},"status":{"minLength":1,"type":"string","description":"One of: Active, Draft. Required."},"scopeType":{"minLength":1,"type":"string","description":"One of: All, MemoriCategories, List, AllExcept. Required."},"scopeMemoriCategories":{"type":"array","items":{"type":"string"},"description":"Categories to match against Memori.Categories. Used only when ScopeType is MemoriCategories.","nullable":true},"scopeMemoriIDs":{"type":"array","items":{"type":"string"},"description":"IDs (backend Memori IDs) this rule applies to. Used only when ScopeType is List.","nullable":true},"exclusions":{"type":"array","items":{"$ref":"#/components/schemas/GovernanceRuleExclusionSpecs"},"description":"Memori excluded from this rule, each with a mandatory reason. Used only when ScopeType is AllExcept.","nullable":true},"createdByUserID":{"type":"string","description":"User ID who created this rule. Returned during Get operations. Ignored in other cases.","nullable":true},"updatedByUserID":{"type":"string","description":"User ID who last updated this rule. Returned during Get operations. Ignored in other cases.","nullable":true},"creationTimestamp":{"type":"string","description":"Timestamp of creation. Returned during Get operations.\r\nIgnored in other cases.","format":"date-time","nullable":true},"lastChangeTimestamp":{"type":"string","description":"Timestamp of latest change. Returned during Get operations.\r\nIgnored in other cases.","format":"date-time","nullable":true}},"additionalProperties":false,"description":"Specifications of a GovernanceRule object."},"GovernanceRuleExclusionSpecs":{"required":["memoriID","reason"],"type":"object","properties":{"memoriID":{"minLength":1,"type":"string","description":"ID (backend Memori ID) of the excluded Memori. Required."},"reason":{"minLength":20,"type":"string","description":"Mandatory reason for the exclusion. Must be at least 20 characters long."},"createdByUserID":{"type":"string","description":"User ID who created this exclusion. Returned during Get operations. Ignored in other cases.","nullable":true},"createdAt":{"type":"string","description":"Timestamp of creation. Returned during Get operations. Ignored in other cases.","format":"date-time","nullable":true}},"additionalProperties":false,"description":"Specifications of a single Memori exclusion, used when GovernanceRule.ScopeType is AllExcept."},"CreateGovernanceRuleResponse":{"type":"object","properties":{"governanceRule":{"$ref":"#/components/schemas/GovernanceRuleSpecs"},"requestID":{"type":"integer","description":"Progressive number of the request (since the Server started).\r\nUse this number, together with the RequestDateTime property,\r\nto report an anomalous reponse.","format":"int64"},"requestDateTime":{"type":"string","description":"Timestamp of the request.\r\nUse this timestamp, together with the RequestID property,\r\nto report an anomalous reponse.","format":"date-time"},"resultCode":{"type":"integer","description":"Result code. A code of ```0``` means no errors.\r\nWhen the request fails, its value is indicative of the actual\r\nerror.","format":"int32"},"resultMessage":{"type":"string","description":"Result message. A message of ```Ok``` means no errors.","nullable":true}},"additionalProperties":false,"description":"Response of a Create GovernanceRule request."}}}}
````

## Gets a GovernanceRule by ID.

> Only administrators can get GovernanceRules.

````json
{"openapi":"3.0.1","info":{"title":"Memori.ai Web API V2","version":"v2"},"paths":{"/api/v2/GovernanceRule/{strToken}/{strRuleID}":{"get":{"tags":["GovernanceRule"],"summary":"Gets a GovernanceRule by ID.","description":"Only administrators can get GovernanceRules.","operationId":"GovernanceRule-GetGovernanceRule","parameters":[{"name":"strToken","in":"path","required":true,"schema":{"type":"string"}},{"name":"strRuleID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetGovernanceRuleResponse"}}}}}}}},"components":{"schemas":{"GetGovernanceRuleResponse":{"type":"object","properties":{"governanceRule":{"$ref":"#/components/schemas/GovernanceRuleSpecs"},"requestID":{"type":"integer","description":"Progressive number of the request (since the Server started).\r\nUse this number, together with the RequestDateTime property,\r\nto report an anomalous reponse.","format":"int64"},"requestDateTime":{"type":"string","description":"Timestamp of the request.\r\nUse this timestamp, together with the RequestID property,\r\nto report an anomalous reponse.","format":"date-time"},"resultCode":{"type":"integer","description":"Result code. A code of ```0``` means no errors.\r\nWhen the request fails, its value is indicative of the actual\r\nerror.","format":"int32"},"resultMessage":{"type":"string","description":"Result message. A message of ```Ok``` means no errors.","nullable":true}},"additionalProperties":false,"description":"Response of a Get GovernanceRule request."},"GovernanceRuleSpecs":{"required":["categoryID","rationale","scopeType","status","text","title"],"type":"object","properties":{"ruleID":{"type":"string","description":"GovernanceRule ID. Unique and assigned by the system.\r\nReturned during Get operations. Ignored in other cases.","nullable":true},"tenantID":{"type":"string","description":"Tenant ID this GovernanceRule belongs to.\r\nReturned during Get operations. Ignored in other cases.","nullable":true},"title":{"maxLength":255,"minLength":1,"type":"string","description":"Short title of the rule. Required."},"text":{"minLength":1,"type":"string","description":"Full text of the rule, injected in the agent's system prompt. Required."},"categoryID":{"minLength":1,"type":"string","description":"ID of a default or tenant-defined GovernanceRuleCategory. Required."},"categoryName":{"type":"string","description":"Name of the selected category. Returned during Get operations and ignored in writes.","nullable":true},"rationale":{"minLength":1,"type":"string","description":"Rationale explaining why this rule exists. Required."},"normRef":{"type":"string","description":"Optional reference to a norm/regulation this rule derives from.","nullable":true},"status":{"minLength":1,"type":"string","description":"One of: Active, Draft. Required."},"scopeType":{"minLength":1,"type":"string","description":"One of: All, MemoriCategories, List, AllExcept. Required."},"scopeMemoriCategories":{"type":"array","items":{"type":"string"},"description":"Categories to match against Memori.Categories. Used only when ScopeType is MemoriCategories.","nullable":true},"scopeMemoriIDs":{"type":"array","items":{"type":"string"},"description":"IDs (backend Memori IDs) this rule applies to. Used only when ScopeType is List.","nullable":true},"exclusions":{"type":"array","items":{"$ref":"#/components/schemas/GovernanceRuleExclusionSpecs"},"description":"Memori excluded from this rule, each with a mandatory reason. Used only when ScopeType is AllExcept.","nullable":true},"createdByUserID":{"type":"string","description":"User ID who created this rule. Returned during Get operations. Ignored in other cases.","nullable":true},"updatedByUserID":{"type":"string","description":"User ID who last updated this rule. Returned during Get operations. Ignored in other cases.","nullable":true},"creationTimestamp":{"type":"string","description":"Timestamp of creation. Returned during Get operations.\r\nIgnored in other cases.","format":"date-time","nullable":true},"lastChangeTimestamp":{"type":"string","description":"Timestamp of latest change. Returned during Get operations.\r\nIgnored in other cases.","format":"date-time","nullable":true}},"additionalProperties":false,"description":"Specifications of a GovernanceRule object."},"GovernanceRuleExclusionSpecs":{"required":["memoriID","reason"],"type":"object","properties":{"memoriID":{"minLength":1,"type":"string","description":"ID (backend Memori ID) of the excluded Memori. Required."},"reason":{"minLength":20,"type":"string","description":"Mandatory reason for the exclusion. Must be at least 20 characters long."},"createdByUserID":{"type":"string","description":"User ID who created this exclusion. Returned during Get operations. Ignored in other cases.","nullable":true},"createdAt":{"type":"string","description":"Timestamp of creation. Returned during Get operations. Ignored in other cases.","format":"date-time","nullable":true}},"additionalProperties":false,"description":"Specifications of a single Memori exclusion, used when GovernanceRule.ScopeType is AllExcept."}}}}
````

## Deletes a GovernanceRule.

> Only administrators can delete GovernanceRules.

````json
{"openapi":"3.0.1","info":{"title":"Memori.ai Web API V2","version":"v2"},"paths":{"/api/v2/GovernanceRule/{strToken}/{strRuleID}":{"delete":{"tags":["GovernanceRule"],"summary":"Deletes a GovernanceRule.","description":"Only administrators can delete GovernanceRules.","operationId":"GovernanceRule-DeleteGovernanceRule","parameters":[{"name":"strToken","in":"path","required":true,"schema":{"type":"string"}},{"name":"strRuleID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}}},"components":{"schemas":{"Response":{"type":"object","properties":{"requestID":{"type":"integer","description":"Progressive number of the request (since the Server started).\r\nUse this number, together with the RequestDateTime property,\r\nto report an anomalous reponse.","format":"int64"},"requestDateTime":{"type":"string","description":"Timestamp of the request.\r\nUse this timestamp, together with the RequestID property,\r\nto report an anomalous reponse.","format":"date-time"},"resultCode":{"type":"integer","description":"Result code. A code of ```0``` means no errors.\r\nWhen the request fails, its value is indicative of the actual\r\nerror.","format":"int32"},"resultMessage":{"type":"string","description":"Result message. A message of ```Ok``` means no errors.","nullable":true}},"additionalProperties":false,"description":"Base response."}}}}
````

## Updates an existing GovernanceRule.

> Only administrators can update GovernanceRules. Fields left null are not changed;> \
> ScopeType, if provided, replaces the whole scope (ScopeMemoriCategories/ScopeMemoriIDs/Exclusions).

````json
{"openapi":"3.0.1","info":{"title":"Memori.ai Web API V2","version":"v2"},"paths":{"/api/v2/GovernanceRule/{strToken}/{strRuleID}":{"patch":{"tags":["GovernanceRule"],"summary":"Updates an existing GovernanceRule.","description":"Only administrators can update GovernanceRules. Fields left null are not changed;\r\nScopeType, if provided, replaces the whole scope (ScopeMemoriCategories/ScopeMemoriIDs/Exclusions).","operationId":"GovernanceRule-UpdateGovernanceRule","parameters":[{"name":"strToken","in":"path","required":true,"schema":{"type":"string"}},{"name":"strRuleID","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GovernanceRuleSpecs"}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateGovernanceRuleResponse"}}}}}}}},"components":{"schemas":{"GovernanceRuleSpecs":{"required":["categoryID","rationale","scopeType","status","text","title"],"type":"object","properties":{"ruleID":{"type":"string","description":"GovernanceRule ID. Unique and assigned by the system.\r\nReturned during Get operations. Ignored in other cases.","nullable":true},"tenantID":{"type":"string","description":"Tenant ID this GovernanceRule belongs to.\r\nReturned during Get operations. Ignored in other cases.","nullable":true},"title":{"maxLength":255,"minLength":1,"type":"string","description":"Short title of the rule. Required."},"text":{"minLength":1,"type":"string","description":"Full text of the rule, injected in the agent's system prompt. Required."},"categoryID":{"minLength":1,"type":"string","description":"ID of a default or tenant-defined GovernanceRuleCategory. Required."},"categoryName":{"type":"string","description":"Name of the selected category. Returned during Get operations and ignored in writes.","nullable":true},"rationale":{"minLength":1,"type":"string","description":"Rationale explaining why this rule exists. Required."},"normRef":{"type":"string","description":"Optional reference to a norm/regulation this rule derives from.","nullable":true},"status":{"minLength":1,"type":"string","description":"One of: Active, Draft. Required."},"scopeType":{"minLength":1,"type":"string","description":"One of: All, MemoriCategories, List, AllExcept. Required."},"scopeMemoriCategories":{"type":"array","items":{"type":"string"},"description":"Categories to match against Memori.Categories. Used only when ScopeType is MemoriCategories.","nullable":true},"scopeMemoriIDs":{"type":"array","items":{"type":"string"},"description":"IDs (backend Memori IDs) this rule applies to. Used only when ScopeType is List.","nullable":true},"exclusions":{"type":"array","items":{"$ref":"#/components/schemas/GovernanceRuleExclusionSpecs"},"description":"Memori excluded from this rule, each with a mandatory reason. Used only when ScopeType is AllExcept.","nullable":true},"createdByUserID":{"type":"string","description":"User ID who created this rule. Returned during Get operations. Ignored in other cases.","nullable":true},"updatedByUserID":{"type":"string","description":"User ID who last updated this rule. Returned during Get operations. Ignored in other cases.","nullable":true},"creationTimestamp":{"type":"string","description":"Timestamp of creation. Returned during Get operations.\r\nIgnored in other cases.","format":"date-time","nullable":true},"lastChangeTimestamp":{"type":"string","description":"Timestamp of latest change. Returned during Get operations.\r\nIgnored in other cases.","format":"date-time","nullable":true}},"additionalProperties":false,"description":"Specifications of a GovernanceRule object."},"GovernanceRuleExclusionSpecs":{"required":["memoriID","reason"],"type":"object","properties":{"memoriID":{"minLength":1,"type":"string","description":"ID (backend Memori ID) of the excluded Memori. Required."},"reason":{"minLength":20,"type":"string","description":"Mandatory reason for the exclusion. Must be at least 20 characters long."},"createdByUserID":{"type":"string","description":"User ID who created this exclusion. Returned during Get operations. Ignored in other cases.","nullable":true},"createdAt":{"type":"string","description":"Timestamp of creation. Returned during Get operations. Ignored in other cases.","format":"date-time","nullable":true}},"additionalProperties":false,"description":"Specifications of a single Memori exclusion, used when GovernanceRule.ScopeType is AllExcept."},"UpdateGovernanceRuleResponse":{"type":"object","properties":{"governanceRule":{"$ref":"#/components/schemas/GovernanceRuleSpecs"},"requestID":{"type":"integer","description":"Progressive number of the request (since the Server started).\r\nUse this number, together with the RequestDateTime property,\r\nto report an anomalous reponse.","format":"int64"},"requestDateTime":{"type":"string","description":"Timestamp of the request.\r\nUse this timestamp, together with the RequestID property,\r\nto report an anomalous reponse.","format":"date-time"},"resultCode":{"type":"integer","description":"Result code. A code of ```0``` means no errors.\r\nWhen the request fails, its value is indicative of the actual\r\nerror.","format":"int32"},"resultMessage":{"type":"string","description":"Result message. A message of ```Ok``` means no errors.","nullable":true}},"additionalProperties":false,"description":"Response of an Update GovernanceRule request."}}}}
````

## Lists all GovernanceRules for the current tenant.

> Only administrators can list GovernanceRules.

````json
{"openapi":"3.0.1","info":{"title":"Memori.ai Web API V2","version":"v2"},"paths":{"/api/v2/GovernanceRules/{strToken}":{"get":{"tags":["GovernanceRule"],"summary":"Lists all GovernanceRules for the current tenant.","description":"Only administrators can list GovernanceRules.","operationId":"GovernanceRule-ListGovernanceRules","parameters":[{"name":"strToken","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListGovernanceRulesResponse"}}}}}}}},"components":{"schemas":{"ListGovernanceRulesResponse":{"type":"object","properties":{"governanceRules":{"type":"array","items":{"$ref":"#/components/schemas/GovernanceRuleSpecs"},"description":"List of GovernanceRule objects.","nullable":true},"requestID":{"type":"integer","description":"Progressive number of the request (since the Server started).\r\nUse this number, together with the RequestDateTime property,\r\nto report an anomalous reponse.","format":"int64"},"requestDateTime":{"type":"string","description":"Timestamp of the request.\r\nUse this timestamp, together with the RequestID property,\r\nto report an anomalous reponse.","format":"date-time"},"resultCode":{"type":"integer","description":"Result code. A code of ```0``` means no errors.\r\nWhen the request fails, its value is indicative of the actual\r\nerror.","format":"int32"},"resultMessage":{"type":"string","description":"Result message. A message of ```Ok``` means no errors.","nullable":true}},"additionalProperties":false,"description":"Response of a List GovernanceRules request."},"GovernanceRuleSpecs":{"required":["categoryID","rationale","scopeType","status","text","title"],"type":"object","properties":{"ruleID":{"type":"string","description":"GovernanceRule ID. Unique and assigned by the system.\r\nReturned during Get operations. Ignored in other cases.","nullable":true},"tenantID":{"type":"string","description":"Tenant ID this GovernanceRule belongs to.\r\nReturned during Get operations. Ignored in other cases.","nullable":true},"title":{"maxLength":255,"minLength":1,"type":"string","description":"Short title of the rule. Required."},"text":{"minLength":1,"type":"string","description":"Full text of the rule, injected in the agent's system prompt. Required."},"categoryID":{"minLength":1,"type":"string","description":"ID of a default or tenant-defined GovernanceRuleCategory. Required."},"categoryName":{"type":"string","description":"Name of the selected category. Returned during Get operations and ignored in writes.","nullable":true},"rationale":{"minLength":1,"type":"string","description":"Rationale explaining why this rule exists. Required."},"normRef":{"type":"string","description":"Optional reference to a norm/regulation this rule derives from.","nullable":true},"status":{"minLength":1,"type":"string","description":"One of: Active, Draft. Required."},"scopeType":{"minLength":1,"type":"string","description":"One of: All, MemoriCategories, List, AllExcept. Required."},"scopeMemoriCategories":{"type":"array","items":{"type":"string"},"description":"Categories to match against Memori.Categories. Used only when ScopeType is MemoriCategories.","nullable":true},"scopeMemoriIDs":{"type":"array","items":{"type":"string"},"description":"IDs (backend Memori IDs) this rule applies to. Used only when ScopeType is List.","nullable":true},"exclusions":{"type":"array","items":{"$ref":"#/components/schemas/GovernanceRuleExclusionSpecs"},"description":"Memori excluded from this rule, each with a mandatory reason. Used only when ScopeType is AllExcept.","nullable":true},"createdByUserID":{"type":"string","description":"User ID who created this rule. Returned during Get operations. Ignored in other cases.","nullable":true},"updatedByUserID":{"type":"string","description":"User ID who last updated this rule. Returned during Get operations. Ignored in other cases.","nullable":true},"creationTimestamp":{"type":"string","description":"Timestamp of creation. Returned during Get operations.\r\nIgnored in other cases.","format":"date-time","nullable":true},"lastChangeTimestamp":{"type":"string","description":"Timestamp of latest change. Returned during Get operations.\r\nIgnored in other cases.","format":"date-time","nullable":true}},"additionalProperties":false,"description":"Specifications of a GovernanceRule object."},"GovernanceRuleExclusionSpecs":{"required":["memoriID","reason"],"type":"object","properties":{"memoriID":{"minLength":1,"type":"string","description":"ID (backend Memori ID) of the excluded Memori. Required."},"reason":{"minLength":20,"type":"string","description":"Mandatory reason for the exclusion. Must be at least 20 characters long."},"createdByUserID":{"type":"string","description":"User ID who created this exclusion. Returned during Get operations. Ignored in other cases.","nullable":true},"createdAt":{"type":"string","description":"Timestamp of creation. Returned during Get operations. Ignored in other cases.","format":"date-time","nullable":true}},"additionalProperties":false,"description":"Specifications of a single Memori exclusion, used when GovernanceRule.ScopeType is AllExcept."}}}}
````

Gets the GovernanceRules applicable to a given Memori (Title and Category only).\
Intended for a future read-only section in the Memori editor.
-------------------------------------------------------------

> Only administrators can view applicable GovernanceRules. Never returns Text or Rationale.

````json
{"openapi":"3.0.1","info":{"title":"Memori.ai Web API V2","version":"v2"},"paths":{"/api/v2/GovernanceRule/{strToken}/ApplicableFor/{strMemoriID}":{"get":{"tags":["GovernanceRule"],"summary":"Gets the GovernanceRules applicable to a given Memori (Title and Category only).\r\nIntended for a future read-only section in the Memori editor.","description":"Only administrators can view applicable GovernanceRules. Never returns Text or Rationale.","operationId":"GovernanceRule-GetApplicableGovernanceRules","parameters":[{"name":"strToken","in":"path","required":true,"schema":{"type":"string"}},{"name":"strMemoriID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetApplicableGovernanceRulesResponse"}}}}}}}},"components":{"schemas":{"GetApplicableGovernanceRulesResponse":{"type":"object","properties":{"applicableRules":{"type":"array","items":{"$ref":"#/components/schemas/ApplicableGovernanceRuleSpecs"},"description":"GovernanceRules applicable to the requested agent (Title and Category only).","nullable":true},"requestID":{"type":"integer","description":"Progressive number of the request (since the Server started).\r\nUse this number, together with the RequestDateTime property,\r\nto report an anomalous reponse.","format":"int64"},"requestDateTime":{"type":"string","description":"Timestamp of the request.\r\nUse this timestamp, together with the RequestID property,\r\nto report an anomalous reponse.","format":"date-time"},"resultCode":{"type":"integer","description":"Result code. A code of ```0``` means no errors.\r\nWhen the request fails, its value is indicative of the actual\r\nerror.","format":"int32"},"resultMessage":{"type":"string","description":"Result message. A message of ```Ok``` means no errors.","nullable":true}},"additionalProperties":false,"description":"Response of a Get Applicable GovernanceRules request (admin-facing, read-only)."},"ApplicableGovernanceRuleSpecs":{"type":"object","properties":{"title":{"type":"string","nullable":true},"categoryID":{"type":"string","nullable":true},"categoryName":{"type":"string","nullable":true}},"additionalProperties":false,"description":"Read-only, admin-facing view of a GovernanceRule applicable to a given agent.\r\nIntentionally omits Text and Rationale, which are never exposed outside of the\r\nGovernanceRule management APIs."}}}}
````
