Get a UserChat's messages

Retrieve a list of message of UserChat with ID.

Parameter

Accessible via URL https://api.channel.io/open/v3/user-chats/{userChatId}/messages and HTTP GET

📘

This method does currently accept application/json only.

Parameter

Example

Required

Description

Parameter type

userChatId

5e65fa8bc2409f0c1fd3

Required

ID of UserChat

Path

since

eyJjaGF0S2V5IjoiZ3Jvn0=

Optional

Encoded key of the first message to be retrieved

Qeury

limit

25

Optional

Restrict the maximum number of messages to be retrieved

Query

sortOrder

desc(or asc)

Required

Order messages should be listed (descending order means latest message first)

Query

Example

GET https://api.channel.io/open/v3/user-chats/5e65fa8bc2409f0c1fd3/messages?limit=10

Response

Returns messages along with related information.

{
  "next": "String",
  "messages": [
    {
      "chatKey": "userChat-5e7049961ece389ba6ac",
      "id": "5e89ebbe897380e9d378",
      "channelId": "10",
      "chatType": "userChat",
      "chatId": "5e7049961ece389ba6ac",
      "personType": "bot",
      "personId": "10598",
      "createdAt": 1586097086563,
      "version": 1,
      "log": {
        "action": "invite",
        "values": [
          "String"
        ]
      },
      "options": [
        "immutable",
        "quiet",
        "private"
      ]
    }
  ],
  "bots": [
    {
      "id": "10598",
      "channelId": "10",
      "name": "bot",
      "createdAt": 1533542935896,
      "color": "#9270ff",
      "avatarUrl": "https://cf.channel.io/avatar/text/B.c6a5ff.png"
    }
  ],
  "users": []
}

Implementation Notes

The number of messages retrieved in this endpoint is restricted by the limit query parameter, and is capped to values in the closed interval [1, 100].

Pagination is supported through the since query parameter along with the next value contained in the root object of the JSON response. Successive queries to this endpoint using the previous next value as the since parameter will ultimately retrieve all messages in the chat.

If the since parameter is left empty, the list retrieved will start with the first message (as specified by the order parameter).