> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-restapi-chat-api-eng-37141.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Update a CometChat moderation rule by ruleId with REST API to change content checks, actions, or rule conditions.

# Update Rule



## OpenAPI

````yaml put /moderation/rules/{ruleId}
openapi: 3.0.0
info:
  title: Chat APIs
  description: Manage messages, users, groups for a particular app using our Chat API.
  version: '3.0'
servers:
  - url: https://{appId}.api-{region}.cometchat.io/v3
    variables:
      appId:
        default: appId
        description: (Required) App ID
      region:
        enum:
          - us
          - eu
          - in
        default: us
        description: Select Region
security: []
tags:
  - name: API Keys
    description: The API keys are used to authorise the APIs
  - name: Roles
    description: The roles are used to give user access rights
  - name: Users
    description: The REST collection for users.
  - name: Auth Tokens
    description: The auth tokens are used to login end users using client SDKs.
  - name: Blocked Users
    description: The REST collections for blocked users.
  - name: Friends
    description: List,add and remove friends by passing UID in path variables
  - name: Groups
    description: The REST collections for groups.
  - name: Banned Users
    description: Ban and Unban user by passing other UID in path variables.
  - name: Group Members
    description: The REST collections for group members.
  - name: Messages
    description: The REST collections for messages.
  - name: Conversations
    description: The REST collections for conversations.
  - name: Restrict Features
    description: Allows Restricting Features
  - name: Metrics
    description: Allows accessing Data Metrics
  - name: Triggers
    description: Allows adding triggers to a webhook.
  - name: Webhooks
    description: Allows accessing Webhooks.
  - name: Notifications
    description: Allows configuring Notifications core.
  - name: Moderation
    description: The REST collections for Moderations.
paths:
  /moderation/rules/{ruleId}:
    put:
      tags:
        - Moderation
      summary: Update Rule
      description: Update an existing moderation rule with new actions or conditions.
      operationId: chat-api-update-rule
      parameters:
        - $ref: '#/components/parameters/ruleId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ModerationRequestBody'
      responses:
        '200':
          description: Update Rule
          content:
            application/json:
              schema:
                properties:
                  data:
                    properties:
                      '':
                        $ref: '#/components/schemas/webhookSchema'
                    type: object
                type: object
              example:
                data:
                  id: moderation-test
                  name: Video Moderation
                  description: AI-powered video moderation to detect unsafe content.
                  enabled: true
                  conditions:
                    - id: 1
                      isKeywordsReferencePresent: false
                      isMediaPresent: true
                      entity: message
                      operand: image
                      category: word
                      operator: contains
                      value:
                        - violence_greaterThan_30
                      message:
                        - >-
                          Image contains violence with confidence greater than
                          30
                  action:
                    - blockMessage
                  active: true
                  createdAt: 1720003247
                  updatedAt: 1720003247
                  revisionId: 253179cf5f665257_moderation-test_1
      security:
        - apiKey: []
components:
  parameters:
    ruleId:
      name: ruleId
      in: path
      description: Rule ID
      required: true
      schema:
        type: string
  schemas:
    ModerationRequestBody:
      properties:
        id:
          description: Unique identifier for the moderation rule.
          type: string
          example: moderation-test
        name:
          description: Descriptive name for the moderation rule.
          type: string
          example: Video Moderation
        enabled:
          description: Indicates whether the rule is active.
          type: boolean
          example: true
        description:
          description: Detailed explanation of the rule's purpose.
          type: string
          example: AI-powered video moderation to detect unsafe content.
        action:
          description: Actions to be taken when a violation is detected.
          type: array
          items:
            type: string
            example: blockMessage
        filters:
          description: List of filters to apply
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/UserFilter'
              - $ref: '#/components/schemas/GroupFilter'
        conditions:
          description: List of conditions that must be met for the rule to trigger.
          type: array
          items:
            $ref: '#/components/schemas/Condition'
      type: object
    webhookSchema:
      description: Response data
      properties:
        id:
          type: string
        name:
          type: string
        webhookURL:
          type: string
        useBasicAuth:
          type: boolean
        username:
          type: string
        password:
          type: string
        enabled:
          type: boolean
        createdAt:
          type: integer
        updatedAt:
          type: integer
      type: object
    UserFilter:
      required:
        - entity
        - operand
        - operator
        - value
        - type
      properties:
        type:
          description: Type of the filter, specifying sender or receiver
          type: string
          enum:
            - sender
            - receiver
          example: sender
        entity:
          description: Type of entity for user filter
          type: string
          enum:
            - user
        operand:
          description: Field to apply the filter on for 'user'
          type: string
          enum:
            - uid
            - name
            - role
            - tags
            - createdAt
        operator:
          description: Operator to use for filtering
          type: string
          enum:
            - equals
            - not equals
            - in
            - not in
            - startsWith
          example: equals
        value:
          description: Value for the filter
          type: string
          example: admin
      type: object
    GroupFilter:
      required:
        - entity
        - operand
        - operator
        - value
        - type
      properties:
        entity:
          description: Type of entity for group filter
          type: string
          enum:
            - group
        operand:
          description: Field to apply the filter on for 'group'
          type: string
          enum:
            - guid
            - name
            - type
            - tags
            - createdAt
        operator:
          description: Operator to use for filtering
          type: string
          enum:
            - equals
            - notEquals
            - in
            - notIn
            - startsWith
            - endsWith
            - lessThan
            - greaterThan
          example: equals
        value:
          description: Value for the filter
          type: string
          example: exampleValue
        type:
          description: Type of the filter, specifying sender or receiver
          type: string
          enum:
            - sender
            - receiver
          example: sender
      type: object
    Condition:
      properties:
        id:
          description: Unique identifier of a condition
          type: integer
          example: 1
        entity:
          description: Entity type in which moderation will be performed.
          type: string
          example: message
        operand:
          description: >-
            Type of message content to moderate (e.g., text, image, video,
            custom).
          type: string
          enum:
            - text
            - image
            - video
            - custom
          example: image
        operator:
          description: >-
            Operation to be performed for condition evaluation (e.g., contains,
            equals).
          type: string
          enum:
            - contains
            - equals
          example: contains
        category:
          description: Type of entries for evaluation, either 'word' or 'pattern'.
          type: string
          enum:
            - word
            - pattern
          example: word
        isKeywordReferencePresent:
          description: Indicates if the value contains a reference to a keyword list.
          type: boolean
          example: false
        isMediaPresent:
          description: Indicates if the incoming message contains media content.
          type: boolean
          example: true
        value:
          description: >-
            Actual value for the condition, or reference ID if
            isKeywordReferencePresent is true, or a formula if isMediaPresent is
            true.
          type: string
          example: violence_greaterThan_30
      type: object
  securitySchemes:
    apiKey:
      type: apiKey
      description: API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
      name: apikey
      in: header

````