> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/cn/platform-service/zls/audit-logs/describelogs.md).

# DescribeLogs

## 1. 接口描述

本接口(DescribeLogs)用于查询审计日志列表。

## 2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

| 参数名称      | 必选 | 类型               | 描述                                                                                                                                                                             |
| --------- | -- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| startTime | 是  | String           | <p>开始时间。</p><p>时间格式：yyyy-MM-ddTHH<span data-gb-custom-inline data-tag="emoji" data-code="1f1f2-1f1f2">🇲🇲</span>ssZ。</p>                                                      |
| endTime   | 是  | String           | <p>结束时间。</p><p>时间格式：yyyy-MM-ddTHH<span data-gb-custom-inline data-tag="emoji" data-code="1f1f2-1f1f2">🇲🇲</span>ssZ。</p><p>开始时间不能大于结束时间；开始时间和结束时间的间隔不能超过30天；开始时间不能超过90天前。</p> |
| cursor    | 否  | Array of Integer | <p>下一页的游标。</p><p>当请求完该页数据后，响应结果中会返回下一页的游标，当需要获取下一页数据时，请求参数需要加上该页返回的游标，依次循环，可以获取到该段时间内的所有数据。</p><p>例如：请求当页返回： "cursor": \[1691028715371]，请求下一页时将\[1691028715371]赋值给cursor。</p>  |
| resUid    | 否  | String           | 资源ID。                                                                                                                                                                          |
| resEvent  | 否  | String           | 事件名称。                                                                                                                                                                          |
| clientIP  | 否  | String           | 客户端操作IP。                                                                                                                                                                       |
| size      | 否  | Integer          | <p>返回的分页大小。</p><p>默认为20，最大为1000。</p><p>可选值范围：\[1, 1000]</p>                                                                                                                    |

## 3. 响应结果

| 参数名称      | 类型                                                                                                                   | 描述                                                                                                                                                                            |
| --------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| requestId | String                                                                                                               | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p>                                                                                                                      |
| dataSet   | Array of [LogInfo](https://docs.console.zenlayer.com/api-reference/cn/platform-service/zls/datastructure.md#loginfo) | 结果集。                                                                                                                                                                          |
| cursor    | Array of Integer                                                                                                     | <p>下一页的游标。</p><p>当请求完该页数据后，响应结果中会返回下一页的游标，当需要获取下一页数据时，请求参数需要加上该页返回的游标，依次循环，可以获取到该段时间内的所有数据。</p><p>例如：请求当页返回： "cursor": \[1691028715371]，请求下一页时将\[1691028715371]赋值给cursor。</p> |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}
**1. 查询指定时间范围内的审计日志。**

```json
POST /api/v2/zls HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: DescribeLogs
<Common Request Params>

Request：
{
    "startTime": "2023-07-26T16:00:00Z",
    "endTime": "2023-08-03T15:59:59Z",
    "size": 20
}

Response：
{
  "requestId": "T83B6A963-B111-4BF9-8466-1C3351E2DFD1",
  "response": {
    "requestId": "T83B6A963-B111-4BF9-8466-1C3351E2DFD1",
    "dataSet": [
      {
        "resUid": "user/*|team/123",
        "resType": "user",
        "resEvent": "switch  team",
        "opsTime": "2023-08-03T07:56:28.670Z",
        "eventSource": "CONSOLE_CALL",
        "apiVersion": "v1",
        "opsUser": "test@zenlayer.com",
        "clientIP": "10.88.61.84",
        "request": null,
        "response": "{\"msg\":\"success\",\"ret\":0,\"code\":\"SUCCESS\",\"success\":true}"
      },
      {
        "resUid": "bmi/123",
        "resType": "bmi",
        "resEvent": "rename bmi",
        "opsTime": "2023-08-03T06:52:23.008Z",
        "eventSource": "CONSOLE_CALL",
        "apiVersion": "v1",
        "opsUser": "test@zenlayer.com",
        "clientIP": "10.88.61.100",
        "request": "{\"label\":\"xxx\"}",
        "response": "{\"msg\":\"success\",\"ret\":0,\"code\":\"SUCCESS\",\"success\":true}"
      }
    ],
    "cursor": [1691028715371]
  }
}
```

{% endtab %}
{% endtabs %}

## 5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的[开发工具集（SDK）](https://docs.console.zenlayer.com/api-reference/cn/api-introduction/toolkit.md)，未来会陆续支持更多开发语言，方便快速接入和使用Zenlayer的产品和服务。

## 6. 错误码

下面包含业务逻辑中遇到的错误码，其他错误码见[公共错误码](https://docs.console.zenlayer.com/api-reference/cn/api-introduction/instruction/commonerrorcode.md)

| HTTP状态码 | 错误码                                          | 说明                                                      |
| ------- | -------------------------------------------- | ------------------------------------------------------- |
| 400     | INVALID\_TIME\_FORMAT                        | 时间参数格式非法。时间参数不符合格式：yyyy-MM-ddTHH:flag\_mm:ssZ。          |
| 400     | INVALID\_PARAMETER\_ILLEGAL\_TIME            | 时间参数数据非法。开始时间不能大于结束时间；开始时间和结束时间的间隔不能超过30天；开始时间不能超过90天前。 |
| 400     | INVALID\_PARAMETER\_\_TEAM\_CANNOT\_BE\_NULL | 团队ID不能为空。                                               |
