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

# 📬 Get Messages

> Use these endpoints to retrieve historical messages either by contact or grouped by conversation.

## 🔽 `GET /api/public/ai-message/contact/{aiContactId}` – Get Messages by Contact

Returns all messages (inbound/outbound) associated with a specific contact.

Click to expand full details

### 🔹 URL

```
GET /api/public/ai-message/contact/{aiContactId}
```

***

### 🔹 Path Parameters

| Name          | Type   | Required | Description             |
| ------------- | ------ | -------- | ----------------------- |
| `aiContactId` | string | ✅        | The contact’s unique ID |

***

### 🔹 Headers

| Name        | Type   | Required | Description                    |
| ----------- | ------ | -------- | ------------------------------ |
| `x-api-key` | string | ✅        | Your API key for authorization |

***

### 🔹 Example Request

<CodeGroup>
  ```bash bash
  curl --request GET \
    'https://iris-backend-production.up.railway.app/api/public/ai-message/contact/contact_123' \
    --header 'x-api-key: YOUR_API_KEY'
  ```
</CodeGroup>

***

***

## 🔽 `GET /api/public/ai-message/contact/{aiContactId}/by-conversation` – Get Messages by Conversation

Fetches messages grouped by conversation for a specific contact. Each conversation includes a thread of related messages.

Click to expand full details

### 🔹 URL

```
GET /api/public/ai-message/contact/{aiContactId}/by-conversation
```

***

### 🔹 Path Parameters

| Name          | Type   | Required | Description             |
| ------------- | ------ | -------- | ----------------------- |
| `aiContactId` | string | ✅        | The contact’s unique ID |

***

### 🔹 Headers

| Name        | Type   | Required | Description                    |
| ----------- | ------ | -------- | ------------------------------ |
| `x-api-key` | string | ✅        | Your API key for authorization |

***

### 🔹 Example Request

<CodeGroup>
  ```bash bash
  curl --request GET \
    'https://iris-backend-production.up.railway.app/api/public/ai-message/contact/contact_123/by-conversation' \
    --header 'x-api-key: YOUR_API_KEY'
  ```
</CodeGroup>

***

***

[💻 WhatsApp API](/docs/whatsapp-api)

[👨🏽‍💻 Webchat](/docs/webchat)

Ask AI

* [Table of Contents](#)

* * [🔽 GET /api/public/ai-message/contact/\{aiContactId} – Get Messages by Contact](#-get-apipublicai-messagecontactaicontactid--get-messages-by-contact)
  * [🔽 GET /api/public/ai-message/contact/\{aiContactId}/by-conversation – Get Messages by Conversation](#-get-apipublicai-messagecontactaicontactidby-conversation--get-messages-by-conversation)
