> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Sync Messages

> List the messages in a room along with any data updates from a specified date.
### Changelog
| Version      | Description | 
| ------------ | ------------|
| 1.0.0        | Added       |

## OpenAPI

````json GET /api/v1/chat.syncMessages
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Messaging"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "tags": [
    {
      "name": "Chat"
    },
    {
      "name": "DM"
    },
    {
      "name": "Auto-Translate"
    }
  ],
  "paths": {
    "/api/v1/chat.syncMessages": {
      "get": {
        "tags": [
          "Chat"
        ],
        "summary": "Sync Messages",
        "description": "List the messages in a room along with any data updates from a specified date.\n### Changelog\n| Version      | Description | \n| ------------ | ------------|\n| 1.0.0        | Added       |",
        "operationId": "get-api-v1-chat.syncMessages",
        "parameters": [
          {
            "$ref": "#/components/parameters/Auth-Token"
          },
          {
            "$ref": "#/components/parameters/UserId"
          },
          {
            "$ref": "#/components/parameters/RoomId"
          },
          {
            "$ref": "#/components/parameters/offset"
          },
          {
            "$ref": "#/components/parameters/count"
          },
          {
            "$ref": "#/components/parameters/sort"
          },
          {
            "name": "lastUpdate",
            "in": "query",
            "description": "The date as an ISO string. You cannot use this parameter if you are using the `next` or `previous` parameter.",
            "schema": {
              "type": "string"
            },
            "example": "2019-04-16T18:30:46.669Z"
          },
          {
            "schema": {
              "type": "number",
              "example": "14182940000"
            },
            "in": "query",
            "name": "next",
            "description": "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()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime). Note that you can use either `next` or `previous` at the same time."
          },
          {
            "schema": {
              "type": "number",
              "example": "14182940000"
            },
            "in": "query",
            "name": "previous",
            "description": "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()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime)."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "type",
            "description": "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."
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "properties": {
                        "updated": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "_id": {
                                "type": "string"
                              },
                              "rid": {
                                "type": "string"
                              },
                              "u": {
                                "type": "object",
                                "properties": {
                                  "_id": {
                                    "type": "string"
                                  },
                                  "username": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  }
                                }
                              },
                              "msg": {
                                "type": "string"
                              },
                              "ts": {
                                "type": "string"
                              },
                              "_updatedAt": {
                                "type": "string"
                              },
                              "alias": {
                                "type": "string"
                              },
                              "token": {
                                "type": "string"
                              },
                              "unread": {
                                "type": "boolean"
                              },
                              "urls": {
                                "type": "array",
                                "items": {
                                  "type": "object"
                                }
                              },
                              "mentions": {
                                "type": "array",
                                "items": {
                                  "type": "object"
                                }
                              },
                              "channels": {
                                "type": "array",
                                "items": {
                                  "type": "object"
                                }
                              },
                              "md": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string"
                                    },
                                    "value": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string"
                                          },
                                          "value": {
                                            "type": "string"
                                          }
                                        }
                                      }
                                    }
                                  }
                                }
                              },
                              "t": {
                                "type": "string"
                              },
                              "groupable": {
                                "type": "boolean"
                              }
                            }
                          }
                        },
                        "deleted": {
                          "type": "array",
                          "items": {
                            "type": "object"
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Example": {
                    "value": {
                      "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"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    },
                    "errorType": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "success": "false",
                      "error": "The required \"roomId\" query param is missing. [error-roomId-param-not-provided]",
                      "errorType": "error-roomId-param-not-provided"
                    }
                  },
                  "Example 2": {
                    "value": {
                      "success": "false",
                      "error": "The required \"lastUpdate\" query param is missing. [error-lastUpdate-param-not-provided]",
                      "errorType": "error-lastUpdate-param-not-provided"
                    }
                  },
                  "Example 3": {
                    "value": {
                      "success": "false",
                      "error": "The \"lastUpdate\" query parameter must be a valid date. [error-roomId-param-invalid]",
                      "errorType": "error-roomId-param-invalid"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "Auth-Token": {
        "name": "X-Auth-Token",
        "in": "header",
        "description": "The `authToken` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
      },
      "UserId": {
        "name": "X-User-Id",
        "in": "header",
        "description": "The `userId` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "rbAXPnMktTFbNpwtJ"
      },
      "RoomId": {
        "name": "roomId",
        "in": "query",
        "description": "The room ID.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "6GFJ3tbmHiyHbahmC"
      },
      "offset": {
        "name": "offset",
        "in": "query",
        "description": "Number of items to \"skip\" in the query, i.e. requests return count items, skipping the first offset items. Refer to the [official documentation](https://developer.rocket.chat/apidocs/query-parameters#pagination) to learn more.",
        "required": "false",
        "schema": {
          "type": "integer"
        },
        "example": "50"
      },
      "count": {
        "name": "count",
        "in": "query",
        "description": "The number of items to return.  Refer to the [official documentation](https://developer.rocket.chat/apidocs/query-parameters#pagination) to learn more.",
        "required": "false",
        "schema": {
          "type": "integer"
        },
        "example": "50"
      },
      "sort": {
        "name": "sort",
        "in": "query",
        "description": "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](https://developer.rocket.chat/apidocs/query-parameters#pagination) to learn more.",
        "required": "false",
        "schema": {}
      }
    },
    "responses": {
      "authorizationError": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Authorization Error": {
                "value": {
                  "status": "error",
                  "message": "You must be logged in to do this."
                }
              }
            }
          }
        }
      }
    }
  }
}
````

