curl --request POST \
--url https://{appid}.api-{region}.cometchat.io/v3/data_import/messages \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"messages": {
"3118": {
"muid": "3118",
"sender": "s12",
"receiverType": "user",
"receiver": "r123",
"type": "text",
"category": "message",
"data": {
"text": "Hi there",
"attachments": [
{
"name": "hi.png",
"extension": "png",
"size": "350.2",
"mimeType": "image/png",
"url": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png"
}
],
"metadata": {
"key": "value"
},
"custodata": {
"key": "value"
}
},
"sentAt": "1674104348",
"deliveredAt": "1674224684",
"readAt": "1674224684",
"senderUserDetails": {
"uid": "s12",
"name": "user1",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"createdAt": "1674228536",
"metadata": {
"key": "value"
}
},
"receiverUserDetails": {
"uid": "r123",
"name": "superhero",
"type": "public",
"description": "Hello group",
"icon": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"owner": "superhero1",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"createdAt": "1674228536",
"metadata": {
"key": "value"
}
},
"tags": [
"tag1"
],
"mentionedUserDetails": {
"example-uid-new": {
"uid": "example-uid-new",
"name": "example-uid"
}
}
}
}
}
'{
"data": {
"3117": {
"success": true,
"data": {
"id": "1029",
"muid": "3117",
"conversationId": "r123_user_s12",
"sender": "s12",
"receiverType": "user",
"receiver": "r123",
"category": "message",
"type": "text",
"data": {
"text": "Hi there,",
"attachments": [
{
"name": "hi.png",
"extension": "png",
"size": "350.2",
"mimeType": "image/png",
"url": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png"
}
],
"metad2ata": {
"key": "value"
},
"custodata": {
"key": "value"
},
"entities": {
"sender": {
"entity": {
"uid": "s12",
"name": "user1",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"metadata": {
"key": "value"
},
"status": "offline",
"role": "default",
"createdAt": 1674228536,
"updatedAt": 1674232131
},
"entityType": "user"
},
"receiver": {
"entity": {
"uid": "r123",
"name": "superhero",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"metadata": {
"key": "value"
},
"status": "offline",
"role": "default",
"createdAt": 1674228536,
"updatedAt": 1674232131,
"conversationId": "r123_user_s12"
},
"entityType": "user"
}
}
},
"sentAt": 1674104348,
"deliveredAt": 1674224684,
"readAt": 1674224684,
"updatedAt": 1674104348,
"tags": [
"tag1"
]
}
}
}
}The CometChat message import API allows customers to import their messages’ data into the CometChat systems.
curl --request POST \
--url https://{appid}.api-{region}.cometchat.io/v3/data_import/messages \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"messages": {
"3118": {
"muid": "3118",
"sender": "s12",
"receiverType": "user",
"receiver": "r123",
"type": "text",
"category": "message",
"data": {
"text": "Hi there",
"attachments": [
{
"name": "hi.png",
"extension": "png",
"size": "350.2",
"mimeType": "image/png",
"url": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png"
}
],
"metadata": {
"key": "value"
},
"custodata": {
"key": "value"
}
},
"sentAt": "1674104348",
"deliveredAt": "1674224684",
"readAt": "1674224684",
"senderUserDetails": {
"uid": "s12",
"name": "user1",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"createdAt": "1674228536",
"metadata": {
"key": "value"
}
},
"receiverUserDetails": {
"uid": "r123",
"name": "superhero",
"type": "public",
"description": "Hello group",
"icon": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"owner": "superhero1",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"createdAt": "1674228536",
"metadata": {
"key": "value"
}
},
"tags": [
"tag1"
],
"mentionedUserDetails": {
"example-uid-new": {
"uid": "example-uid-new",
"name": "example-uid"
}
}
}
}
}
'{
"data": {
"3117": {
"success": true,
"data": {
"id": "1029",
"muid": "3117",
"conversationId": "r123_user_s12",
"sender": "s12",
"receiverType": "user",
"receiver": "r123",
"category": "message",
"type": "text",
"data": {
"text": "Hi there,",
"attachments": [
{
"name": "hi.png",
"extension": "png",
"size": "350.2",
"mimeType": "image/png",
"url": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png"
}
],
"metad2ata": {
"key": "value"
},
"custodata": {
"key": "value"
},
"entities": {
"sender": {
"entity": {
"uid": "s12",
"name": "user1",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"metadata": {
"key": "value"
},
"status": "offline",
"role": "default",
"createdAt": 1674228536,
"updatedAt": 1674232131
},
"entityType": "user"
},
"receiver": {
"entity": {
"uid": "r123",
"name": "superhero",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"metadata": {
"key": "value"
},
"status": "offline",
"role": "default",
"createdAt": 1674228536,
"updatedAt": 1674232131,
"conversationId": "r123_user_s12"
},
"entityType": "user"
}
}
},
"sentAt": 1674104348,
"deliveredAt": 1674224684,
"readAt": 1674224684,
"updatedAt": 1674104348,
"tags": [
"tag1"
]
}
}
}
}API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
Wrapper for the messages.
Show child attributes
Wraps a single message object. The <muid> will be a primary key/unique Identifier of the message.
Show child attributes
The value should be the same as value of the placeholder <muid> which wraps the message object.
UID of the sender.
The receiverType of the message. either user or group
user, group If the receiverType == “user” the UID of a user receiving the message. else GUID of the group.
10-digit UNIX timestamp for the time at which the message was sent.
Category of the message. The available categories are message and custom.
message, custom If category==”message” then the allowed values for the type are: text: for a plain text message. image: for an image message audio: for an audio message video: for a video message file: for any file if category==”custom” the customized type can be used. The developer can send the type as any random string and can use it in the implementation at the UI
text, image, file, audio, video Can contain any additional properties except for the key properties.
Show child attributes
The property has a fixed meaning for: 1. category==”message” && type ==”text” ⇒ it stores the text message 2. category==”message” && type !=”text” ⇒ it stores a caption for the attachment
when category==”custom”, this property can have any JSON object.
For the messages with image, video, audio or file type (i.e. category=="message" && type !="text"), the property contains an array of attachment objects.
Show child attributes
Publicly accessible URL of the attachment.
Name of the attachment.
Mime Type of attachment.
The extension of the attachment.
The size of the attachment(in bytes).
String array containing developer defined tags.
A 10-digit UNIX timestamp at which the message was delivered to the receiver.
A 10-digit UNIX timestamp at which the message was read by the receiver.
If all the users are imported before importing the messages. The JSON object contains the user details of the sender.
Show child attributes
The primary-key/ unique identifier of the sender.
Name of the sender.
URL to the profile picture of the user sending the message.
Profile page URL of the sender.
Role of the sender. Should be created already via the Create role API.
A 10-digit timestamp at which the sender was created.
A 10-digit UNIX timestamp at which the sender was most recently online.
Additional details about the sender.
A string array containing sender tags.
A 10-digit UNIX timestamp at which the sender was deactivated/soft-deleted/blocked to use the chat services.
If all the users are imported before importing the messages or else required if receiverType==”user”. The JSON object contains the user details of the receiver.
Show child attributes
The primary-key/ unique identifier of the user receiving the message.
Name of the receiver.
URL to the profile picture of the receiver.
Profile page URL of the receiver.
Role of the receiver. Should be created already via the Create role API.
A 10-digit timestamp at which the receiver was created.
A 10-digit UNIX timestamp at which the receiver was most recently online.
Additional details about the receiver.
A string array containing receiver tags.
A 10-digit UNIX timestamp at which the receiver was deactivated/soft-deleted/blocked to use the chat services.
The JSON object contains the group details of the receiver.
Show child attributes
The primary-key/ unique identifier of the group.
Name of the group.
Type of the group. Can be public, password or private.
public, password, private An URL for a group icon.
A password required to join the the group with type password
Owner of the group.
A 10-digit UNIX timestamp at which the group was created.
Additional data for the group.
A string array containing grouptags.
The JSON object contains the user details of the owner.
Show child attributes
The primary-key/ unique identifier of the owner.
Name of the owner.
URL to the profile picture of the owner.
Profile page URL of the owner.
Role of the owner. Should be created already via the Create role API.
A 10-digit timestamp at which the owner was created.
A 10-digit UNIX timestamp at which the owner was most recently online.
Additional details about the owner.
A string array containing owner tags.
A 10-digit UNIX timestamp at which the owner was deactivated/soft-deleted/blocked to use the chat services.
Optional field that provides user details when data.text includes a mention, formatted using CometChat’s mention template (<@uid:UID>).
Show child attributes
A map where each key is a user’s unique identifier (UID) and the value is that user’s details. The <uid> will be replaced by the mentioned user’s primary key.
Show child attributes
Show child attributes
The primary-key/ unique identifier of the owner. The value should be the same as value of the placeholder
Name of the owner.
URL to the profile picture of the owner.
Profile page URL of the owner.
Role of the owner. Should be created already via the Create role API.
A 10-digit timestamp at which the owner was created.
A 10-digit UNIX timestamp at which the owner was most recently online.
Additional details about the owner.
A string array containing owner tags.
A 10-digit UNIX timestamp at which the owner was deactivated/soft-deleted/blocked to use the chat services.
{
"3118": {
"muid": "3118",
"sender": "s12",
"receiverType": "user",
"receiver": "r123",
"type": "text",
"category": "message",
"data": {
"text": "Hi there",
"attachments": [
{
"name": "hi.png",
"extension": "png",
"size": "350.2",
"mimeType": "image/png",
"url": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png"
}
],
"metadata": { "key": "value" },
"custodata": { "key": "value" }
},
"sentAt": "1674104348",
"deliveredAt": "1674224684",
"readAt": "1674224684",
"senderUserDetails": {
"uid": "s12",
"name": "user1",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"createdAt": "1674228536",
"metadata": { "key": "value" }
},
"receiverUserDetails": {
"uid": "r123",
"name": "superhero",
"type": "public",
"description": "Hello group",
"icon": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"owner": "superhero1",
"avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png",
"createdAt": "1674228536",
"metadata": { "key": "value" }
},
"tags": ["tag1"],
"mentionedUserDetails": {
"example-uid-new": {
"uid": "example-uid-new",
"name": "example-uid"
}
}
}
}Import Message(s)
Show child attributes
Response data
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?