Skip to main content
POST
/
moderation
/
messages
Send message
curl --request POST \
  --url https://{appid}.api-{region}.cometchat.io/v3/moderation/messages \
  --header 'Content-Type: application/json' \
  --header 'apikey: <api-key>' \
  --data '{
  "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"
}'
{
  "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
  }
}

Authorizations

apikey
string
header
required

API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).

Body

application/json
sender
string
required

UID of the sender.

receiver
string
required

If the receiverType == “user” the UID of a user receiving the message. else GUID of the group.

receiverType
enum<string>
required

The receiverType of the message. either user or group

Available options:
user,
group
muid
string

The unique identifier for the message

category
enum<string>

Category of the message. The available category is message

Available options:
message
type
enum<string>

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.

Available options:
text,
image,
file,
audio,
video
data
object

Can contain any additional properties except for the key properties.

senderUserDetails
object

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.

receiverUserDetails
object

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.

receiverGroupDetails
object

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.

tags
string[]

String array containing developer defined tags.

sentAt
integer

10 digit unix timestamp at which the message would be sent. If left blank, the current timestamp would be used.

Response

200 - application/json

Import Message(s)

The response is of type object.

I