Skip to main content

Get Chat Messages | DeadSimpleChat

Overview

The Get Chat Room Messages API retrieves messages from a specified chat room. Authentication is required to ensure data security and privacy.

HTTP Request

GET
    https://api.deadsimplechat.com/consumer/api/v1/chatRoom/{{CHAT_ROOM_ID}}/messages

URL Parameters

ParameterDescription
{{CHAT_ROOM_ID}}The unique identifier for the chat room from which messages are being fetched.
info

The auth query parameter is your private key. You can find it in your Dashboard under Developer -> Private Key.

Query Parameters

ParameterRequiredDescription
authYesPrivate Key, Can be Obtained from Developer -> Private Key
onlyAttachmentsNoIf true, only returns chat messages with files
limitNoThe maximum number of messages to return. Default is 50.
skipNoThe number of messages to skip (for pagination). Default is 0.

Headers

  • Content-Type: application/json

Response Format

The API responds with a JSON array, each object representing a message with the following structure:

{
"limit": 18,
"skip": 0,
"totalRecords": 1,
"count": 1,
"messages": [
{
"_id": "string",
"likes": "array",
"actionButtons": "array",
"created": "string",
"chatRoom": "string",
"message": "string",
"user": {
"_id": "string",
"uniqueUserIdentifier": "string",
"username": "string",
"parentCustomerAccount": "string",
"isModerator": "boolean"
},
"customer": "string",
"file": {
"_id": "string",
"url": "string",
"fileName": "string",
"size": "number",
"contentType": "string",
"fileType": "string",
"imageHeight": "number",
"imageWidth": "number"
},
"__v": "number"
}
// ... additional messages
]
}

Response Fields

  • _id: Unique identifier for the message.
  • likes: An array of objects representing likes on the message, each containing user details and the type of reaction.
  • actionButtons: An array of action buttons related to the message (if any).
  • created: Timestamp of message creation.
  • chatRoom: Chat room identifier to which the message belongs.
  • message: The text content of the message.
  • user: An object containing information about the user who sent the message.
    • uniqueUserIdentifier: A unique user ID within the system.
    • username: User's display name.
    • parentCustomerAccount: Identifier for the parent customer account.
    • isModerator: Indicates if the user has moderator privileges.
  • customer: Identifier for the customer associated with the message.
  • file: (Optional) An object containing file data if the message includes a file.
    • url: Direct URL to the file.
    • fileName: Original name of the file.
    • size: File size in bytes.
    • contentType: MIME type of the file.
    • fileType: General type of file (e.g., image, video).
    • imageHeight: Height of the image (if applicable).
    • imageWidth: Width of the image (if applicable).
  • __v: Version number of the document in the database.

Errors

  • 401 Unauthorized: Returned if the authentication token (auth) is missing or invalid.
  • 404 Not Found: Returned if the {{CHAT_ROOM_ID}} does not correspond to an existing chat room.

Example Request

GET   https://api.deadsimplechat.com/consumer/api/v1/chatRoom/OmPS_VtLS/messages?auth=SECRET_KEY

Example Response

{
"limit": 18,
"skip": 0,
"totalRecords": 1,
"count": 1,
"messages": [
{
"_id": "65cbcad33126694ef8236f4c",
"likes": [],
"actionButtons": [],
"created": "2024-02-13T20:02:27.165Z",
"chatRoom": "65a5a0e17fb13759919407e4",
"message": "How is it going?",
"user": {
"_id": "65cbcac33126694ef8236f25",
"uniqueUserIdentifier": "25",
"username": "Sam",
"parentCustomerAccount": "648e1fd181cea20bd8b1581b",
"isModerator": false
},
"customer": "648e1fd181cea20bd8b1581b",
"__v": 0
},
{
"_id": "65cbca5c3126694ef8236ed7",
"likes": [],
"actionButtons": [],
"created": "2024-02-13T20:00:28.384Z",
"chatRoom": "65a5a0e17fb13759919407e4",
"message": "phone image",
"user": {
"_id": "648e211a81cea20bd8b1581d",
"username": "admin",
"parentCustomerAccount": "648e1fd181cea20bd8b1581b",
"isModerator": false
},
"customer": "648e1fd181cea20bd8b1581b",
"file": {
"_id": "65cbca573126694ef8236ed2",
"url": "https://f000.backblazeb2.com/file/chatroom-uploads/images/648e1fd181cea20bd8b1581b/58ac8a74-5d2e-417c-9353-370d8543655a/Image.jpeg",
"fileName": "Image.jpeg",
"size": 477245,
"contentType": "image/jpeg",
"fileType": "image",
"imageHeight": 600,
"imageWidth": 800
},
"__v": 0
},
{
"_id": "65cbca493126694ef8236ec8",
"likes": [
{
"_id": "65cbca663126694ef8236ee3",
"username": "admin",
"userId": "648e211a81cea20bd8b1581d",
"reaction": "pray"
},
{
"_id": "65cbca683126694ef8236eeb",
"username": "admin",
"userId": "648e211a81cea20bd8b1581d",
"reaction": "wave"
}
],
"actionButtons": [],
"created": "2024-02-13T20:00:09.779Z",
"chatRoom": "65a5a0e17fb13759919407e4",
"message": "Test Message",
"user": {
"_id": "648e211a81cea20bd8b1581d",
"username": "admin",
"parentCustomerAccount": "648e1fd181cea20bd8b1581b",
"isModerator": false
},
"customer": "648e1fd181cea20bd8b1581b",
"__v": 0
},
]
}