Skip to main content

Get Channel Messages | DeadSimpleChat

Overview

The Get Channel Message API is designed to retrieve messages from a specific channel within a chat room. The request requires authentication and returns a list of messages in JSON format.

HTTP Request

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

URL Parameters

ParameterDescription
{{CHAT_ROOM_ID}}The unique identifier for the chat room.
{{ChannelId}}The unique identifier for the channel.
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 of message objects. Each object has the following structure:

{
"limit": 18,
"skip": 0,
"totalRecords": 1,
"count": 1,
"messages": [
{
"_id": "string",
"likes": "array",
"created": "string",
"user": {
"_id": "string",
"uniqueUserIdentifier": "string",
"username": "string",
"parentCustomerAccount": "string",
"isModerator": "boolean"
},
"channel": "string",
"message": "string",
"__v": "number"
},
// ... additional messages
]
}

Response Fields

  • _id: Unique identifier of the message.
  • likes: An array of objects containing like information, if any.
  • created: Timestamp when the message was created.
  • user: An object with the sender's details.
    • uniqueUserIdentifier: A unique identifier for the user.
    • username: The sender's username.
    • parentCustomerAccount: ID of the parent customer account.
    • isModerator: A boolean indicating whether the user is a moderator.
  • channel: Unique identifier of the channel.
  • message: The text content of the message.
  • __v: Version of the message document.

Errors

  • 401 Unauthorized: Returned if the auth token is not provided, is invalid, or the Authorization header is missing.
  • 404 Not Found: Returned if the {{CHAT_ROOM_ID}} or ChannelId does not exist.

Example Request

GET https://api.example.com/consumer/api/v1/chatRoom/OmPS_VtLS/channel/65cbcbe63126694ef8236f76/messages?auth=secret_key

Example Response

{
"limit": 18,
"skip": 0,
"totalRecords": 1,
"count": 1,
"messages": [
{
"_id": "65cbcc283126694ef8237038",
"likes": [],
"created": "2024-02-13T20:08:08.075Z",
"user": {
"_id": "65cbcac33126694ef8236f25",
"uniqueUserIdentifier": "25",
"username": "Sam",
"parentCustomerAccount": "648e1fd181cea20bd8b1581b",
"isModerator": false
},
"channel": "65cbcbe63126694ef8236f76",
"message": "Testing",
"__v": 0
},
{
"_id": "65cbcc003126694ef8236fe2",
"likes": [
{
"_id": "65cbcc023126694ef8236fed",
"username": "Sam",
"userId": "65cbcac33126694ef8236f25",
"reaction": "thumbs_up"
}
],
"created": "2024-02-13T20:07:28.378Z",
"user": {
"_id": "65cbcac33126694ef8236f25",
"uniqueUserIdentifier": "25",
"username": "Sam",
"parentCustomerAccount": "648e1fd181cea20bd8b1581b",
"isModerator": false
},
"channel": "65cbcbe63126694ef8236f76",
"message": "Hello channel ",
"__v": 0
}
]
}