Sync Messages

Prev Next
Get
/api/v1/chat.syncMessages

List the messages in a room along with any data updates from a specified date.

Changelog

Version Description
1.0.0 Added
Header parameters
X-Auth-Token
stringRequired

The authToken of the authenticated user.

ExampleRScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f
X-User-Id
stringRequired

The userId of the authenticated user.

ExamplerbAXPnMktTFbNpwtJ
Query parameters
roomId
stringRequired

The room ID.

Example6GFJ3tbmHiyHbahmC
offset
integer

Number of items to "skip" in the query, i.e. requests return count items, skipping the first offset items. Refer to the official documentation to learn more.

Example50
count
integer

The number of items to return. Refer to the official documentation to learn more.

Example50
sort

List of fields to order by, and in which direction. This is a JSON object, with properties listed in desired order, with values of 1 for ascending, or -1 for descending. For example, { "value": -1, "_id": 1 }. Refer to the official documentation to learn more.

lastUpdate
string

The date as an ISO string. You cannot use this parameter if you are using the next or previous parameter.

Example2019-04-16T18:30:46.669Z
next
number

This indicates whether the query should retrieve items from a later point in time. The value must be the number of milliseconds, as it follows Date getTime(). Note that you can use either next or previous at the same time.

Example14182940000
previous
number

This indicates whether the query should retrieve items from an earlier point in time. The value must be the number of milliseconds, as it follows Date getTime().

Example14182940000
type
string

You must specify whether you want to retrieve DELETED (for deleted messages) or UPDATED (for updated messages, which is the default use case). This parameter is required if you are using the next or previous parameter.


Note: offset, sort, and count are optional parameters. By default, the endpoint returns 20 items if you don't specify a value for count. According to the remaining query parameters you use, this endpoint returns the messages in two ways: 

  • With the lastUpdate parameter: If you use the lastUpdate parameter, the endpoint returns the messages updated since the specified date. 
  • With the cursor based pagination: For this approach, you must enter either the next or the previous parameter, and type is a mandatory field. In this case, the lastUpdate parameter cannot be used.
Responses
200

OK

Example
{
  "result": {
    "updated": [
      {
        "_id": "ak3WdaLbf4P7ZW3wQ",
        "rid": "5qW6ssMFyzWjJev69",
        "u": {
          "_id": "FWfHnJmcudrCagGDX",
          "username": "555192857993",
          "name": "555192857993"
        },
        "msg": "teste",
        "ts": "2021-09-24T19:19:47.911Z",
        "_updatedAt": "2021-09-24T19:19:48.048Z",
        "alias": "mauricio pretto",
        "token": "do554ryecscmfrrxyxpvm",
        "unread": true,
        "urls": [],
        "mentions": [],
        "channels": [],
        "md": [
          {
            "type": "PARAGRAPH",
            "value": [
              {
                "type": "PLAIN_TEXT",
                "value": "teste"
              }
            ]
          }
        ]
      },
      {
        "_id": "2ttrNPABcCKbsbEtB",
        "t": "livechat-started",
        "msg": "",
        "groupable": false,
        "ts": "2021-09-24T19:19:46.523Z",
        "u": {
          "_id": "FWfHnJmcudrCagGDX",
          "username": "555192857993",
          "name": "555192857993"
        },
        "rid": "5qW6ssMFyzWjJev69",
        "unread": true,
        "_updatedAt": "2021-09-24T19:19:46.691Z",
        "urls": [],
        "mentions": [],
        "channels": []
      }
    ],
    "deleted": []
  },
  "success": true
}
Expand All
object
result
object
updated
Array of object
object
_id
string
rid
string
u
object
_id
string
username
string
name
string
msg
string
ts
string
_updatedAt
string
alias
string
token
string
unread
boolean
urls
Array of object
object
mentions
Array of object
object
channels
Array of object
object
md
Array of object
object
type
string
value
Array of object
object
type
string
value
string
t
string
groupable
boolean
deleted
Array of object
object
success
boolean
400

Bad Request

Example 1
{
  "success": false,
  "error": "The required \"roomId\" query param is missing. [error-roomId-param-not-provided]",
  "errorType": "error-roomId-param-not-provided"
}
Example 2
{
  "success": false,
  "error": "The required \"lastUpdate\" query param is missing. [error-lastUpdate-param-not-provided]",
  "errorType": "error-lastUpdate-param-not-provided"
}
Example 3
{
  "success": false,
  "error": "The \"lastUpdate\" query parameter must be a valid date. [error-roomId-param-invalid]",
  "errorType": "error-roomId-param-invalid"
}
object
success
boolean
error
string
errorType
string
401

Unauthorized

Authorization Error
{
  "status": "error",
  "message": "You must be logged in to do this."
}
object
status
string
message
string