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

# 查询审计日志

> 查询组织内的审计事件（控制台管理操作、登录事件与 Admin API 操作），按事件时间倒序返回，游标分页。

> [!NOTE]
>
> 本接口要求 Admin Key 具备 `audit:read` 作用域。
>
> 审计日志按组织开关启用：组织管理员在「控制台 → 组织管理 → Admin Key 管理 → 审计日志卡片」开启。未开启时本接口返回空列表（与「没有事件」同形，无法区分）。开启后事件自开启时点起可查：开启前不回溯，关闭期间的空白不可恢复。每次调用本接口自身也会记录一条 `audit_log.read` 审计事件。


## OpenAPI

````yaml GET /v1/admin/organizations/audit_logs
openapi: 3.0.3
info:
  title: Kimi Admin API
  version: 2026-10-20-beta
  description: >-
    ## 概览


    Kimi Admin API 让组织管理员通过接口管理成员、邀请、项目与推理 API 密钥，并查询账单、用量与审计日志——无需登录控制台。它是管理面
    API：Admin API 凭证不能调用任何推理端点，推理 API key 也不能调用本 API。


    服务地址为 `https://api.moonshot.cn/v1`。


    <Note>

    Admin API 当前处于 **Beta** 阶段，面向已完成企业认证的组织开放。在「控制台 → 组织管理 →
    组织认证」完成企业认证后，组织管理员即可在「组织管理 → Admin API Keys」自助创建 Admin Key。

    </Note>


    ## 身份验证


    以 Bearer 方式发送 Admin API secret（`sk-admin-*`）：


    ```sh

    curl https://api.moonshot.cn/v1/admin/organizations \
      --header "Authorization: Bearer $MOONSHOT_ADMIN_KEY"
    ```


    每个 Admin API 密钥 固定绑定一个组织；组织永远从 key 推导——结构上不可能跨组织访问。key 的持有者退出组织或被注销后，key 在
    30 秒内失效。secret 仅在创建或轮换时展示一次，请妥善保存。


    ## 作用域（scope）


    每个 Admin API 密钥 在创建时选定权限域：


    | scope | 类型 | 覆盖范围 |

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

    | `billing:read` | 只读 | 日/产品账单、请求明细、中断请求、账户余额、用量聚合 |

    | `org:read` | 只读 | 成员、邀请、项目、项目成员、推理 API 密钥 元数据、项目支出限额、组织速率限制 |

    | `org:write` | 写 | 成员/邀请/项目/推理 API 密钥 写操作（隐含 `org:read`，无需单独授权） |

    | `audit:read` | 只读 | 审计日志事件 |

    | `all` | 读+写 | 以上全部；未来新增权限域自动覆盖 |


    写端点额外要求 key 持有者在调用时仍是组织管理员，且适用更严格的限流（见下）。


    ## 速率限制


    | 类别 | 限制 |

    | --- | --- |

    | 读端点 | 60 次/分钟/组织 |

    | 写端点 | 20 次/分钟/组织 |

    | 请求明细、中断请求、用量聚合 | 5 并发/组织 |


    限流按「组织 × 端点」计数：同一组织下的所有 Admin Key 共享限额，多把 key 不会获得更高配额。超限返回 `429
    rate_limit_exceeded` / `concurrency_limit_exceeded`。


    ## 分页


    分页端点（日/产品账单、请求明细、中断请求、用量聚合、审计日志）使用游标分页：响应携带 `has_more` 与 `next`；将 `next` 作为
    `cursor` 查询参数传回即可翻页。页大小按端点：日/产品账单与用量聚合默认 100、最大 1000；请求明细与中断请求默认 100、最大
    10000；审计日志默认 20、最大 100。游标只携带页位置——翻页时请原样重复全部过滤参数。


    组织集合端点（成员、邀请、项目、项目成员、推理 API 密钥）一次性全量返回，无分页参数。协议之外的查询参数（如
    `page_size`）会被静默忽略，请核对参数名。


    ## 错误格式


    错误响应遵循统一格式：


    ```json

    {
      "error": {
        "type": "invalid_request_error",
        "code": "invalid_date_range",
        "message": "end must be greater than start.",
        "param": "end",
        "request_id": "..."
      }
    }

    ```


    `data_not_ready` 专用于账单类端点的数据就绪规则：T 日数据于 T+1 日 07:00（UTC+8）起可查。


    ## 数据口径


    - 金额单位为毫分（1 元 = 100,000 毫分）。

    - 查询参数中的时间为 epoch 毫秒；响应体中的时间为 RFC 3339（另有说明除外）。

    - 时间窗左闭右开、按 CST 日界；查询参数中的时间为 epoch 毫秒，响应体中的时间为 RFC
    3339（另有说明除外）。按秒传入会返回空数据而非报错，请核对单位为毫秒。

    - 账单数据 T-1 就绪：当日数据次日早 7:00 CST 起可查，之前返回 `400
    data_not_ready`；中断请求明细不受此限（近实时可查）。

    - 数据留存与窗口：日/产品账单留存 365 天；请求明细与中断请求留存 90 天、单次窗口 ≤31 天；审计日志单次窗口 ≤31
    天；用量聚合窗口按粒度分档（`1m` ≤24 小时、`1h` ≤31 天、`1d` ≤93 天）。

    - 每个组织最多同时持有 10 把未删除 Admin Key。
