# List

## <mark style="color:blue;">GET</mark> api/v1/message/list

* Note: To query the list of messages inside a group. It is sorted by reverse order according to timestamps of the messages. Only current group members have access.
* Header

| Field         | Type   | Remarks                                                                                |
| ------------- | ------ | -------------------------------------------------------------------------------------- |
| ApiKey        | String | [ApiKey](/relation-one-api/guide/glossary.md#apikey) acquired from the admin           |
| Authorization | String | Bearer ${unifiedAuthToken} , in which the unifiedAuthToken is returned by /api/v1/auth |

* Request Parameters

| Field        | Type   | Remarks                                                                                                                   |
| ------------ | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| channelUuid  | String | Optional. It stand for the group chat's UUID. "toRelationId" and channelUuid should at least have one non-null value.     |
| toRelationId | String | Optional. It stand for the receiver's relationId. "toRelationId" and channelUuid should at least have one non-null value. |
| maxCreateAt  | Long   | timestamp(ms). It must bigger than or equal to the last message sent in this page.                                        |
| limit        | int    | How much data should be returned per page                                                                                 |

* Request Example

```shell
curl POST 'https://api.relationlabs.ai/api/v1/message/list?channelUuid=4f326124812c41448bc587bf6b2eaf42&maxCreateAt=1665370135000&limit=10' \
--header 'ApiKey: <ApiKey>' \
--header 'Authorization: bearer eyJhbGciO1iJFUzI1NiJ9.eyJqdGkiOiI0MzdiN2EzZDEwMGY0ODVkOWVhMWUzZmZlOWE1NmEyZSIsImlzcyI6InJlbGF0aW9ubGFicy5haSIsImlhdCI6MTY2NTIxNTUzNSwic3ViIjoiZGhreXEtc3FhYWEtYWFhYWotc2d6M3EtY2FpIiwiZXhwIjoxNjY1ODI1wMzM1fQ.rj7KKuIcgmvaIwZ63YHnXQ4jvvI-eR2Wo7k3YEyzMux1o8j5ezCowKDpcW0u9zIuHPFqwD0-1XPWdPLR1d1HLFw'
```

* Response Parameters

| Field | Type                | Remarks            |
| ----- | ------------------- | ------------------ |
| code  | String              | the Return Code    |
| desc  | String              | the Return Message |
| data  | Array\[MessageInfo] | the data           |

The MessageInfo field consists of the following subfields:

| Field       | Type        | Remarks                                                             |
| ----------- | ----------- | ------------------------------------------------------------------- |
| id          | String      | The unique id of the message                                        |
| sendUuid    | String      | The uuid of the message. It is generated and managed by the client. |
| channelUuid | String      | the uuid of the group chat                                          |
| createAt    | String      | timestamp of the message (ms)                                       |
| type        | String      | message type                                                        |
| from        | String      | sender' relationId                                                  |
| fromName    | String      | sender's name                                                       |
| fromAvatar  | String      | sender's avatar                                                     |
| content     | String      | message content                                                     |
| quote       | MessageInfo | the quoted message                                                  |

* Response Body

```json
{
    "code": "0",
    "desc": "success",
    "data": [
        {
            "id": "1578671129496899586",
            "sendUuid": "8e7c082f-9a96-405a-b946-7f465048f354",
            "channelUuid": "4f326124812c41448bc587bf6b2eaf42",
            "createAt": "1665219502000",
            "type": "SYS",
            "from": "00000000000000000000000000000000",
            "fromName": null,
            "fromAvatar": null,
            "content": "0x1e56 created Group test-group",
            "quote": null
        }
        ...
    ]
}
```

* Return Code

| code  | desc              | Remarks                                                       |
| ----- | ----------------- | ------------------------------------------------------------- |
| 0     | success           | the flag for a successful request                             |
| 10112 | parameter error   | ChannelUuid and toRelationId cannot be null at the same time. |
| 10120 | permission denied | You don't have access.                                        |


---

# Agent Instructions: 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:

```
GET https://relationlabs.gitbook.io/relation-one-api/api/message/list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
