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

# コードスキャンのメトリクスを取得（Devin API）

> v3 API を使用して、単一の組織における指定期間の Devin コードスキャン、検出結果、修復用PRの集計メトリクスを取得します

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

組織レベルの `ViewCodeScans` 権限を持つ[サービスユーザー](/ja/api-reference/v3/service-users/members-service-users)または[パーソナルアクセストークン](/ja/api-reference/personal-access-tokens)が必要です。

<div id="time-filters">
  ## 時間フィルター
</div>

このエンドポイントでは、`time_after` および `time_before` クエリパラメータが必要です。

* `time_after` と `time_before` はどちらも、UTC として解釈される**秒単位の Unix タイムスタンプ**です。
* `time_after` は `time_before` より前の時刻である必要があります。
* `time_after` と `time_before` の間の期間は**100 日以下**である必要があります。
* メトリクスの対象は、この期間内に作成されたコードスキャンです。

Enterprise 内のすべての組織のメトリクスを取得するには、[Get Code Scan Metrics (Enterprise)](/ja/api-reference/v3/code-scans/enterprise-code-scans-metrics) を利用してください。


## OpenAPI

````yaml ja/v3-openapi.yaml GET /v3/organizations/{org_id}/code-scans/metrics
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/organizations/{org_id}/code-scans/metrics:
    get:
      tags:
        - code-scans
      summary: コードスキャンのメトリクスを取得
      description: |-
        組織の集計済みコードスキャンメトリクスを取得します。

        指定した期間内に作成されたコードスキャンについて、スキャン、検出結果、および修正PRのメトリクスを返します。
      operationId: >-
        handle_get_code_scan_metrics_v3_organizations__org_id__code_scans_metrics_get
      parameters:
        - description: '組織ID（プレフィックス: org-）'
          in: path
          name: org_id
          required: true
          schema:
            example: org-abc123def456
            title: Org Id
            type: string
        - 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
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodeScanMetricsResponse'
          description: 成功レスポンス
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 認証されていません
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: アクセスが禁止されています
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 見つかりません
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 競合
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: 処理できないコンテンツ
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: リクエストが多すぎます
components:
  schemas:
    CodeScanMetricsResponse:
      description: >-
        コードスキャンのメトリクスのレスポンスモデル。


        すべてのメトリクスは、指定した期間内に作成されたコードスキャンを対象としています。検出結果と修復用PRは、それらを生成したスキャンに紐付けられます。
      properties:
        avg_pr_open_duration_seconds:
          anyOf:
            - type: number
            - type: 'null'
          description: >-
            PRがオープン状態にある（またはあった）平均時間（秒）。完了したPRでは作成からマージまたはクローズまで、オープン中のPRでは作成から現在までを指します。PRが1件も作成されていない場合は
            Null。
          title: Avg Pr Open Duration Seconds
        avg_pr_time_to_merge_seconds:
          anyOf:
            - type: number
            - type: 'null'
          description: PRの作成からマージまでの平均時間（秒）。マージ済みのPRが1件もない場合は Null。
          title: Avg Pr Time To Merge Seconds
        open_critical_findings_count:
          description: 重大度がcriticalの未解決の検出結果数。
          title: Open Critical Findings Count
          type: integer
        open_high_findings_count:
          description: 重大度がhighの未解決の検出結果数。
          title: Open High Findings Count
          type: integer
        open_low_findings_count:
          description: 重大度がlowの未解決の検出結果数。
          title: Open Low Findings Count
          type: integer
        open_medium_findings_count:
          description: 重大度がmediumの未解決の検出結果数。
          title: Open Medium Findings Count
          type: integer
        prs_closed_count:
          description: マージされずにクローズされた修復用PRの数。
          title: Prs Closed Count
          type: integer
        prs_created_count:
          description: スキャンの修復セッションによって作成されたPRの数。
          title: Prs Created Count
          type: integer
        prs_merged_count:
          description: マージされた修復用PRの数。
          title: Prs Merged Count
          type: integer
        prs_open_count:
          description: 現在オープン状態の修復用PRの数。
          title: Prs Open Count
          type: integer
        repos_scanned_count:
          description: スキャン対象となった一意のリポジトリ数。
          title: Repos Scanned Count
          type: integer
        scans_count:
          description: 指定した期間内に作成されたコードスキャンの数。
          title: Scans Count
          type: integer
      required:
        - scans_count
        - repos_scanned_count
        - prs_created_count
        - prs_open_count
        - prs_merged_count
        - prs_closed_count
        - avg_pr_time_to_merge_seconds
        - avg_pr_open_duration_seconds
        - open_critical_findings_count
        - open_high_findings_count
        - open_medium_findings_count
        - open_low_findings_count
      title: CodeScanMetricsResponse
      type: object
    ProblemDetail:
      description: >-
        v3 API 用の RFC 9457 application/problem+json エラーボディ。


        detail は後方互換性のため、レガシーな {"detail": ...}
        ボディから引き継がれます。その他のメンバーは追加式です。errors にはフィールドレベルのバリデーションエラーが含まれます（422
        の場合のみ）。
      properties:
        detail:
          anyOf:
            - type: string
            - type: 'null'
          description: この事象に固有の、人が読める説明。
          title: Detail
        errors:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          description: フィールド単位のバリデーションエラー（422 レスポンスのみ）。
          title: Errors
        instance:
          anyOf:
            - type: string
            - type: 'null'
          description: この発生箇所の URI 参照（リクエストパス）。
          title: Instance
        status:
          description: HTTP ステータスコード。
          title: Status
          type: integer
        title:
          description: 問題タイプを人が読める短い要約。
          title: Title
          type: string
        type:
          default: about:blank
          description: 問題タイプを識別する URI 参照。
          title: Type
          type: string
      required:
        - title
        - status
      title: ProblemDetail
      type: object
  securitySchemes:
    bearerAuth:
      description: 'サービスユーザーの認証情報（接頭辞: cog_）'
      scheme: bearer
      type: http

````