---
agentTools:
  projectIndex: https://uspacy.readme.io/llms.txt
---

# Find all chats by meta value

Searches for all chats matching the specified metadata type and value. Returns multiple results if found.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "paths": {
    "/messenger/v1/chats/findAllByMeta": {
      "get": {
        "operationId": "ChatsController_handleFindAllByMeta",
        "summary": "Find all chats by meta value",
        "description": "Searches for all chats matching the specified metadata type and value. Returns multiple results if found.",
        "parameters": [
          {
            "name": "type",
            "required": true,
            "in": "query",
            "description": "The type of metadata to search by",
            "schema": {
              "enum": [
                "phone",
                "widgetUser",
                "username",
                "facebook",
                "instagram",
                "telegram",
                "twitter",
                "viber",
                "whatsapp"
              ],
              "type": "string"
            },
            "example": "phone"
          },
          {
            "name": "value",
            "required": true,
            "in": "query",
            "description": "The metadata value to search for",
            "schema": {
              "type": "string"
            },
            "example": "+1234567890"
          }
        ],
        "responses": {
          "200": {
            "description": "Find chats by meta value",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChatResponseDto"
                  }
                }
              }
            }
          }
        },
        "tags": [
          "chats"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    }
  },
  "info": {
    "title": "Messenger service",
    "description": "API for managing chats, messages, and other messenger-related functionalities.",
    "version": "v1",
    "contact": {}
  },
  "servers": [
    {
      "url": "https://{domain}.uspacy.ua",
      "description": "Ukrainian server"
    },
    {
      "url": "https://{domain}.uspacy.eu",
      "description": "EU server"
    },
    {
      "url": "https://{domain}.uspacy.com.br",
      "description": "Brazilian server"
    },
    {
      "url": "https://{domain}.uspacy.com",
      "description": "International server"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "type": "http"
      }
    },
    "schemas": {
      "ExternalLineResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "External line id",
            "example": "659ff121fd62e43063340f2f"
          },
          "name": {
            "type": "string",
            "description": "External line name",
            "example": "Main line"
          },
          "icon": {
            "type": "string",
            "description": "External line icon",
            "example": "https://example.com/icon.png"
          },
          "externalId": {
            "type": "string",
            "description": "External line external id",
            "example": "externalId"
          },
          "timestamp": {
            "type": "number",
            "description": "External line timestamp",
            "example": 1620211200000
          },
          "portal": {
            "type": "string",
            "description": "External line portal",
            "example": "portal"
          },
          "phoneNumber": {
            "type": "string",
            "description": "External line phone number",
            "example": "+1234567890"
          }
        },
        "required": [
          "id",
          "name",
          "icon",
          "externalId",
          "timestamp",
          "portal",
          "phoneNumber"
        ]
      },
      "AttachedFile": {
        "type": "object",
        "properties": {
          "id": {
            "type": "object",
            "description": "Attached file id",
            "example": 1
          },
          "entityId": {
            "type": "string",
            "description": "Attached file entity id",
            "example": "659ff121fd62e43063340f2f"
          },
          "entityType": {
            "type": "string",
            "description": "Attached file entity type",
            "example": "chat_message"
          },
          "lastModified": {
            "type": "number",
            "description": "Attached file created date",
            "example": 1613491200000
          },
          "originalFilename": {
            "type": "string",
            "description": "Attached file original filename",
            "example": "file.jpg"
          },
          "size": {
            "type": "string",
            "description": "Attached file size",
            "example": "1024"
          },
          "url": {
            "type": "string",
            "description": "Attached file url",
            "example": "https://example.com/file.jpg"
          }
        },
        "required": [
          "id",
          "entityId",
          "entityType",
          "lastModified",
          "originalFilename",
          "size",
          "url"
        ]
      },
      "MessageRelation": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "delete"
            ],
            "example": "create",
            "description": "Action"
          },
          "service": {
            "type": "string",
            "enum": [
              "crm"
            ],
            "example": "crm",
            "description": "Service"
          },
          "entity": {
            "type": "string",
            "enum": [
              "lead",
              "contact",
              "deal"
            ],
            "example": "contact",
            "description": "Entity"
          },
          "name": {
            "type": "string",
            "description": "Entity id",
            "example": "659ff121fd62e43063340f2f"
          },
          "pictureUrl": {
            "type": "string",
            "description": "Entity picture url",
            "example": "https://example.com/picture.jpg"
          },
          "entityId": {
            "type": "string",
            "description": "Entity id",
            "example": "659ff121fd62e43063340f2f"
          }
        },
        "required": [
          "action",
          "service",
          "entity",
          "name",
          "pictureUrl",
          "entityId"
        ]
      },
      "Reference": {
        "type": "object",
        "properties": {
          "chatId": {
            "type": "string",
            "example": "76bfc2ff-207c-4b5a-8543-f7009b7f8872",
            "description": "Chat id"
          },
          "authorId": {
            "type": "number",
            "example": 1,
            "description": "Author id"
          },
          "messageId": {
            "type": "string",
            "example": "76bfc2ff-207c-4b5a-8543-f7009b7f8872",
            "description": "Message id"
          }
        },
        "required": [
          "chatId",
          "authorId",
          "messageId"
        ]
      },
      "MetaBody": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "Text post or stories or whatever",
            "example": "Hello, world!"
          },
          "attachedFiles": {
            "description": "Attached files url",
            "example": "https://example.com/file.jpg",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "url": {
            "type": "string",
            "description": "Post or stories url",
            "example": "https://www.instagram.com"
          }
        },
        "required": [
          "text",
          "attachedFiles",
          "url"
        ]
      },
      "MessageMeta": {
        "type": "object",
        "properties": {
          "entity": {
            "type": "string",
            "description": "Entity name"
          },
          "type": {
            "type": "string",
            "description": "Entity type"
          },
          "accountName": {
            "type": "string",
            "description": "Account name"
          },
          "accountImage": {
            "type": "string",
            "description": "Account image url"
          },
          "body": {
            "description": "Body entity",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetaBody"
            }
          }
        },
        "required": [
          "entity",
          "type",
          "accountName",
          "accountImage",
          "body"
        ]
      },
      "MessageResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "76bfc2ff-207c-4b5a-8543-f7009b7f8872",
            "description": "Message id"
          },
          "timestamp": {
            "type": "number",
            "example": 1709043064088,
            "description": "Timestamp of message"
          },
          "message": {
            "type": "string",
            "example": "Hello, world!",
            "description": "Message text"
          },
          "type": {
            "type": "string",
            "enum": [
              "MESSAGE",
              "AUDIO",
              "VIDEO",
              "GIF",
              "SYSTEM"
            ],
            "example": "MESSAGE",
            "description": "Message type"
          },
          "chatId": {
            "type": "string",
            "example": "76bfc2ff-207c-4b5a-8543-f7009b7f8872",
            "description": "Chat id"
          },
          "readBy": {
            "example": [
              1,
              2,
              3,
              4
            ],
            "description": "Members ids",
            "type": "array",
            "items": {
              "type": "number"
            }
          },
          "externalLine": {
            "description": "External line",
            "allOf": [
              {
                "$ref": "#/components/schemas/ExternalLineResponseDto"
              }
            ]
          },
          "attachedFiles": {
            "description": "Attached files",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttachedFile"
            }
          },
          "relations": {
            "description": "Relations",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessageRelation"
            }
          },
          "externalAuthorId": {
            "type": "string",
            "description": "External author id",
            "example": "123456"
          },
          "externalId": {
            "type": "string",
            "description": "External id",
            "example": "123456"
          },
          "ref": {
            "description": "Reference",
            "allOf": [
              {
                "$ref": "#/components/schemas/Reference"
              }
            ]
          },
          "meta": {
            "description": "MessageMeta",
            "allOf": [
              {
                "$ref": "#/components/schemas/MessageMeta"
              }
            ]
          }
        },
        "required": [
          "message",
          "chatId",
          "externalLine"
        ]
      },
      "ChatMeta": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "phone",
              "widgetUser",
              "username",
              "facebook",
              "instagram",
              "telegram",
              "twitter",
              "viber",
              "whatsapp"
            ],
            "example": "telegram",
            "description": "Meta type"
          },
          "value": {
            "type": "string",
            "example": "1234567890",
            "description": "Meta value"
          }
        },
        "required": [
          "type",
          "value"
        ]
      },
      "ChatSettingsDto": {
        "type": "object",
        "properties": {
          "muteUntil": {
            "example": "forever",
            "description": "Mute until",
            "type": "array",
            "items": {
              "type": "number"
            }
          }
        },
        "required": [
          "muteUntil"
        ]
      },
      "ChatResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "76bfc2ff-207c-4b5a-8543-f7009b7f8872",
            "description": "Chat id"
          },
          "members": {
            "type": "string",
            "example": [
              1,
              2,
              3,
              4
            ],
            "description": "Members ids"
          },
          "timestamp": {
            "type": "number",
            "example": 1709043064088,
            "description": "Timestamp of last message in chat"
          },
          "ownerId": {
            "type": "number",
            "example": 1,
            "description": "Owner id"
          },
          "name": {
            "type": "string",
            "example": "Chat name",
            "description": "Chat name"
          },
          "pictureUrl": {
            "type": "string",
            "example": "https://example.com/picture.jpg",
            "description": "Chat picture url"
          },
          "type": {
            "type": "string",
            "enum": [
              "PRIVATE",
              "PUBLIC",
              "GROUP",
              "DIRECT",
              "EXTERNAL"
            ],
            "example": "GROUP",
            "description": "Chat type"
          },
          "groupId": {
            "type": "number",
            "example": 1,
            "description": "Group id"
          },
          "portals": {
            "example": [
              "portal1",
              "portal2"
            ],
            "description": "Portals",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "externalLines": {
            "description": "External lines",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalLineResponseDto"
            }
          },
          "lastMessage": {
            "$ref": "#/components/schemas/MessageResponseDto"
          },
          "meta": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatMeta"
            }
          },
          "active": {
            "type": "boolean",
            "example": true,
            "description": "Chat active"
          },
          "unreadCount": {
            "type": "number",
            "example": 1,
            "description": "Unread messages count"
          },
          "pinned": {
            "type": "boolean",
            "example": true,
            "description": "Pinned chat"
          },
          "pinnedTimestamp": {
            "type": "number",
            "example": 1709043064088,
            "description": "Pinned timestamp"
          },
          "setting": {
            "description": "Chat settings",
            "allOf": [
              {
                "$ref": "#/components/schemas/ChatSettingsDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "members",
          "timestamp",
          "ownerId",
          "name",
          "pictureUrl",
          "type",
          "groupId",
          "portals",
          "externalLines",
          "lastMessage",
          "meta",
          "active",
          "unreadCount",
          "pinned",
          "pinnedTimestamp",
          "setting"
        ]
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 101,
      "1": 187,
      "2": 117,
      "3": 228,
      "4": 199,
      "5": 37,
      "6": 48,
      "7": 0,
      "8": 120,
      "9": 36,
      "10": 113,
      "11": 177
    }
  }
}
```