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

# Get messages by conversation id

> Get messages by conversation id.

Get messages by conversation id.

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

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

## Path parameters

<ParamField path="conversationId" type="string" required default="tDtDnQdgm2LXpyiqYvZ6">
  Conversation ID as string
</ParamField>

## Query parameters

<ParamField query="lastMessageId" type="string" default="tDtDnQdgm2LXpyiqYvZ6">
  Message ID of the last message in the list as a string
</ParamField>

<ParamField query="limit" type="number" default="20">
  Number of messages to be fetched from the conversation. Default limit is 20
</ParamField>

<ParamField query="type" type="string" default="TYPE_SMS,TYPE_CALL">
  Types of message to fetched separated with comma
</ParamField>

## Respuestas

<Accordion title="200 - List of messages for the conversation id of the given type.">
  <ResponseField name="lastMessageId" type="string" required default="p1mRSHeLDhAms5q0LMr4">
    Id of the last message in the messages array
  </ResponseField>

  <ResponseField name="nextPage" type="boolean" required default="True">
    Next page value true indicates only 20 message is in the response. Rest of the messages are in the next page. Please use the lastMessageId value in the query to get the next page messages
  </ResponseField>

  <ResponseField name="messages" type="object[]" required>
    Array of messages

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

      <ResponseField name="type" type="number" required default="1" />

      <ResponseField name="messageType" type="string" required default="SMS">
        Type of the message as a string 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="locationId" type="string" required default="ve9EPM428h8vShlRW1KT" />

      <ResponseField name="contactId" type="string" required default="ve9EPM428h8vShlRW1KT" />

      <ResponseField name="conversationId" type="string" required default="ve9EPM428h8vShlRW1KT" />

      <ResponseField name="dateAdded" type="string" required default="2024-03-27T18:13:49.000Z" />

      <ResponseField name="body" type="string" default="Hi there" />

      <ResponseField name="direction" type="string" required>
        Posibles valores: 'inbound', 'outbound'
      </ResponseField>

      <ResponseField name="status" type="string">
        Posibles valores: 'connected', 'delivered', 'failed', 'opened', 'pending', 'read', 'scheduled', 'sent', 'undelivered', 'clicked', 'opt\_out', 'queued'
      </ResponseField>

      <ResponseField name="contentType" type="string" required default="text/plain" />

      <ResponseField name="attachments" type="string[]">
        An array of attachment URLs. Attachments will be empty for Call and Voicemails, type 1 and 10. Please use get call recording API to fetch call recording and voicemails.
      </ResponseField>

      <ResponseField name="meta" type="object">
        <Expandable title="propiedades">
          <ResponseField name="callDuration" type="string" default="120">
            Call duration in seconds
          </ResponseField>

          <ResponseField name="callStatus" type="string" default="completed">
            Call status - can be pending, completed, answered, busy, no-answer, failed, canceled, or voicemail Posibles valores: 'pending', 'completed', 'answered', 'busy', 'no-answer', 'failed', 'canceled', 'voicemail'
          </ResponseField>

          <ResponseField name="email" type="object">
            meta will contain email, for message type 3 (email). messageIds is list of all email message ids under the message thread
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="source" type="string">
        Message source Posibles valores: 'workflow', 'bulk\_actions', 'campaign', 'api', 'app'
      </ResponseField>

      <ResponseField name="userId" type="string" default="ve9EPM428kjkvShlRW1KT">
        User Id
      </ResponseField>

      <ResponseField name="conversationProviderId" type="string" default="ve9EPM428kjkvShlRW1KT">
        Conversation Provider Id
      </ResponseField>

      <ResponseField name="chatWidgetId" type="string" default="67b0cc8cf14b19d85ace7s35">
        Chat Widget Id
      </ResponseField>
    </Expandable>
  </ResponseField>

  ```json theme={null}
  {
    "lastMessageId": "p1mRSHeLDhAms5q0LMr4",
    "nextPage": true,
    "messages": [
      {
        "id": "ve9EPM428h8vShlRW1KT",
        "type": 1,
        "messageType": "SMS",
        "locationId": "ve9EPM428h8vShlRW1KT",
        "contactId": "ve9EPM428h8vShlRW1KT",
        "conversationId": "ve9EPM428h8vShlRW1KT",
        "dateAdded": "2024-03-27T18:13:49.000Z",
        "body": "Hi there",
        "direction": "inbound",
        "status": "connected",
        "contentType": "text/plain",
        "attachments": [
          "string"
        ],
        "meta": {
          "callDuration": 120,
          "callStatus": "completed",
          "email": {
            "email": {
              "messageIds": [
                "ve9EPM428kjkvShlRW1KT",
                "ve9EPs1028kjkvShlRW1KT"
              ]
            }
          }
        },
        "source": "workflow",
        "userId": "ve9EPM428kjkvShlRW1KT",
        "conversationProviderId": "ve9EPM428kjkvShlRW1KT",
        "chatWidgetId": "67b0cc8cf14b19d85ace7s35"
      }
    ]
  }
  ```
</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/YOUR_conversationId/messages' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/conversations/YOUR_conversationId/messages', {
    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/YOUR_conversationId/messages',
      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/YOUR_conversationId/messages');
  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>