servers:
  - url: https://api.moonshot.cn
    description: 生产环境
security:
  - AdminBearerAuth: []
paths:
  /v1/admin/organizations/audit_logs:
    get:
      tags:
        - 审计日志
      summary: 查询审计日志
      description: 查询组织内的审计事件（控制台管理操作、登录事件与 Admin API 操作），按事件时间倒序返回，游标分页。
      operationId: listAuditLogsV2
      parameters:
        - $ref: '#/components/parameters/Start'
        - $ref: '#/components/parameters/End'
        - name: event_types
          in: query
          required: false
          schema:
            type: array
            items:
              $ref: '#/components/schemas/AuditEventType'
          style: form
          explode: true
          description: >-
            事件类型过滤。只返回 `event_type`
            属于本列表的事件。支持重复传参（`event_types=a&event_types=b`）或逗号拼接（`event_types=a,b`）。
        - name: actor_id
          in: query
          required: false
          schema:
            type: string
          description: 操作者 ID 过滤（uid 或 Admin Key ID）。
        - name: actor_type
          in: query
          required: false
          schema:
            type: string
            enum:
              - user
              - api_key
          description: 操作者类型过滤。
        - name: target_type
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/AuditTargetType'
          description: 对象类型过滤。
        - name: target_id
          in: query
          required: false
          schema:
            type: string
          description: 对象 ID 过滤。
        - name: result
          in: query
          required: false
          schema:
            type: string
            enum:
              - success
              - failed
          description: 结果过滤。
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: 页大小。默认 20，最大 100。
        - name: cursor
          in: query
          required: false
          schema:
            type: string
          description: >-
            上一次响应 `next` 字段返回的游标。游标只携带页位置；每次翻页都需原样重复全部查询参数（`limit`
            除外），服务端不校验参数一致性。
      responses:
        '200':
          description: 审计事件列表，按事件时间倒序。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditLogsResponse'
        '400':
          description: 请求参数错误（时间窗非法、枚举非法、limit/cursor 非法）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditErrorResponse'
        '401':
          description: 身份验证失败（Admin API key 无效、已删除/已过期，或 key 持有者已失效）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditErrorResponse'
        '403':
          description: 权限不足（Admin Key 缺少 audit:read 权限域）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditErrorResponse'
        '404':
          description: 资源不存在（组织无审计数据或游标指向不存在）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditErrorResponse'
        '429':
          description: 达到速率限制（每分钟请求数超限或并发超限）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditErrorResponse'
        '500':
          description: 服务内部错误（联系支持团队并提供 request_id）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuditErrorResponse'
      security:
        - AdminBearerAuth: []
