> ## 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.

# Search Visitor Chat

> Get the Livechat information of a visitor. This endpoint returns only those chats that are served and closed.

## OpenAPI

````json GET /api/v1/livechat/visitors.searchChats/room/{roomId}/visitor/{visitorId}
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Omnichannel"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "tags": [
    {
      "name": "Omnichannel Users"
    },
    {
      "name": "Omnichannel Agents"
    },
    {
      "name": "Omnichannel Monitors"
    },
    {
      "name": "Omnichannel Visitors"
    },
    {
      "name": "Omnichannel Contacts"
    },
    {
      "name": "Omnichannel Rooms"
    },
    {
      "name": "Omnichannel Departments"
    },
    {
      "name": "Omnichannel Custom Fields"
    },
    {
      "name": "Omnichannel Business Hours"
    },
    {
      "name": "Omnichannel Priorities"
    },
    {
      "name": "Omnichannel Tags"
    },
    {
      "name": "Omnichannel Units"
    },
    {
      "name": "SLA Policies"
    },
    {
      "name": "Canned Responses"
    },
    {
      "name": "Omnichannel Transcript"
    },
    {
      "name": "Omnichannel Statistics"
    },
    {
      "name": "Omnichannel Agent Stats"
    },
    {
      "name": "Omnichannel Dashboards"
    },
    {
      "name": "Reports"
    },
    {
      "name": "Omnichannel Inquiries"
    },
    {
      "name": "Omnichannel Webhooks"
    },
    {
      "name": "Livechat"
    },
    {
      "name": "Livechat Appearance"
    },
    {
      "name": "Livechat Triggers"
    },
    {
      "name": "Livechat Messages"
    },
    {
      "name": "Livechat Page Visited"
    }
  ],
  "paths": {
    "/api/v1/livechat/visitors.searchChats/room/{roomId}/visitor/{visitorId}": {
      "parameters": [
        {
          "schema": {
            "type": "string"
          },
          "name": "roomId",
          "in": "path",
          "required": "true",
          "description": "The room ID."
        },
        {
          "schema": {
            "type": "string"
          },
          "name": "visitorId",
          "in": "path",
          "required": "true",
          "description": "The visitor ID."
        }
      ],
      "get": {
        "summary": "Search Visitor Chat",
        "tags": [
          "Omnichannel Visitors"
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "history": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "_id": {
                            "type": "string"
                          },
                          "msgs": {
                            "type": "integer"
                          },
                          "fname": {
                            "type": "string"
                          },
                          "ts": {
                            "type": "string"
                          },
                          "v": {
                            "type": "object",
                            "properties": {
                              "_id": {
                                "type": "string"
                              },
                              "username": {
                                "type": "string"
                              },
                              "token": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string"
                              },
                              "lastMessageTs": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "count": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success Example": {
                    "value": {
                      "history": [
                        {
                          "_id": "hhMKhHnnbY79mGs9K",
                          "msgs": "2",
                          "fname": "Maria",
                          "ts": "2021-07-22T17:17:04.216Z",
                          "v": {
                            "_id": "QyBAKC5Wc8tcv6cco",
                            "username": "guest-537",
                            "token": "8s7e9ony6ctl27e1qf8kue",
                            "status": "online",
                            "lastMessageTs": "2021-07-22T17:17:04.937Z"
                          }
                        }
                      ],
                      "count": "1",
                      "offset": "0",
                      "total": "1",
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          }
        },
        "operationId": "get-api-v1-livechat-visitors.searchChats-room-roomId-visitor-visitorId",
        "description": "Get the Livechat information of a visitor. This endpoint returns only those chats that are served and closed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthToken"
          },
          {
            "$ref": "#/components/parameters/UserId"
          },
          {
            "$ref": "#/components/parameters/offset"
          },
          {
            "$ref": "#/components/parameters/count"
          },
          {
            "schema": {},
            "in": "query",
            "name": "sort",
            "description": "Sort the events in the ascending (`1`) or descending (`-1`) order. By default, the result is sorted in descending order. The most recent chats are returned first. Enter the value as: `sort[ts]=1` or `sort[ts]=-1`. Here `ts` refers to timestamp."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "searchText",
            "description": "Enter the text to search for within the chat."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "closedChatsOnly",
            "description": "Filter the results to display only closed chats. The value can be `\"true\"` or `\"false\"`."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "servedChatsOnly",
            "description": "Filter the results to display only chats that are joined by agents. The value can be `\"true\"` or `\"false\"`."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "source",
            "description": "Filter the results by the source of the chat. The value can be: `widget`, `sms`, `api`, `email`, `app`, `other`."
          }
        ]
      }
    }
  },
  "components": {
    "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."
                }
              }
            }
          }
        }
      }
    },
    "parameters": {
      "AuthToken": {
        "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"
      },
      "offset": {
        "name": "offset",
        "in": "query",
        "required": "false",
        "schema": {
          "type": "integer"
        },
        "example": "50",
        "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."
      },
      "count": {
        "name": "count",
        "in": "query",
        "required": "false",
        "schema": {
          "type": "integer"
        },
        "example": "25",
        "description": "The number of items to return. Refer to the [official documentation](https://developer.rocket.chat/apidocs/query-parameters#pagination) to learn more."
      }
    }
  }
}
````

