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

# 检索审计日志

> 按时间范围返回游标分页的操作审计日志列表。

## 限制说明

| 项目   | 说明                             |
| ---- | ------------------------------ |
| 速率限制 | 每个账户 **1,000 次/分钟**；**50 次/秒** |
| 权限要求 | **审计查看**（`organization`）       |

## 使用说明

* 时间范围必填。最大跨度 90 天，`start_time` 和 `end_time` 均为 Unix 时间戳（**秒**）。
* 使用上次响应中的 `search_after_ctx` 获取下一页。该 token 是不透明的，请勿手动构造。
* 可查询的时间窗口受账户许可证限制，超出保留期的查询会静默返回空结果，而不是报错。
* 默认每页 20 条，最大 99 条。


## OpenAPI

````yaml /api-reference/platform.openapi.zh.json post /audit/search
openapi: 3.1.0
info:
  title: Flashduty 开放 API
  description: >-
    Flashduty 事件管理平台的公开 HTTP API —— 覆盖故障、通知模板、协作空间、值班排班、监控、RUM、以及平台管理。每次调用都需在
    query 中携带 `app_key`，该 key 在 Flashduty 控制台 账户 → APP Key 中签发。所有响应使用统一结构：成功时为
    `{ request_id, data }`，失败时为 `{ request_id, error }`。
  version: 1.0.0
servers:
  - url: https://api.flashcat.cloud
    description: Flashduty Open API
security:
  - AppKeyAuth: []
tags:
  - name: 平台/成员管理
    description: ''
  - name: 平台/团队管理
    description: ''
  - name: 平台/角色与权限
    description: ''
  - name: 平台/审计日志
    description: 检索和读取账户操作审计日志。
  - name: 平台/账户设置
    description: 账户（主体）信息与设置