components:
  parameters:
    Start:
      name: start
      in: query
      required: true
      schema:
        type: integer
        format: int64
        minimum: 0
      description: 起始时间（epoch 毫秒），含边界。例如 `1790784000000`（2026-10-01 00:00 CST）。
      example: 1790784000000
    End:
      name: end
      in: query
      required: true
      schema:
        type: integer
        format: int64
        minimum: 0
      description: 结束时间（epoch 毫秒），不含边界。例如 `1792598400000`（2026-10-22 00:00 CST）。
      example: 1792598400000
  schemas:
    AuditEventType:
      type: string
      enum:
        - api_key.created
        - api_key.updated
        - api_key.deleted
        - admin_api_key.created
        - admin_api_key.updated
        - admin_api_key.deleted
        - organization.member_invited
        - organization.member_joined
        - organization.member_role_updated
        - organization.member_removed
        - organization.ip_whitelist_updated
        - organization.audit_log_enabled
        - organization.audit_log_disabled
        - project.created
        - project.updated
        - project.archived
        - project.member_added
        - project.member_role_updated
        - project.member_removed
        - project.spend_limit_updated
        - project.rate_limit_updated
        - audit_log.read
        - auth.login_succeeded
        - auth.login_failed
      description: >-
        审计事件类型。枚举值可能随版本新增。


        | 值 | 含义 |

        | --- | --- |

        | `api_key.created` | 推理 API 密钥 创建。 |

        | `api_key.updated` | 推理 API 密钥 更新（改名/启停）。 |

        | `api_key.deleted` | 推理 API 密钥 删除（吊销）。 |

        | `admin_api_key.created` | Admin Key 创建（控制台自助签发）。 |

        | `admin_api_key.updated` | Admin Key 更新（名称/scopes/有效期）；轮换复用本事件，以
        `detail.action=rotate` 区分。 |

        | `admin_api_key.deleted` | Admin Key 删除（软删，列表置灰保留）。 |

        | `organization.member_invited` | 创建组织成员邀请。 |

        | `organization.member_joined` | 被邀请人接受邀请加入组织。 |

        | `organization.member_role_updated` | 组织成员角色变更（admin ↔ member）。 |

        | `organization.member_removed` | 组织成员被移除。 |

        | `organization.ip_whitelist_updated` | 组织 IP 白名单整体覆盖更新。 |

        | `organization.audit_log_enabled` | 组织审计日志开启（组织管理员操作）。 |

        | `organization.audit_log_disabled` | 组织审计日志关闭。 |

        | `project.created` | 项目创建。 |

        | `project.updated` | 项目更新（名称/描述）。 |

        | `project.archived` | 项目归档。 |

        | `project.member_added` | 项目成员加入（重复添加时更新角色，upsert 语义）。 |

        | `project.member_role_updated` | 项目成员角色变更。 |

        | `project.member_removed` | 项目成员被移除。 |

        | `project.spend_limit_updated` | 项目支出限额变更。 |

        | `project.rate_limit_updated` | 项目限速配置（TPM 维度）变更。 |

        | `audit_log.read` | 审计日志查询（自审计；每次调用 `GET audit_logs` 记录一条）。 |

        | `auth.login_succeeded` | 登录成功。 |

        | `auth.login_failed` | 登录失败（唯一保留的失败结果事件，用于安全审计）。 |
    AuditTargetType:
      type: string
      enum:
        - api_key
        - admin_api_key
        - member
        - project
        - invite
        - ip_whitelist
        - user
        - organization
        - audit_log
      description: |-
        审计事件对象类型。

        | 值 | 含义 |
        | --- | --- |
        | `api_key` | 推理 API 密钥（`ak-` 前缀）。 |
        | `admin_api_key` | Admin Key（`admk_` 前缀）。 |
        | `member` | 组织/项目成员（uid）。 |
        | `project` | 项目（`proj-` 前缀）。 |
        | `invite` | 邀请单。 |
        | `ip_whitelist` | 组织 IP 白名单。 |
        | `user` | 平台用户（登录事件主体）。 |
        | `organization` | 组织。 |
        | `audit_log` | 审计日志（自审计事件对象）。 |
    AuditLogsResponse:
      type: object
      required:
        - data
        - has_more
        - next
      additionalProperties: false
      properties:
        data:
          type: array
          description: 审计事件列表。
          items:
            $ref: '#/components/schemas/AuditLogEvent'
        has_more:
          type: boolean
          description: 是否还有下一页。
        next:
          type: string
          nullable: true
          description: 下一页游标。翻页时将其原样作为 `cursor` 参数传回。
    AuditErrorResponse:
      type: object
      required:
        - error
      additionalProperties: false
      properties:
        error:
          $ref: '#/components/schemas/AuditErrorBody'
    AuditLogEvent:
      type: object
      required:
        - id
        - event_type
        - organization_id
        - actor
        - result
        - created_at
      additionalProperties: false
      properties:
        id:
          type: string
          description: 事件 ID（`audit_<ms-hex><rand-hex>`，按时间有序）。
        event_type:
          $ref: '#/components/schemas/AuditEventType'
        organization_id:
          type: string
          description: 事件所属组织 ID。
        project_id:
          type: string
          nullable: true
          description: 事件关联的项目 ID；无关联项目为 null。
        actor:
          $ref: '#/components/schemas/AuditLogActor'
        target:
          $ref: '#/components/schemas/AuditLogTarget'
        result:
          type: string
          enum:
            - success
            - failed
          description: 操作结果。管理操作仅记录成功事件；登录失败（`auth.login_failed`）也会记录。
        error_code:
          type: string
          description: 当 `result` 为 `failed` 时的稳定错误码。
        error_message:
          type: string
          description: 当 `result` 为 `failed` 时截断的错误信息（最长 256 字符）。
        detail:
          type: object
          additionalProperties: true
          description: 事件附加信息（变更前后值、操作参数等，按事件类型裁剪，不含敏感信息）。
        created_at:
          type: string
          format: date-time
          description: 事件发生时间。
    AuditErrorBody:
      type: object
      required:
        - type
        - code
        - message
        - request_id
      additionalProperties: false
      properties:
        type:
          type: string
          example: invalid_request_error
        code:
          type: string
          description: 审计域错误码（子集）。
          enum:
            - invalid_request
            - invalid_date_range
            - date_range_too_large
            - invalid_cursor
            - invalid_api_key
            - api_key_inactive
            - insufficient_scope
            - resource_not_found
            - rate_limit_exceeded
            - concurrency_limit_exceeded
            - internal_server_error
        message:
          type: string
        param:
          type: string
          nullable: true
        request_id:
          type: string
    AuditLogActor:
      type: object
      required:
        - type
        - id
        - name
      additionalProperties: false
      properties:
        type:
          type: string
          enum:
            - user
            - api_key
          description: 操作者类型：`user` 平台用户、`api_key` Admin Key。
        id:
          type: string
          description: 操作者 ID（uid 或 Admin Key ID）；匿名（登录失败）时为空。
        name:
          type: string
          description: 事件发生时的名称快照（登录失败时为脱敏账号）。
        ip:
          type: string
          description: 操作来源 IP。
        user_agent:
          type: string
          description: 客户端 User-Agent。
    AuditLogTarget:
      type: object
      additionalProperties: false
      properties:
        type:
          $ref: '#/components/schemas/AuditTargetType'
        id:
          type: string
          description: 操作对象 ID。
        name:
          type: string
          description: 操作对象在事件发生时的名称快照。
  securitySchemes:
    AdminBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Admin API Secret (sk-admin-*)
      description: >-
        Authorization 请求头携带 Admin API secret 作为 Bearer 令牌，格式为 `Bearer
        sk-admin-***`。Admin Key 可在「控制台 → 组织管理 → Admin API Keys」创建。

````