> ## 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.

# 查看会话详情

> 查看单个会话，并返回其最近事件的一页（向更早方向分页）。

## 限制说明

| 项目   | 说明                                     |
| ---- | -------------------------------------- |
| 速率限制 | 每个 `app_key` **1,000 次/分钟**；**50 次/秒** |
| 权限要求 | 无 —— 持有有效的 `app_key` 即可调用              |

## 使用说明

* 使用上一次响应的 `search_after_ctx` 翻阅更早的历史。
* `limit`（或旧版 `num_recent_events`）限制事件页大小；默认 100，最大 1000。


## OpenAPI

````yaml /api-reference/safari.openapi.zh.json post /safari/session/get
openapi: 3.1.0
info:
  title: Flashduty 开放 API
  description: >-
    Flashduty AI SRE 平台的公开 HTTP API —— 技能、MCP 服务器（连接器）、A2A 智能体与会话。所有接口均使用
    Flashduty 控制台签发的 `app_key` 查询参数进行认证。
  version: 1.0.0
servers:
  - url: https://api.flashcat.cloud
    description: Flashduty Open API
security:
  - AppKeyAuth: []
tags:
  - name: AI SRE/技能
  - name: AI SRE/MCP 服务器
  - name: AI SRE/A2A 智能体
  - name: AI SRE/会话
  - name: AI SRE/自动化
paths:
  /safari/session/get:
    post:
      tags:
        - AI SRE/会话
      summary: 查看会话详情
      description: 查看单个会话，并返回其最近事件的一页（向更早方向分页）。
      operationId: session-read-info
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionGetRequest'
            example:
              session_id: sess_f8oDvqiG64uur6sBNsTc4u
              num_recent_events: 50
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ResponseEnvelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/SessionGetResponse'
              example:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                data:
                  session:
                    session_id: sess_f8oDvqiG64uur6sBNsTc4u
                    session_name: Investigate cloud-assistant first heartbeat
                    app_name: ai-sre
                    entry_kind: web
                    person_id: '3790925372131'
                    team_id: 0
                    is_mine: false
                    can_manage: true
                    status: enabled
                    incognito: false
                    created_at: 1780367971228
                    updated_at: 1780367993457
                    token_usage:
                      input_tokens: 14948
                      cached_tokens: 11520
                      output_tokens: 888
                      reasoning_tokens: 351
                    current_context_tokens: 14948
                    context_window: 0
                    archived_at: 0
                    pinned_at: 0
                    last_event_at: 1780367992649
                    is_running: false
                    has_unread: true
                  events:
                    - event_id: evt_3aZQ9p
                      session_id: sess_f8oDvqiG64uur6sBNsTc4u
                      author: user
                      partial: false
                      turn_complete: false
                      status: normal
                      created_at: 1780367971241
                    - event_id: evt_7bWk2r
                      session_id: sess_f8oDvqiG64uur6sBNsTc4u
                      author: ai-sre
                      content:
                        role: model
                        parts:
                          - text: ...
                      partial: false
                      turn_complete: true
                      status: normal
                      created_at: 1780367992649
                  has_more_older: false
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
      security:
        - AppKeyAuth: []
