> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-013b37f0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Rule

> Update an existing moderation rule with new actions or conditions.



## OpenAPI

````yaml put /apps/{appId}/moderation/rules/{ruleId}
openapi: 3.0.0
info:
  title: Management APIs (Multi-Tenancy)
  description: Create and manage apps on-the-fly using our app management APIs
  version: '1.0'
servers:
  - url: https://apimgmt.cometchat.io
security: []
tags:
  - name: App
    description: The Rest collection for app.
  - name: Extensions
    description: The REST collections for extensions.
  - name: Extensions
    description: The REST collections for Chat widgets.
  - name: Extensions
    description: The REST collections for Giphy extension.
  - name: Extensions
    description: The REST collections for XSS Filter extension.
  - name: Extensions
    description: The REST collections for Image Moderation extension.
  - name: Extensions
    description: The REST collections for Report user extension.
  - name: Extensions
    description: The REST collections for Report message extension.
  - name: Extensions
    description: The REST collections for Sentiment analysis extension.
  - name: Extensions
    description: The REST collections for Voice transcription extension.
  - name: Extensions
    description: The REST collections for Stipop extension.
  - name: Extensions
    description: The REST collections for TinyURL extension.
  - name: Extensions
    description: The REST collections for Intercom extension.
  - name: Extensions
    description: The REST collections for Bitly extension.
  - name: Extensions
    description: The REST collections for Rich media preview extension.
  - name: Extensions
    description: The REST collections for Virus Malware Scanner extension.
  - name: Extensions
    description: The REST collections for Video Broadcasting extension.
  - name: Extensions
    description: The REST collections for Tenor gifs extension.
  - name: Extensions
    description: The REST collections for End-to-end encryption extension.
  - name: Extensions
    description: The REST collections for In-flight message moderation extension.
  - name: Extensions
    description: The REST collections for Stickers extension.
  - name: Extensions
    description: The REST collections for Data masking extension.
  - name: Extensions
    description: The REST collections for Email replies extension.
  - name: Extensions
    description: The REST collections for SMS Notification extension.
  - name: Extensions
    description: The REST collections for Push notification extension.
  - name: Extensions
    description: The REST collections for Chatwoot extension.
  - name: Extensions
    description: The REST collections for Message shortcuts extension.
  - name: Extensions
    description: The REST collections for Email Notification extension.
  - name: Team Management
    description: The REST collections for team management.
  - name: Settings
    description: The REST collections for Settings.
  - name: Extensions
    description: The REST collections for Profanity-filter extension.
  - name: Webhooks
    description: The REST collections for Webhooks.
  - name: Moderation
    description: The REST collections for Moderations.
paths:
  /apps/{appId}/moderation/rules/{ruleId}:
    put:
      tags:
        - Moderation
      summary: Update Rule
      description: Update an existing moderation rule with new actions or conditions.
      operationId: update-rule
      parameters:
        - $ref: '#/components/parameters/key'
        - $ref: '#/components/parameters/secret'
        - $ref: '#/components/parameters/appId'
        - $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
components:
  parameters:
    key:
      name: key
      in: header
      description: Authorization Key
      required: true
      schema:
        type: string
    secret:
      name: secret
      in: header
      description: Authorization Secret
      required: true
      schema:
        type: string
    appId:
      name: appId
      in: path
      description: AppID in which the extension has to be enabled/disabled
      required: true
      schema:
        type: string
    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:
      properties:
        id:
          type: string
        name:
          type: string
        webhookURL:
          type: string
        enabled:
          type: boolean
      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

````