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

# Get Messages

> Get messages from a lead

## Endpoint

<Card>
  <strong>GET</strong> `/backend/messages/{lead_id}`
</Card>

## Path Parameters

<ParamField path="lead_id" type="string" required>
  Lead ID
</ParamField>

## Query Parameters

<ParamField query="limit" type="integer" default="50">
  Number of messages to return
</ParamField>

<ParamField query="before" type="string">
  Get messages before this timestamp (ISO 8601)
</ParamField>

<ParamField query="after" type="string">
  Get messages after this timestamp (ISO 8601)
</ParamField>

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.leavo.ai/backend/messages/lead-uuid?limit=100" \
    -H "Authorization: Bearer your_api_key_here"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.leavo.ai/backend/messages/lead-uuid?limit=100', {
    headers: {
      'Authorization': 'Bearer your_api_key_here'
    }
  });
  ```
</CodeGroup>

## Response

```json theme={null}
{
  "success": true,
  "data": [
    {
      "id": "message-uuid-1",
      "content": "Hello, I would like information about the product",
      "role": "user",
      "type": "text",
      "timestamp": "2024-01-15T10:30:00Z",
      "status": "delivered"
    },
    {
      "id": "message-uuid-2",
      "content": "Hello! Of course, I'd be happy to help...",
      "role": "assistant",
      "type": "text",
      "timestamp": "2024-01-15T10:30:05Z",
      "status": "delivered"
    },
    {
      "id": "message-uuid-3",
      "content": null,
      "role": "user",
      "type": "image",
      "media_url": "https://storage.leavo.ai/messages/image.jpg",
      "timestamp": "2024-01-15T10:31:00Z",
      "status": "delivered"
    }
  ],
  "pagination": {
    "has_more": true,
    "oldest_timestamp": "2024-01-15T10:30:00Z"
  }
}
```

## Message Status

| Status      | Description            |
| ----------- | ---------------------- |
| `pending`   | Waiting to be sent     |
| `sent`      | Sent to provider       |
| `delivered` | Delivered to recipient |
| `read`      | Read by recipient      |
| `failed`    | Sending failed         |