components:
  schemas:
    SessionGetRequest:
      type: object
      description: 查询单个会话，并返回其最近事件的一页（向更早方向分页）。
      properties:
        session_id:
          type: string
          description: 目标会话 ID。
          minLength: 1
        num_recent_events:
          type: integer
          description: 旧版每页数量：返回的最近事件数。与 `limit` 同时设置时以 `limit` 为准；0 使用服务端默认值（100）。
          minimum: 0
          maximum: 1000
        limit:
          type: integer
          description: 事件每页数量；优先于 `num_recent_events`。0 使用服务端默认值（100）。
          minimum: 0
          maximum: 1000
        search_after_ctx:
          type: string
          description: 上一次响应返回的不透明游标；回传以获取更早的一页。
          maxLength: 4096
      required:
        - session_id
    ResponseEnvelope:
      type: object
      description: >-
        Standard response envelope used by every Flashduty public API. On
        success `data` contains the endpoint-specific payload and `error` is
        absent. On failure `error` is present and `data` is absent. `request_id`
        is always present and is also mirrored in the `Flashcat-Request-Id`
        response header.
      properties:
        request_id:
          type: string
          description: >-
            Unique ID for this request. Mirrored in the Flashcat-Request-Id
            header. Include it when reporting issues.
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
        data:
          description: Endpoint-specific payload. See each operation's 200 response schema.
      required:
        - request_id
    SessionGetResponse:
      type: object
      description: 一个会话及其事件的一页（向更早方向分页）。
      properties:
        session:
          $ref: '#/components/schemas/SessionItem'
        events:
          type: array
          items:
            $ref: '#/components/schemas/EventItem'
          description: 最近事件，按 (created_at, event_id) 升序排列。
        has_more_older:
          type: boolean
          description: 当本页之外仍有更早的事件时为 true。
        search_after_ctx:
          type: string
          description: 不透明游标；作为 search_after_ctx 回传以获取更早的一页。has_more_older 为 false 时省略。
    DutyError:
      type: object
      description: >-
        Error payload inside the response envelope. Present only on non-2xx
        responses.
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: >-
            Human-readable error message, localized by the caller's
            Accept-Language. May contain field names, IDs, or other context from
            the failing request.
      required:
        - code
        - message
    SessionItem:
      type: object
      description: 单条智能体会话记录。
      properties:
        session_id:
          type: string
          description: 会话标识。
        parent_session_id:
          type: string
          description: 子智能体（子）会话的父会话 ID；否则为空。
        session_name:
          type: string
          description: 会话标题；未命名会话可能为空。
        app_name:
          type: string
          description: 拥有该会话的智能体应用。
        entry_kind:
          type: string
          description: 创建该会话的入口来源。
          enum:
            - web
            - im
            - api
            - scheduled
            - subagent
        person_id:
          type: string
          description: 创建者人员 ID。
        team_id:
          type: integer
          format: int64
          description: 所属团队 ID；0 表示未绑定团队。创建后不可变更。
        team_name:
          type: string
          description: 解析出的团队名称；未绑定或团队已删除时为空。
        is_mine:
          type: boolean
          description: 当该会话由调用者创建时为 true。
        can_manage:
          type: boolean
          description: 当调用者可重命名/归档/删除该会话时为 true。
        status:
          type: string
          description: 生命周期状态。
          enum:
            - enabled
            - deleted
        incognito:
          type: boolean
          description: 无痕（不持久化记忆）会话时为 true。
        created_at:
          type: integer
          format: int64
          description: 会话创建时间，Unix 毫秒时间戳。
        updated_at:
          type: integer
          format: int64
          description: 会话最近更新时间，Unix 毫秒时间戳。
        template_staging_round_id:
          type: string
          description: 当前 save→validate 轮次 ID（仅 template-assistant）；否则为空。
        state:
          type: object
          additionalProperties: true
          description: 原始会话状态包（会话级键）。为空时省略。
        bound_environment:
          $ref: '#/components/schemas/EnvironmentBinding'
        context_resolved:
          $ref: '#/components/schemas/ContextResolvedItem'
        token_usage:
          $ref: '#/components/schemas/SessionTokenUsage'
        current_context_tokens:
          type: integer
          format: int64
          description: 截至最近一轮的 LLM 上下文窗口的 token 数。0 表示尚无已完成的轮次。
        context_window:
          type: integer
          format: int64
          description: 所绑定模型的最大上下文 token 数。0 表示未知。
        archived_at:
          type: integer
          format: int64
          description: 归档时间，Unix 毫秒时间戳；0 表示未归档。
        pinned_at:
          type: integer
          format: int64
          description: 调用者的个人置顶时间，Unix 毫秒时间戳；0 表示未置顶。
        last_event_at:
          type: integer
          format: int64
          description: 最近一条助手侧事件的时间，Unix 毫秒时间戳。
        is_running:
          type: boolean
          description: 当该会话当前有正在进行的智能体轮次时为 true。
        has_unread:
          type: boolean
          description: 当存在调用者尚未查看的助手输出时为 true。
    EventItem:
      type: object
      description: 单条已持久化的会话事件。content/actions/usage_metadata 携带原始 ADK 信封，请将其视为不透明的结构化负载。
      properties:
        event_id:
          type: string
          description: 事件标识。
        session_id:
          type: string
          description: 所属会话 ID。
        invocation_id:
          type: string
          description: 标识一轮的 ADK 调用 ID。
        author:
          type: string
          description: 事件作者（如 user 或智能体名称）。
        branch:
          type: string
          description: 嵌套智能体的 ADK 分支路径。
        content:
          type: object
          additionalProperties: true
          description: ADK content 信封 {role, parts:[...]}。
        actions:
          type: object
          additionalProperties: true
          description: ADK actions 信封（状态增量、转移、升级）。
        usage_metadata:
          type: object
          additionalProperties: true
          description: 单轮 token 用量元数据。
        partial:
          type: boolean
          description: 流式部分分片时为 true。
        turn_complete:
          type: boolean
          description: 一轮的终止事件上为 true。
        error_code:
          type: string
          description: 当该事件表示失败时的错误码。
        error_message:
          type: string
          description: 可读的错误信息（如有）。
        status:
          type: string
          description: 事件状态。
          enum:
            - normal
            - compressed
        created_at:
          type: integer
          format: int64
          description: 事件写入时间，Unix 毫秒时间戳。
    ErrorResponse:
      type: object
      description: Response envelope for errors. `error` is required; `data` is absent.
      properties:
        request_id:
          type: string
          example: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
        error:
          $ref: '#/components/schemas/DutyError'
      required:
        - request_id
        - error
    ErrorCode:
      type: string
      description: >-
        Flashduty error code enum. Every failed API response sets `error.code`
        to one of these values. The value is a stable wire string — not a
        localized message and not a numeric status. HTTP status is
        informational.
      enum:
        - OK
        - InvalidParameter
        - BadRequest
        - InvalidContentType
        - ResourceNotFound
        - NoLicense
        - ReferenceExist
        - Unauthorized
        - BalanceNotEnough
        - AccessDenied
        - RouteNotFound
        - MethodNotAllowed
        - UndonedOrderExist
        - RequestLocked
        - EntityTooLarge
        - RequestTooFrequently
        - RequestVerifyRequired
        - DangerousOperation
        - InternalError
        - ServiceUnavailable
    EnvironmentBinding:
      type: object
      description: 会话绑定的 runner 或云沙箱。首条消息前为 null。
      properties:
        kind:
          type: string
          description: 环境类型（如 runner、sandbox）。
        id:
          type: string
          description: 环境标识。
        name:
          type: string
          description: 可读的环境名称。
        status:
          type: string
          description: 绑定状态。
    ContextResolvedItem:
      type: object
      description: 该会话三层知识包解析结果的快照。
      properties:
        account_pack_id:
          type: string
          description: 解析出的账户级知识包 ID。
        team_pack_id:
          type: string
          description: 解析出的团队级知识包 ID。
        incident_id:
          type: string
          description: 作战室来源时绑定的故障 ID。
        resolved_at_ms:
          type: integer
          format: int64
          description: 知识包解析时间，Unix 毫秒时间戳。
        versions:
          type: object
          additionalProperties:
            type: integer
          description: 各知识包解析版本映射。
    SessionTokenUsage:
      type: object
      description: 跨所有轮次的会话级 token 累计汇总。账户计费的权威来源。
      properties:
        input_tokens:
          type: integer
          format: int64
          description: 提示（输入）token 总数，含缓存部分。
        cached_tokens:
          type: integer
          format: int64
          description: input_tokens 中由提示缓存命中的部分。
        output_tokens:
          type: integer
          format: int64
          description: 生成（输出）token 总数。
        reasoning_tokens:
          type: integer
          format: int64
          description: 推理/思考 token 总数。
  responses:
    BadRequest:
      description: Invalid request — usually a missing or malformed parameter.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missingParameter:
              summary: Missing required parameter
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: InvalidParameter
                  message: The specified parameter skill_id is not valid.
    Unauthorized:
      description: Missing or invalid 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: Rate limit hit. Either the global API limit or a per-account limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rateLimited:
              value:
                request_id: 01HK8XQE3Z7JM2NTFQ5YJ8P9R4
                error:
                  code: RequestTooFrequently
                  message: Request too frequently.
    ServerError:
      description: Unexpected server-side error. Include the request_id when reporting.
      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: >-
        App key issued from the Flashduty console. Required on every public API
        call. Keep it secret — it grants the same access as the owning account.

````