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

# 获取会话指标

> 获取 Enterprise 账户的会话指标汇总。

可选地根据 playbook_id 进行过滤，仅返回使用特定 playbook 创建的会话指标。

<div id="permissions">
  ## 权限
</div>

需要一个在 Enterprise 层级拥有 `ViewAccountMetrics` 权限的服务用户。


## OpenAPI

````yaml zh/v3-openapi.yaml GET /v3/enterprise/metrics/sessions
openapi: 3.1.0
info:
  description: 采用 Service User 身份验证和 RBAC 的 Devin v3 API
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3/enterprise/metrics/sessions:
    get:
      tags:
        - metrics
      summary: 获取会话指标
      description: |-
        获取 Enterprise 账户的会话指标汇总。

        可选地根据 playbook_id 进行过滤，仅返回使用特定 playbook 创建的会话指标。
      operationId: handle_get_session_metrics_v3_enterprise_metrics_sessions_get
      parameters:
        - in: query
          name: user_ids
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: User Ids
        - in: query
          name: service_user_ids
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Service User Ids
        - in: query
          name: time_before
          required: true
          schema:
            title: Time Before
            type: integer
        - in: query
          name: time_after
          required: true
          schema:
            title: Time After
            type: integer
        - in: query
          name: org_ids
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Org Ids
        - in: query
          name: playbook_id
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Playbook Id
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionMetricsResponse'
          description: 成功响应
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: 验证错误
components:
  schemas:
    SessionMetricsResponse:
      description: 用于会话指标的响应模型。
      properties:
        avg_acus_per_session:
          title: Avg Acus Per Session
          type: number
        sessions_created_by_origin:
          $ref: '#/components/schemas/SessionCountsByOrigin'
        sessions_created_by_size:
          $ref: '#/components/schemas/SessionCountsBySize'
        sessions_created_count:
          title: Sessions Created Count
          type: integer
        sessions_created_with_playbook_count:
          title: Sessions Created With Playbook Count
          type: integer
        sessions_created_with_search_count:
          title: Sessions Created With Search Count
          type: integer
        sessions_with_merged_prs_by_size:
          $ref: '#/components/schemas/SessionCountsBySize'
        sessions_with_merged_prs_count:
          title: Sessions With Merged Prs Count
          type: integer
      required:
        - sessions_created_count
        - sessions_created_by_size
        - sessions_created_by_origin
        - sessions_created_with_playbook_count
        - sessions_created_with_search_count
        - sessions_with_merged_prs_count
        - sessions_with_merged_prs_by_size
        - avg_acus_per_session
      title: SessionMetricsResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    SessionCountsByOrigin:
      description: |-
        按来源类型划分的会话计数，通过 v3 metrics API 提供。

        这是 `SessionOrigin` 的一个精选子集：旧版来源（cli、
        vscode_extension、devin_spaces）会被有意隐藏，不对外暴露。
        对于数据库来源为 `scheduled` 的会话，其计数会通过规范的 `db_origin_to_api` 映射并入
        `automation`，因为 `automation` 是 `schedule` 将迁移到的超集。
      properties:
        api:
          default: 0
          title: Api
          type: integer
        automation:
          default: 0
          title: Automation
          type: integer
        code_scan:
          default: 0
          title: Code Scan
          type: integer
        desktop:
          default: 0
          title: Desktop
          type: integer
        jira:
          default: 0
          title: Jira
          type: integer
        linear:
          default: 0
          title: Linear
          type: integer
        slack:
          default: 0
          title: Slack
          type: integer
        teams:
          default: 0
          title: Teams
          type: integer
        webapp:
          default: 0
          title: Webapp
          type: integer
      title: SessionCountsByOrigin
      type: object
    SessionCountsBySize:
      description: 按规模分类的会话数量。
      properties:
        l:
          default: 0
          title: L
          type: integer
        m:
          default: 0
          title: M
          type: integer
        s:
          default: 0
          title: S
          type: integer
        xl:
          default: 0
          title: Xl
          type: integer
        xs:
          default: 0
          title: Xs
          type: integer
      title: SessionCountsBySize
      type: object
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    bearerAuth:
      description: 服务用户凭据（前缀：cog_）
      scheme: bearer
      type: http

````