paths:
  /audit/search:
    post:
      tags:
        - 平台/审计日志
      summary: 检索审计日志
      description: 按时间范围返回游标分页的操作审计日志列表。
      operationId: audit-read-search
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuditSearchRequest'
            example:
              start_time: 1712620800
              end_time: 1712707200
              limit: 20
              operations:
                - template:write:create
                - template:write:delete
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/SuccessEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/AuditSearchResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  total: 2
                  search_after_ctx: ''
                  docs:
                    - created_at: 1712700123456
                      account_id: 10023
                      member_id: 80011
                      member_name: Alice
                      request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                      ip: 203.0.113.42
                      operation: template:write:create
                      operation_name: 创建模板
                      body: '{"template_name":"生产默认模板"}'
                      params: []
                      is_dangerous: false
                      is_write: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    AuditSearchRequest:
      type: object
      description: 审计日志检索的过滤条件，时间范围必填。
      required:
        - start_time
        - end_time
      properties:
        start_time:
          type: integer
          format: int64
          description: 检索窗口开始时间，Unix 时间戳（秒）。
          example: 1712620800
        end_time:
          type: integer
          format: int64
          description: 检索窗口结束时间，Unix 时间戳（秒）。必须晚于 `start_time`，最大跨度 90 天。
          example: 1712707200
        limit:
          type: integer
          description: 每页条数。最小 0，最大 99。
          minimum: 0
          maximum: 99
          example: 20
        request_id:
          type: string
          description: 按唯一请求 ID 过滤到单条记录。
        search_after_ctx:
          type: string
          description: 上次响应返回的不透明分页游标。首页留空。
        operations:
          type: array
          items:
            type: string
          description: 按操作名称过滤。合法值可通过 `POST /audit/operation/list` 获取。
        person_id:
          type: integer
          format: uint64
          description: 按操作人成员 ID 过滤。
        is_dangerous:
          type:
            - boolean
            - 'null'
          description: 为 true 时只返回高危操作。
        is_write:
          type:
            - boolean
            - 'null'
          description: 为 true 时只返回写操作；为 false 时只返回读操作。
    SuccessEnvelope:
      type: object
      description: >-
        成功响应结构。2xx 响应中 `request_id` 标识本次调用（同时出现在 `Flashcat-Request-Id`
        响应头中），`data` 为接口业务 payload。失败响应使用不同结构，参见 `ErrorResponse`。
      properties:
        request_id:
          type: string
          description: 本次请求的唯一 ID，也会在 Flashcat-Request-Id 响应头中返回。反馈问题时请一并附上。
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        data:
          description: 每个接口自己的业务 payload，详见各接口的 200 响应 schema。
      required:
        - request_id
        - data
    AuditSearchResponse:
      type: object
      description: 游标分页的审计日志检索结果。
      required:
        - total
        - search_after_ctx
      properties:
        total:
          type: integer
          format: int64
          description: 检索窗口内符合条件的总条数。
          example: 2
        search_after_ctx:
          type: string
          description: 用于获取下一页的不透明游标。没有更多结果时为空字符串。
        docs:
          type: array
          items:
            $ref: '#/components/schemas/AuditLog'
          description: 当前页的审计日志条目。
    AuditLog:
      type: object
      description: 单条审计日志。
      required:
        - created_at
        - account_id
        - member_id
        - member_name
        - request_id
        - ip
        - operation
        - operation_name
        - body
        - params
        - is_dangerous
        - is_write
      properties:
        created_at:
          type: integer
          format: int64
          description: 操作时间，Unix 毫秒时间戳。
        account_id:
          type: integer
          format: uint64
          description: 账户 ID。
        member_id:
          type: integer
          format: uint64
          description: 操作人的成员 ID。
        member_name:
          type: string
          description: 操作人的显示名称。
        request_id:
          type: string
          description: 用于关联的唯一请求 ID。
        ip:
          type: string
          description: 调用者的客户端 IP 地址。
        operation:
          type: string
          description: 稳定的机器可读操作名称，如 `template:write:create`。
        operation_name:
          type: string
          description: 按账户语种显示的人类可读操作标签。
        body:
          type: string
          description: JSON 编码的请求体（可能截断至 10 KB）。
        params:
          type: array
          items:
            type: object
            properties:
              Key:
                type: string
              Value:
                type: string
          description: URL 路径参数的键值对数组，无参数时为空数组。
        is_dangerous:
          type: boolean
          description: 是否被标记为高危操作。
        is_write:
          type: boolean
          description: 是否为写操作；false 表示只读操作。
    ErrorResponse:
      type: object
      description: 错误响应结构。`error` 必填，`data` 不存在。
      properties:
        request_id:
          type: string
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
      required:
        - request_id
        - error
    DutyError:
      type: object
      description: 响应结构中的错误 payload，仅在非 2xx 响应时出现。
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: 用户可读的错误描述，语言会跟随调用方的 Accept-Language。可能包含字段名、ID 等请求上下文。
          example: The specified parameter template_id is not valid.
      required:
        - code
        - message
    ErrorCode:
      type: string
      description: >-
        Flashduty 错误码枚举。每个失败响应的 `error.code` 都是下列稳定值之一，HTTP 状态码仅作参考。


        | 错误码 | HTTP | 含义 |

        |---|---|---|

        | `OK` | 200 | 保留值，正常错误响应不会返回。 |

        | `InvalidParameter` | 400 | 必填参数缺失或未通过校验。 |

        | `BadRequest` | 400 | 通用的 400 错误，通常是请求本身不合法。 |

        | `InvalidContentType` | 400 | 请求头 `Content-Type` 不是 `application/json`。
        |

        | `ResourceNotFound` | 400 | 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。 |

        | `NoLicense` | 400 | 功能需要有效授权，但未找到可用的 license。 |

        | `ReferenceExist` | 400 | 该资源仍被其他实体引用，无法删除。 |

        | `Unauthorized` | 401 | `app_key` 缺失、无效或已过期。 |

        | `BalanceNotEnough` | 402 | 账户余额不足，无法执行需要计费的操作。 |

        | `AccessDenied` | 403 | 身份认证通过，但 RBAC 权限不足以执行该操作。 |

        | `RouteNotFound` | 404 | 请求的 URL 路径不是已知路由。 |

        | `MethodNotAllowed` | 405 | 当前路径不接受所使用的 HTTP 方法。 |

        | `UndonedOrderExist` | 409 | 账户存在未完成的订单，请稍后重试。 |

        | `RequestLocked` | 423 | 因连续失败被临时锁定。 |

        | `EntityTooLarge` | 413 | 请求体超过允许的最大长度。 |

        | `RequestTooFrequently` | 429 | 命中限流（全局、账户级或集成级）。 |

        | `RequestVerifyRequired` | 428 | 操作需要二次验证码，但未提供。 |

        | `DangerousOperation` | 428 | 危险操作，需要进行 MFA 验证。 |

        | `InternalError` | 500 | 服务端未预期错误。反馈问题请附上 `request_id`。 |

        | `ServiceUnavailable` | 503 | 后端依赖不可用，请稍后重试。 |
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
      x-enumDescriptions:
        OK: 保留值，正常错误响应不会返回。
        InvalidParameter: 必填参数缺失或未通过校验。
        BadRequest: 通用的 400 错误，通常是请求本身不合法。
        InvalidContentType: 请求头 `Content-Type` 不是 `application/json`。
        ResourceNotFound: 目标资源不存在。注意 HTTP 状态码是 400 而非 404（历史设计）。
        NoLicense: 功能需要有效授权，但未找到可用的 license。
        ReferenceExist: 该资源仍被其他实体引用，无法删除。
        Unauthorized: '`app_key` 缺失、无效或已过期。'
        BalanceNotEnough: 账户余额不足，无法执行需要计费的操作。
        AccessDenied: 身份认证通过，但 RBAC 权限不足以执行该操作。
        RouteNotFound: 请求的 URL 路径不是已知路由。
        MethodNotAllowed: 当前路径不接受所使用的 HTTP 方法。
        UndonedOrderExist: 账户存在未完成的订单，请稍后重试。
        RequestLocked: 因连续失败被临时锁定。
        EntityTooLarge: 请求体超过允许的最大长度。
        RequestTooFrequently: 命中限流（全局、账户级或集成级）。
        RequestVerifyRequired: 操作需要二次验证码，但未提供。
        DangerousOperation: 危险操作，需要进行 MFA 验证。
        InternalError: 服务端未预期错误。反馈问题请附上 `request_id`。
        ServiceUnavailable: 后端依赖不可用，请稍后重试。
      example: InvalidParameter
  responses:
    BadRequest:
      description: 请求非法 — 通常是参数缺失或格式不正确。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingParameter:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InvalidParameter
                  message: The specified parameter is not valid.
    Unauthorized:
      description: app_key 缺失或无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingAppKey:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: Unauthorized
                  message: You are unauthorized.
    TooManyRequests:
      description: 命中限流。可能是全局 API 限流、账户级限流或集成级限流。限流按账户聚合。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
    ServerError:
      description: 服务端未预期错误。反馈问题时请携带 request_id。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            internal:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InternalError
                  message: >-
                    We encountered an internal error, and it has been reported.
                    Please try again later.
  securitySchemes:
    AppKeyAuth:
      type: apiKey
      in: query
      name: app_key
      description: >-
        在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API
        时都必须携带。它等同于所属账户的身份凭证，请妥善保管。

````