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

> > **Note:** This endpoint will be replaced. Refer to the [new API documentation](https://developer.rocket.chat/apidocs/search-omnichannel-contacts) for updated usage and features.

Find contacts by name, email, phone number, or any custom field values stored in the database.
Permission required: `view-l-room`.
* Encode values having characters like @,+, /and * to avoid breaking the endpoint.
* To find contacts using custom fields, use the custom query parameter. The custom query parameter must be encoded by <a href="https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams" target="_blank">URLSearchParams</a>.
For example, to search contacts with premium subscription, the request is as follows:
```
curl --location --globoff 'http://localhost:3000/api/v1/omnichannel/contact.search?custom={%20%22Subscription%22%3A%20%22premium%22%20}' \
--header 'X-Auth-Token: b5BKhblglC5OU0AfB_Tl9dKmOb0zXUvWK-nhNT_aE8V' \
--header 'X-User-Id: CkCPNcvsvCDfmWLqC'
```

## OpenAPI

````json GET /api/v1/omnichannel/contact.search
{
  "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/omnichannel/contact.search": {
      "get": {
        "summary": "Search Contacts",
        "description": "> **Note:** This endpoint will be replaced. Refer to the [new API documentation](https://developer.rocket.chat/apidocs/search-omnichannel-contacts) for updated usage and features.\n\nFind contacts by name, email, phone number, or any custom field values stored in the database.\nPermission required: `view-l-room`.\n* Encode values having characters like @,+, /and * to avoid breaking the endpoint.\n* To find contacts using custom fields, use the custom query parameter. The custom query parameter must be encoded by <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams\" target=\"_blank\">URLSearchParams</a>.\nFor example, to search contacts with premium subscription, the request is as follows:\n```\ncurl --location --globoff 'http://localhost:3000/api/v1/omnichannel/contact.search?custom={%20%22Subscription%22%3A%20%22premium%22%20}' \\\n--header 'X-Auth-Token: b5BKhblglC5OU0AfB_Tl9dKmOb0zXUvWK-nhNT_aE8V' \\\n--header 'X-User-Id: CkCPNcvsvCDfmWLqC'\n```",
        "operationId": "get-api-v1-contact.search",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthToken"
          },
          {
            "$ref": "#/components/parameters/UserId"
          },
          {
            "name": "email",
            "in": "query",
            "description": "The contact's email address.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "description": "The contact's phone number.",
            "schema": {
              "type": "string"
            },
            "example": "+1367895436"
          },
          {
            "name": "custom",
            "in": "query",
            "description": "The defined custom fields.",
            "schema": {
              "type": "string"
            },
            "example": "fieldName=value"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contact": {
                      "type": "object",
                      "properties": {
                        "_id": {
                          "type": "string"
                        },
                        "username": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "ts": {
                          "type": "string"
                        },
                        "_updatedAt": {
                          "type": "string"
                        },
                        "department": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "token": {
                          "type": "string"
                        },
                        "visitorEmails": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "address": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "lastChat": {
                          "type": "object",
                          "properties": {
                            "_id": {
                              "type": "string"
                            },
                            "ts": {
                              "type": "string"
                            }
                          }
                        },
                        "livechatData": {
                          "type": "object",
                          "properties": {
                            "hobby": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success Example": {
                    "value": {
                      "contact": {
                        "_id": "62fbed6d337291dc9a68ff89",
                        "username": "guest-16",
                        "status": "online",
                        "ts": "2022-08-16T19:18:05.38Z",
                        "_updatedAt": "2022-08-23T17:58:37.254Z",
                        "department": "MgzoccgEFHZ856i97",
                        "name": "Kev",
                        "token": "969X86icKLRduGAKK",
                        "visitorEmails": [
                          {
                            "address": "email@rocket.chat"
                          }
                        ],
                        "lastChat": {
                          "_id": "CT5bru2WjJ2EsmGbH",
                          "ts": "2022-08-16T19:24:35.916Z"
                        },
                        "livechatData": {
                          "hobby": "gaming"
                        }
                      },
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/permissionError"
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          }
        },
        "tags": [
          "Omnichannel Contacts"
        ]
      }
    }
  },
  "components": {
    "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"
      }
    },
    "responses": {
      "permissionError": {
        "description": "Forbidden",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "type": "boolean"
                },
                "error": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Permission Error": {
                "value": {
                  "success": "false",
                  "error": "User does not have the permissions required for this action [error-unauthorized]"
                }
              },
              "Unauthorized": {
                "value": {
                  "success": "false",
                  "error": "unauthorized"
                }
              }
            }
          }
        }
      },
      "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."
                }
              }
            }
          }
        }
      }
    }
  }
}
````

