> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-flutter-sdk-mark-as-unread.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Send message

> This endpoint is used to submit a message for moderation before it is delivered to the recipient. The message is scanned against the moderation rules configured for the app.



## OpenAPI

````yaml post /moderation/messages
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/messages:
    post:
      tags:
        - Moderation
      summary: Send message
      description: >-
        This endpoint is used to submit a message for moderation before it is
        delivered to the recipient. The message is scanned against the
        moderation rules configured for the app.
      operationId: chat-api-send-message-moderation
      requestBody:
        content:
          application/json:
            schema:
              required:
                - sender
                - receiver
                - receiverType
              properties:
                muid:
                  description: The unique identifier for the message
                  type: string
                category:
                  description: Category of the message. The available category is message
                  type: string
                  enum:
                    - message
                type:
                  description: >-
                    Defines the type of the message based on the selected
                    category.

                    When `category` is `message`, the allowed values for `type`
                    are:


                    `text` — Plain text message


                    `image` — Image message


                    `audio` — Audio message


                    `video` — Video message


                    `file` — File message


                    When `category` is `custom`, any custom string can be used
                    as the `type`. This allows developers to define and handle
                    custom message types as needed in their UI implementation.
                  type: string
                  enum:
                    - text
                    - image
                    - file
                    - audio
                    - video
                sender:
                  description: UID of the sender.
                  type: string
                receiver:
                  description: >-
                    If the receiverType == “user” the UID of a user receiving
                    the message. else GUID of the group.
                  type: string
                receiverType:
                  description: The receiverType of the message. either user or group
                  type: string
                  enum:
                    - user
                    - group
                data:
                  $ref: '#/components/schemas/moderationMessageData'
                senderUserDetails:
                  description: >-
                    This property contains information about the sender user. It
                    is required only if the sender does not already exist in
                    CometChat. If provided, the sender user will be created
                    before the message is processed.
                  allOf:
                    - $ref: '#/components/schemas/userSenderDetails'
                receiverUserDetails:
                  description: >-
                    This property contains information about the receiver user
                    (in case of one-to-one messages). It is required only if the
                    receiver user does not already exist in CometChat. If
                    provided, the user will be created before the message is
                    sent.
                  allOf:
                    - $ref: '#/components/schemas/userSenderDetails'
                receiverGroupDetails:
                  description: >-
                    This property contains information about the group receiving
                    the message.

                    It is required only if the group does not already exist in
                    CometChat. If provided, the group will be created before the
                    message is sent.
                  allOf:
                    - $ref: '#/components/schemas/groupReceiverDetails'
                tags:
                  description: String array containing developer defined tags.
                  type: array
                  items:
                    type: string
                sentAt:
                  description: >-
                    10 digit unix timestamp at which the message would be sent.
                    If left blank, the current timestamp would be used.
                  type: integer
              type: object
            examples:
              Send Moderation Message:
                summary: Send Moderation Message
                value:
                  category: message
                  type: text
                  data:
                    text: Hey there! Welcome aboard.
                  sender: cometchat-test-user-1
                  receiver: cometchat-test-user-2
                  senderUserDetails:
                    uid: cometchat-test-user-1
                    name: Test User 1
                  receiverUserDetails:
                    uid: cometchat-test-user-2
                    name: Test User 2
                  receiverType: user
      responses:
        '200':
          description: Import Message(s)
          content:
            application/json:
              schema:
                type: object
              example:
                data:
                  id: '1'
                  conversationId: cometchat-uid-1_user_cometchat-uid-2
                  sender: cometchat-uid-2
                  receiverType: user
                  receiver: cometchat-uid-1
                  category: message
                  type: text
                  data:
                    text: Hi new user
                    entities:
                      sender:
                        entity:
                          uid: cometchat-uid-2
                          name: George Alan
                          avatar: >-
                            https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp
                          status: offline
                          role: default
                          lastActiveAt: 1751644824
                          createdAt: 1751644824
                          conversationId: cometchat-uid-1_user_cometchat-uid-2
                        entityType: user
                      receiver:
                        entity:
                          uid: cometchat-uid-1
                          name: Andrew Joseph
                          avatar: >-
                            https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp
                          status: offline
                          role: default
                          lastActiveAt: 1751644824
                          createdAt: 1751644824
                        entityType: user
                    moderation:
                      status: pending
                  sentAt: 1750335220
                  updatedAt: 1751644906
      security:
        - apiKey: []
components:
  schemas:
    moderationMessageData:
      description: Can contain any additional properties except for the key properties.
      properties:
        text:
          description: >-
            The meaning of the `data.text` property depends on the values of
            `category` and `type`:

            1. When `category` is `'message'` and `type` is `'text'`, it
            represents the text content of the message.

            2. When `category` is `'message'` and `type` is not `'text'`, it
            represents the caption associated with the attachment.
          type: string
        customData:
          description: when category==”custom”, this property can have any JSON object.
          type: object
        attachments:
          description: >-
            For the messages with image, video, audio or file type (i.e.
            category=="message" && type !="text"), the property contains an
            array of attachment objects.
          type: array
          items:
            required:
              - name
              - mimeType
              - extension
              - url
            properties:
              url:
                description: >-
                  Contains the URL of the attachment. The developer has to make
                  sure that the URL is accessible while calling the API. The API
                  will be downloading the attachment from its current location
                  and upload it to CometChat’s attachment storage.
                type: string
              name:
                description: Name of the attachment.
                type: string
              mimeType:
                description: Mime Type of attachment.
                type: string
              extension:
                description: The extension of the attachment.
                type: string
              size:
                description: The size of the attachment(in bytes).
                type: string
            type: object
        metadata:
          type: object
      type: object
    userSenderDetails:
      required:
        - uid
        - name
      properties:
        uid:
          description: The primary-key/ unique identifier of the sender.
          type: string
        name:
          description: Name of the sender.
          type: string
        avatar:
          description: URL to the profile picture of the user sending the message.
          type: string
        link:
          description: Profile page URL of the sender.
          type: string
        role:
          description: >-
            Role of the sender. Should be created already via the Create role
            API.
          type: string
        createdAt:
          description: A 10-digit timestamp at which the sender was created.
          type: integer
        metadata:
          description: Additional details about the sender.
          type: object
        tags:
          description: A string array containing sender tags.
          type: array
          items:
            type: string
          default: []
      type: object
    groupReceiverDetails:
      required:
        - guid
        - name
        - type
      properties:
        guid:
          description: The primary-key/ unique identifier of the group.
          type: string
        name:
          description: Name of the group.
          type: string
        icon:
          description: An URL for a group icon.
          type: string
        type:
          description: Type of the group. Can be public, password or private.
          type: string
          enum:
            - public
            - password
            - private
        password:
          description: A password required to join the the group with type password
          type: string
        owner:
          description: Owner of the group.
          type: string
        createdAt:
          description: ' A 10-digit UNIX timestamp at which the group was created.'
          type: integer
        metadata:
          description: Additional data for the group.
          type: object
        tags:
          description: A string array containing grouptags.
          type: array
          items:
            type: string
          default: []
      type: object
  securitySchemes:
    apiKey:
      type: apiKey
      description: API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
      name: apikey
      in: header

````