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

# Search Conversations

> Returns a list of all conversations matching the search criteria along with the sort and filter options selected.

Returns a list of all conversations matching the search criteria along with the sort and filter options selected.

```http theme={null}
GET https://services.leadconnectorhq.com/conversations/search
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Query parameters

<ParamField query="locationId" type="string" required default="ABCHkzuJQ8ZMd4Te84GK">
  Account Id
</ParamField>

<ParamField query="contactId" type="string" default="9VEmS0si86GW6gXWU89b">
  Contact Id
</ParamField>

<ParamField query="assignedTo" type="string" default="ABCHkzuJQ8ZMd4Te84GK,fGiae4CHkzoskh8thsik">
  User IDs that conversations are assigned to. Multiple IDs can be provided as comma-separated values. Use "unassigned" to fetch conversations not assigned to any user.
</ParamField>

<ParamField query="followers" type="string" default="ABCHkzuJQ8ZMd4Te84GK,fGiae4CHkzoskh8thsik">
  User IDs of followers to filter conversations by. Multiple IDs can be provided as comma-separated values.
</ParamField>

<ParamField query="mentions" type="string" default="ABCHkzuJQ8ZMd4Te84GK,fGiae4CHkzoskh8thsik">
  User Id of the mention. Multiple values are comma separated.
</ParamField>

<ParamField query="query" type="string" default="Search string">
  Search paramater as a string
</ParamField>

<ParamField query="sort" type="string" default="asc">
  Sort paramater - asc or desc
</ParamField>

<ParamField query="startAfterDate" type="any" default="1600854">
  Search to begin after the specified date - should contain the sort value of the last document
</ParamField>

<ParamField query="id" type="string" default="ABCHkzuJQ8ZMd4Te84GK">
  Id of the conversation
</ParamField>

<ParamField query="limit" type="number" default="20">
  Limit of conversations - Default is 20
</ParamField>

<ParamField query="lastMessageType" type="string" default="TYPE_SMS">
  Type of the last message in the conversation as a string
</ParamField>

<ParamField query="lastMessageAction" type="string" default="manual">
  Action of the last outbound message in the conversation as string.
</ParamField>

<ParamField query="lastMessageDirection" type="string" default="inbound">
  Direction of the last message in the conversation as string.
</ParamField>

<ParamField query="status" type="string" default="all">
  The status of the conversation to be filtered - all, read, unread, starred
</ParamField>

<ParamField query="sortBy" type="string" default="last_message_date">
  The sorting of the conversation to be filtered as - manual messages or all messages
</ParamField>

<ParamField query="sortScoreProfile" type="string" default="ABCHkzuJQ8ZMd4Te84GK">
  Id of score profile on which sortBy.ScoreProfile should sort on
</ParamField>

<ParamField query="scoreProfile" type="string" default="ABCHkzuJQ8ZMd4Te84GK">
  Id of score profile on which conversations should get filtered out, works with scoreProfileMin & scoreProfileMax
</ParamField>

<ParamField query="scoreProfileMin" type="number" default="ABCHkzuJQ8ZMd4Te84GK">
  Minimum value for score
</ParamField>

<ParamField query="scoreProfileMax" type="number" default="ABCHkzuJQ8ZMd4Te84GK">
  Maximum value for score
</ParamField>

<ParamField query="startDate" type="number" default="1640995200000">
  Start date filter for dateAdded field (Unix timestamp in milliseconds)
</ParamField>

<ParamField query="endDate" type="number" default="1672531199000">
  End date filter for dateAdded field (Unix timestamp in milliseconds)
</ParamField>

## Respuestas

<Accordion title="200 - Successfully fetched the conversations">
  <ResponseField name="conversations" type="object[]" required>
    The list of all conversations found for the given query

    <Expandable title="cada item">
      <ResponseField name="id" type="string" required default="ABCHkzuJQ8ZMd4Te84GK">
        Conversation Id
      </ResponseField>

      <ResponseField name="contactId" type="string" required default="ABCHkzuJQ8ZMd4Te84GK">
        Contact Id
      </ResponseField>

      <ResponseField name="locationId" type="string" required default="ABCHkzuJQ8ZMd4Te84GK">
        Account Id
      </ResponseField>

      <ResponseField name="lastMessageBody" type="string" required default="This is a sample message body">
        Content of the most recent message in the conversation
      </ResponseField>

      <ResponseField name="lastMessageType" type="string" required default="TYPE_SMS">
        Channel/type of the most recent message (SMS, Email, Call, etc) Posibles valores: 'TYPE\_CALL', 'TYPE\_SMS', 'TYPE\_RCS', 'TYPE\_EMAIL', 'TYPE\_SMS\_REVIEW\_REQUEST', 'TYPE\_WEBCHAT', 'TYPE\_SMS\_NO\_SHOW\_REQUEST', 'TYPE\_CAMPAIGN\_SMS', 'TYPE\_CAMPAIGN\_CALL', 'TYPE\_CAMPAIGN\_EMAIL', 'TYPE\_CAMPAIGN\_VOICEMAIL', 'TYPE\_FACEBOOK', 'TYPE\_CAMPAIGN\_FACEBOOK', 'TYPE\_CAMPAIGN\_MANUAL\_CALL', 'TYPE\_CAMPAIGN\_MANUAL\_SMS', 'TYPE\_GMB', 'TYPE\_CAMPAIGN\_GMB', 'TYPE\_REVIEW', 'TYPE\_INSTAGRAM', 'TYPE\_WHATSAPP', 'TYPE\_CUSTOM\_SMS', 'TYPE\_CUSTOM\_EMAIL', 'TYPE\_CUSTOM\_PROVIDER\_SMS', 'TYPE\_CUSTOM\_PROVIDER\_EMAIL', 'TYPE\_IVR\_CALL', 'TYPE\_ACTIVITY\_CONTACT', 'TYPE\_ACTIVITY\_INVOICE', 'TYPE\_ACTIVITY\_PAYMENT', 'TYPE\_ACTIVITY\_OPPORTUNITY', 'TYPE\_LIVE\_CHAT', 'TYPE\_LIVE\_CHAT\_INFO\_MESSAGE', 'TYPE\_ACTIVITY\_APPOINTMENT', 'TYPE\_FACEBOOK\_COMMENT', 'TYPE\_INSTAGRAM\_COMMENT', 'TYPE\_CUSTOM\_CALL', 'TYPE\_INTERNAL\_COMMENT', 'TYPE\_ACTIVITY\_EMPLOYEE\_ACTION\_LOG', 'TYPE\_TIKTOK', 'TYPE\_TIKTOK\_COMMENT', 'TYPE\_ACTIVITY\_WHATSAPP', 'TYPE\_FORM\_SUBMISSION', 'TYPE\_SMS\_REACTION'
      </ResponseField>

      <ResponseField name="type" type="string" required default="TYPE_PHONE">
        Primary channel/type of the conversation (Phone, Email, etc) Posibles valores: 'TYPE\_PHONE', 'TYPE\_EMAIL', 'TYPE\_FB\_MESSENGER', 'TYPE\_REVIEW', 'TYPE\_GROUP\_SMS'
      </ResponseField>

      <ResponseField name="unreadCount" type="number" required default="1">
        Number of unread messages in this conversation
      </ResponseField>

      <ResponseField name="fullName" type="string" required default="John Doe">
        Complete name of the contact (first and last name)
      </ResponseField>

      <ResponseField name="contactName" type="string" required default="John Doe Company">
        Alternative display name for the contact - used when full name is not available
      </ResponseField>

      <ResponseField name="email" type="string" required default="johndoe@mailingdomain.com">
        Primary email address of the contact
      </ResponseField>

      <ResponseField name="phone" type="string" required default="+15550001234">
        Primary phone number of the contact
      </ResponseField>
    </Expandable>
  </ResponseField>

  <ResponseField name="total" type="number" required default="100">
    Total Number of results found for the given query
  </ResponseField>

  ```json theme={null}
  {
    "conversations": [
      {
        "id": "ABCHkzuJQ8ZMd4Te84GK",
        "contactId": "ABCHkzuJQ8ZMd4Te84GK",
        "locationId": "ABCHkzuJQ8ZMd4Te84GK",
        "lastMessageBody": "This is a sample message body",
        "lastMessageType": "TYPE_SMS",
        "type": "TYPE_PHONE",
        "unreadCount": 1,
        "fullName": "John Doe",
        "contactName": "John Doe Company",
        "email": "johndoe@mailingdomain.com",
        "phone": "+15550001234"
      }
    ],
    "total": 100
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET 'https://services.leadconnectorhq.com/conversations/search' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/conversations/search', {
    method: 'GET',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
    },
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'GET',
      'https://services.leadconnectorhq.com/conversations/search',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
      },
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/conversations/search');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'GET',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
      ],
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
