# 消息列表

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

* 说明：查询某个群组内的消息列表，根据消息发送时间倒序排列。仅当前群组内成员可查看。
* Header

| Field         | Type   | Remarks                                                                                        |
| ------------- | ------ | ---------------------------------------------------------------------------------------------- |
| ApiKey        | String | 从管理员获取的[ApiKey](https://relationlabs.gitbook.io/relation-one-api/api-zh/guide/glossary#apikey) |
| Authorization | String | Bearer ${unifiedAuthToken} ,其中unifiedAuthToken来自/api/v1/auth接口的返回                              |

* Request Parameters

| Field        | Type   | Remarks                                |
| ------------ | ------ | -------------------------------------- |
| channelUuid  | String | 选填，与toRelationId 至少有一个不为空。群组uuid       |
| toRelationId | String | 选填，与channelUuid 至少有一个不为空。对方的relationId |
| maxCreateAt  | long   | 时间戳，毫秒为单位。需要大于或等于当前页最后一条消息的发送时间        |
| limit        | int    | 每页返回的数据                                |

* 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              | 返回码     |
| desc  | String              | 返回信息    |
| data  | Array\[MessageInfo] | 数据      |

The MessageInfo field consists of the following subfields:

| Field       | Type        | Remarks           |
| ----------- | ----------- | ----------------- |
| id          | String      | 消息的唯一id           |
| sendUuid    | String      | 消息的uuid，由客户端生成维护  |
| channelUuid | String      | 群组的uuid           |
| createAt    | String      | 消息发送时间，时间戳（单位：毫秒） |
| type        | String      | 消息类型              |
| from        | String      | 发送者的relationId    |
| fromName    | String      | 发送者的名称            |
| fromAvatar  | String      | 发送者的头像            |
| content     | String      | 消息内容              |
| quote       | MessageInfo | 引用的消息             |

* 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           | 接口调用成功                         |
| 10112 | parameter error   | channelUuid和toRelationId不能同时为空 |
| 10120 | permission denied | 无权限查看                          |
