> For the complete documentation index, see [llms.txt](https://40factory.gitbook.io/wilson/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://40factory.gitbook.io/wilson/3.11/rest-api/chat/list-chat-messages.md).

# List chat messages

## Request <a href="#request" id="request"></a>

### Url

```
GET 
https://wilson.40mat.com/apif/v2/chat/<chat_id>/messages
```

### Headers

<pre><code><strong>AUTH
</strong>Bearer "eyJ0eXAiOiJKV1QiLCJub25jZSI6IndUZXphSTNjdTNVYj..."
</code></pre>

### Parameters

* `size` (integer): The maximum number of messages to be returned. \
  Default = 1.&#x20;
* `timestamp` (string): The timestamp to filter messages. \
  Default = \<now>.&#x20;

### Body

```
No body is required for this endpoint.
```

***

## Response&#x20;

The response will be a JSON object with `history`  property.

History is an array containing `message` objects with the following properties:

* `actor` (string): Can be `wilson` or `user`. Is the autor of the message.&#x20;
* `chat_id` (string): The unique ID of the chat.&#x20;
* `sources` (string): Array of sources used. Each source have the following properties:
  * `description` (string): Description of document.
  * `filename` (string): Filename of document.
  * `page` (string): Page number of document referred.
  * `page_content` (string): An excerpt from the document&#x20;
  * `tags` (array): An array of tags of document.
  * `usage_score` (number): Score assigned to the document portion.&#x20;
* `tags` (string): A string in JSON format. Contain the array of tags used in message. \
  Each tag is an object with key = path and value = array of tags in that path.
* `text` (string): Textual content of message.&#x20;
* `time` (datetime): Timestamp of message.&#x20;

```json
{
    "history": [
        {
            "actor": "wilson",
            "chat_id": "66719d6ee7b5d6539843b13b",
            "sources": [{
                "description": "This document is useful for ...",
                "filename": "/example_document.pdf",
                "page": 2,
                "page_content": "document useful...",
                "tags": ["Example", "Maintenance"],
                "usage_score": 8
            }],
            "tags": "[{\"/\": [\"Example\"]}]",
            "text": "Hello, I'm Wilson, your assistant for Industrial IoT solutions, industrial machines, and automation components.",
            "time": "2024-05-16T09:12:53.761241Z"
        }
    ]
}
```

***

## Code example

{% tabs %}
{% tab title="Python" %}

```python
import requests

url = "https://wilson.40mat.com/apif/v2/chat/<chat_id>/messages?size=50"

payload = {}

headers = {
  'Authorization': '••••••'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="cURL" %}

```powershell
curl --location 'https://wilson.40mat.com/apif/v2/chat/<chat_id>/messages?size=50' \
--header 'Authorization: ••••••'
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://40factory.gitbook.io/wilson/3.11/rest-api/chat/list-chat-messages.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
