Chat Conversation

To retreive all chat conversations between two users or a group you can use the below API.

info

{api-base-url} can be obtained from the MirrorFly console.

HTTP request#

curl -X GET "https://{api-base-url}/api/v1/chat/admin/chatlogs/conversation?groupId=xxxx&userOne=xxxxx&userTwo=xxxxx&page=1&size=10"
-H "accept: */*"
-H "Authorization: AuthToken"

Request Params#

ParamDataTypeRequiredDescription
userOneStringYesuserOne userid of the chat, Optional if group chat
userTwoStringYesuserTwo userid of the chat, Optional if group chat
groupIdStringYesgroupId of the chat , Optional if single chat
filterTypeStringNoAccepts ALL_MSG or MSG_ONLY to include all messages or skip notification messages. Default is ALL_MSG
pageNumberNoPage number to get the particular page data default value is 1
sizeNumberNoNumber of chats per page default value is 10

Note : If it is a media message, use the fileUrl from the media object to download the media by using this Download Media API.

Responses#

If successful, this action returns chats list in a conversation, in the response body.

{
"status": 200,
"data": {
"chatList": [
{
"fromUser": "xxxxx", // String - Sender username
"fromUserName": "sample username", // String - Sender nickname
"toUser": "xxxxx", // String - Receiver userId
"toUserName": "sample username", // String - Receiver nickname
"chatType": "sample chatType", // String - Possible values are singlechat, groupchat
"messageId": "xxxxxx", // String - Unique id of this message - auto generated
"message": "sample message", // String - Actual message text or notification code
"messageType": "sample messageType", // String - Message type such as text, image, file, audio, video, contact, location, notification
"media": {
"caption": "", // String - caption for uploaded video
"fileKey": "", // String - key to encrypt/decrypt for uploaded file
"fileName": "samplefilename", // String - name of the uploaded file
"fileUrl": "xxxxxx" // String - token of the uploaded file to cloud
},
"location": {
"latitude": "", // String - location latitude
"longitude": "", // String - location longitude
"mid": "", // String - mid
"locationResolvedKey": "" // String - locationResolvedKey
},
"contact": {
"contactResolvedKey": "", // String - contactResolvedKey
"mid": "", // String - mid
"name": "samplename", // String - contact name
"phoneNumber": [
"99xxxxxx11" // String - contact number
]
},
"mentionedUsersIds": {
"xxxxx": "sample username" // Map - mentioned users map key (userId) and value (username), applicable to group chat only
},
"messageTime": 0 // Number - sentTime as epoch timestamp
}
],
"totalPages": 1, // Number - Total pages based on the size
"totalRecords": 1 // Number - Total chats for the logged-in user
},
"message": "Data retrieved successfully"
}

Error#

In the case of an error, an error object like below is returned.

When the token passed in Headers is expired

{
"status": 401,
"message": "Token Expired"
}

In the case of a Bad Request, an error message is returned

{
"status": 400,
"message": "Error Message"
}