Chat history

To retreive the topic based all chats in a conversation 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/history?chatType=singleChat&userOne=xxxx&userTwo=xxxxxx&page=1&size=10&topicId=xxxx"
-H "accept: */*"
-H "Authorization: :AuthToken"

Request Params#

ParamDataTypeRequiredDescription
chatTypeStringYesChat type. Possible value singlechat
topicIdStringNoTopicId to fetch records associated with topicId
userOneStringYesuserOne userid of the chat
userTwoStringYesuserTwo userid of the chat
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. Topics can be created from here Create Topic.

Responses#

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

{
"status": 200,
"data": {
"chatList": [
{
"chatType": "samplechattype", // String - Possible values are singlechat, groupchat
"messageType": "samplemessagetype", // String - Message type such as text, image, file, audio, video, contact, location, notification
"messageId": "xxxxxx", // String - Unique id of this message - auto genereted
"message": "samplemessage", // String - Actual message text or notification code
"deliveryStatus": 0, // Number - Message delivery status
"fromUser": "99xxxxxx22", // String - Sender userid
"fromUserName": "sampleusername", // String - Sender nickname
"toUser": "99xxxxxx00", // String - Receiver userid
"toUserName": "sampleusername", // String - Receiver nickname
"participantName": "sampleusername", // String - Participant nickname
"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
]
},
"id": 0, //Number - unique id for this record
"messageTime": 0, // Number - sentTime as epoch timestamp
"topicId": "xxxxxx" // String - topicId
}
],
"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"
}