---
title: "Search within a specific chat"
method: GET
path: "/messenger/v1/search/{chatId}"
tags: ["search"]
---

# Search within a specific chat

`GET /messenger/v1/search/{chatId}`

## Request

- Base URL: `https://{domain}.uspacy.ua`
- URL: `https://{domain}.uspacy.ua/messenger/v1/search/{chatId}`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/uspacy/apis/messenger-service-2/docs/messenger/v1/search/:chatId/get.ts> (a function with typed inputs; its response is checked against the schema)

Searches for messages, files, and links within a specific chat. Returns categorized results for easy filtering.

## Path parameters

- `chatId` string, required

## Query parameters

- `query` string, required
- `limit` number, required
- `date` string, required

## Response `200`

Search results categorized by messages, files, and links

- SearchResponseDto
  - `messages` MessageResponseDto[], required
    - `id` string: Message id
    - `timestamp` number: Timestamp of message
    - `message` string, required: Message text
    - `type` 'MESSAGE' | 'AUDIO' | 'VIDEO' | 'GIF' | 'SYSTEM': Message type
    - `chatId` string, required: Chat id
    - `readBy` number[]: Members ids
    - `externalLine` ExternalLineResponseDto, required
      - `id` string, required: External line id
      - `name` string, required: External line name
      - `icon` string, required: External line icon
      - `externalId` string, required: External line external id
      - `timestamp` number, required: External line timestamp
      - `portal` string, required: External line portal
      - `phoneNumber` string, required: External line phone number
    - `attachedFiles` AttachedFile[]: Attached files
      - `id` object, required: Attached file id
      - `entityId` string, required: Attached file entity id
      - `entityType` string, required: Attached file entity type
      - `lastModified` number, required: Attached file created date
      - `originalFilename` string, required: Attached file original filename
      - `size` string, required: Attached file size
      - `url` string, required: Attached file url
    - `relations` MessageRelation[]: Relations
      - `action` 'create' | 'update' | 'delete', required: Action
      - `service` 'crm', required: Service
      - `entity` 'lead' | 'contact' | 'deal', required: Entity
      - `name` string, required: Entity id
      - `pictureUrl` string, required: Entity picture url
      - `entityId` string, required: Entity id
    - `externalAuthorId` string: External author id
    - `externalId` string: External id
    - `ref` Reference
      - `chatId` string, required: Chat id
      - `authorId` number, required: Author id
      - `messageId` string, required: Message id
    - `meta` MessageMeta
      - `entity` string, required: Entity name
      - `type` string, required: Entity type
      - `accountName` string, required: Account name
      - `accountImage` string, required: Account image url
      - `body` MetaBody[], required: Body entity
        - `text` string, required: Text post or stories or whatever
        - `attachedFiles` string[], required: Attached files url
        - `url` string, required: Post or stories url
  - `files` MessageResponseDto[], required
    - `id` string: Message id
    - `timestamp` number: Timestamp of message
    - `message` string, required: Message text
    - `type` 'MESSAGE' | 'AUDIO' | 'VIDEO' | 'GIF' | 'SYSTEM': Message type
    - `chatId` string, required: Chat id
    - `readBy` number[]: Members ids
    - `externalLine` ExternalLineResponseDto, required
      - `id` string, required: External line id
      - `name` string, required: External line name
      - `icon` string, required: External line icon
      - `externalId` string, required: External line external id
      - `timestamp` number, required: External line timestamp
      - `portal` string, required: External line portal
      - `phoneNumber` string, required: External line phone number
    - `attachedFiles` AttachedFile[]: Attached files
      - `id` object, required: Attached file id
      - `entityId` string, required: Attached file entity id
      - `entityType` string, required: Attached file entity type
      - `lastModified` number, required: Attached file created date
      - `originalFilename` string, required: Attached file original filename
      - `size` string, required: Attached file size
      - `url` string, required: Attached file url
    - `relations` MessageRelation[]: Relations
      - `action` 'create' | 'update' | 'delete', required: Action
      - `service` 'crm', required: Service
      - `entity` 'lead' | 'contact' | 'deal', required: Entity
      - `name` string, required: Entity id
      - `pictureUrl` string, required: Entity picture url
      - `entityId` string, required: Entity id
    - `externalAuthorId` string: External author id
    - `externalId` string: External id
    - `ref` Reference
      - `chatId` string, required: Chat id
      - `authorId` number, required: Author id
      - `messageId` string, required: Message id
    - `meta` MessageMeta
      - `entity` string, required: Entity name
      - `type` string, required: Entity type
      - `accountName` string, required: Account name
      - `accountImage` string, required: Account image url
      - `body` MetaBody[], required: Body entity
        - `text` string, required: Text post or stories or whatever
        - `attachedFiles` string[], required: Attached files url
        - `url` string, required: Post or stories url
  - `links` MessageResponseDto[], required
    - `id` string: Message id
    - `timestamp` number: Timestamp of message
    - `message` string, required: Message text
    - `type` 'MESSAGE' | 'AUDIO' | 'VIDEO' | 'GIF' | 'SYSTEM': Message type
    - `chatId` string, required: Chat id
    - `readBy` number[]: Members ids
    - `externalLine` ExternalLineResponseDto, required
      - `id` string, required: External line id
      - `name` string, required: External line name
      - `icon` string, required: External line icon
      - `externalId` string, required: External line external id
      - `timestamp` number, required: External line timestamp
      - `portal` string, required: External line portal
      - `phoneNumber` string, required: External line phone number
    - `attachedFiles` AttachedFile[]: Attached files
      - `id` object, required: Attached file id
      - `entityId` string, required: Attached file entity id
      - `entityType` string, required: Attached file entity type
      - `lastModified` number, required: Attached file created date
      - `originalFilename` string, required: Attached file original filename
      - `size` string, required: Attached file size
      - `url` string, required: Attached file url
    - `relations` MessageRelation[]: Relations
      - `action` 'create' | 'update' | 'delete', required: Action
      - `service` 'crm', required: Service
      - `entity` 'lead' | 'contact' | 'deal', required: Entity
      - `name` string, required: Entity id
      - `pictureUrl` string, required: Entity picture url
      - `entityId` string, required: Entity id
    - `externalAuthorId` string: External author id
    - `externalId` string: External id
    - `ref` Reference
      - `chatId` string, required: Chat id
      - `authorId` number, required: Author id
      - `messageId` string, required: Message id
    - `meta` MessageMeta
      - `entity` string, required: Entity name
      - `type` string, required: Entity type
      - `accountName` string, required: Account name
      - `accountImage` string, required: Account image url
      - `body` MetaBody[], required: Body entity
        - `text` string, required: Text post or stories or whatever
        - `attachedFiles` string[], required: Attached files url
        - `url` string, required: Post or stories url

---

[API](https://skmtc.dev/uspacy/apis/messenger-service-2.md) - [All operations](https://skmtc.dev/uspacy/apis/messenger-service-2/llms.txt) - [OpenAPI document](https://skmtc.dev/uspacy/apis/messenger-service-2/revisions/699626a9e425?raw)
