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

# Get Code Scan Metrics

> Get metrics for enterprise code scans

## Permissions

Requires a service user with the `ViewAccountCodeScans` permission at the enterprise level.

## Time filters

This endpoint requires the `time_after` and `time_before` query parameters.

* Both `time_after` and `time_before` are **Unix timestamps in seconds**, interpreted as UTC.
* `time_after` must be earlier than `time_before`.
* The time range between `time_after` and `time_before` must be **100 days or less**.
* Metrics are scoped to code scans created within this time range.


## OpenAPI

````yaml v3-openapi.yaml GET /v3/enterprise/code-scans/metrics
openapi: 3.1.0
info:
  description: Devin v3 API with Service User authentication and RBAC
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3/enterprise/code-scans/metrics:
    get:
      tags:
        - code-scans
      summary: Get Code Scan Metrics
      description: |-
        Get aggregated code scan metrics for the enterprise account.

        Returns scan, finding, and remediation-PR metrics for code scans created
        within the specified time range, optionally filtered to specific
        organizations.
      operationId: handle_get_code_scan_metrics_v3_enterprise_code_scans_metrics_get
      parameters:
        - 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
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodeScanMetricsResponse'
          description: Successful Response
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Conflict
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Unprocessable Content
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Too Many Requests
components:
  schemas:
    CodeScanMetricsResponse:
      description: |-
        Response model for code scan metrics.

        All metrics are scoped to code scans created within the specified time
        range: findings and remediation PRs are attributed to the scan that
        produced them.
      properties:
        avg_pr_open_duration_seconds:
          anyOf:
            - type: number
            - type: 'null'
          description: >-
            Average time a PR is (or was) open, in seconds: creation to
            merge/close for finished PRs, creation to now for open PRs. Null
            when no PRs were created.
          title: Avg Pr Open Duration Seconds
        avg_pr_time_to_merge_seconds:
          anyOf:
            - type: number
            - type: 'null'
          description: >-
            Average time from PR creation to merge, in seconds. Null when no PRs
            have been merged.
          title: Avg Pr Time To Merge Seconds
        open_critical_findings_count:
          description: Number of open findings with critical severity.
          title: Open Critical Findings Count
          type: integer
        open_high_findings_count:
          description: Number of open findings with high severity.
          title: Open High Findings Count
          type: integer
        open_low_findings_count:
          description: Number of open findings with low severity.
          title: Open Low Findings Count
          type: integer
        open_medium_findings_count:
          description: Number of open findings with medium severity.
          title: Open Medium Findings Count
          type: integer
        prs_closed_count:
          description: Number of remediation PRs closed without being merged.
          title: Prs Closed Count
          type: integer
        prs_created_count:
          description: Number of PRs created by the scans' remediation sessions.
          title: Prs Created Count
          type: integer
        prs_merged_count:
          description: Number of remediation PRs merged.
          title: Prs Merged Count
          type: integer
        prs_open_count:
          description: Number of remediation PRs currently in the open state.
          title: Prs Open Count
          type: integer
        repos_scanned_count:
          description: Number of distinct repositories scanned.
          title: Repos Scanned Count
          type: integer
        scans_count:
          description: Number of code scans created within the specified time range.
          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: >-
        RFC 9457 application/problem+json error body for the v3 API.


        detail is retained from the legacy {"detail": ...} body for back-compat;
        the

        other members are additive. errors carries field-level validation
        failures

        (422 only).
      properties:
        detail:
          anyOf:
            - type: string
            - type: 'null'
          description: A human-readable explanation specific to this occurrence.
          title: Detail
        errors:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          description: Field-level validation errors (422 responses only).
          title: Errors
        instance:
          anyOf:
            - type: string
            - type: 'null'
          description: A URI reference (the request path) for this occurrence.
          title: Instance
        status:
          description: The HTTP status code.
          title: Status
          type: integer
        title:
          description: A short, human-readable summary of the problem type.
          title: Title
          type: string
        type:
          default: about:blank
          description: A URI reference identifying the problem type.
          title: Type
          type: string
      required:
        - title
        - status
      title: ProblemDetail
      type: object
  securitySchemes:
    bearerAuth:
      description: 'Service User credential (prefix: cog_)'
      scheme: bearer
      type: http

````