> ## 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 代码扫描并轮询扫描状态，支持按时间、代码仓库和组织过滤

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

需要[服务用户](/zh/api-reference/v3/service-users/members-service-users)或[个人访问令牌](/zh/api-reference/personal-access-tokens)，并且在企业级别拥有 `ViewAccountCodeScans` 权限。

<div id="behavior">
  ## 行为
</div>

返回企业内的代码扫描，按最新时间排序。可使用此接口轮询通过 [启动代码扫描](/zh/api-reference/v3/code-scans/enterprise-code-scans-start) 发起的扫描的 `status`：`waiting` → `pending` → `running` → `completed` (或 `failed` / `cancelled`) 。`awaiting_user_input` 仅适用于从 Web 应用发起的交互式扫描；通过 API 发起的扫描不会进入此状态。

<div id="filters">
  ### 过滤器
</div>

* `time_after` / `time_before`：以秒为单位的 Unix 时间戳 (UTC) ，用于限定扫描的创建时间。
* `repo_name`：仅返回扫描过此代码仓库的扫描记录，包括包含该代码仓库的多代码仓库扫描。
* `org_ids`：仅返回这些组织中的扫描记录。

结果使用不透明游标 (`after` / `first`) 进行分页。若仅查询单个组织，请使用[列出代码扫描 (组织) ](/zh/api-reference/v3/code-scans/organizations-code-scans-list)。


## OpenAPI

````yaml zh/v3-openapi.yaml GET /v3/enterprise/code-scans/scans
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/code-scans/scans:
    get:
      tags:
        - code-scans
      summary: 列出代码扫描
      description: >-
        列出企业账户的代码扫描。


        扫描结果按时间从新到旧返回。也可按 ``org_ids``、``repo_name`` 和创建时间（``time_after`` /
        ``time_before``）进行过滤；结果通过不透明游标（``after`` / ``first``）分页。
      operationId: handle_list_code_scans_v3_enterprise_code_scans_scans_get
      parameters:
        - in: query
          name: time_before
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Time Before
        - in: query
          name: time_after
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Time After
        - in: query
          name: after
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: After
        - in: query
          name: first
          required: false
          schema:
            default: 100
            maximum: 200
            minimum: 1
            title: First
            type: integer
        - description: >-
            筛选扫描过此代码仓库的扫描任务。即使该代码仓库不是扫描的主代码仓库，也会匹配多代码仓库扫描，因此返回项中的 repo_name
            可能不同。
          in: query
          name: repo_name
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              筛选扫描过此代码仓库的扫描任务。即使该代码仓库不是扫描的主代码仓库，也会匹配多代码仓库扫描，因此返回项中的 repo_name
              可能不同。
            title: Repo Name
        - description: 筛选这些组织中的扫描任务。
          in: query
          name: org_ids
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: 筛选这些组织中的扫描任务。
            title: Org Ids
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaginatedResponse_CodeScanResponse_'
          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:
    PaginatedResponse_CodeScanResponse_:
      properties:
        end_cursor:
          anyOf:
            - type: string
            - type: 'null'
          description: 用于获取下一页的游标；如果这是最后一页，则为 None。
          title: End Cursor
        has_next_page:
          default: false
          description: 此页之后是否还有更多项。
          title: Has Next Page
          type: boolean
        items:
          items:
            $ref: '#/components/schemas/CodeScanResponse'
          title: Items
          type: array
        total:
          anyOf:
            - type: integer
            - type: 'null'
          description: 可选的总数（为提升性能可省略）。
          title: Total
      required:
        - items
      title: PaginatedResponse[CodeScanResponse]
      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
    CodeScanResponse:
      description: 一次代码扫描。
      properties:
        created_at:
          description: 扫描的创建时间（Unix 秒）。
          title: Created At
          type: integer
        host:
          anyOf:
            - type: string
            - type: 'null'
          description: 代码仓库的 Git 托管平台（如已知）。
          title: Host
        org_id:
          description: 该扫描所属的组织。
          title: Org Id
          type: string
        profile:
          anyOf:
            - $ref: '#/components/schemas/CodeScanProfileResponse'
            - type: 'null'
          description: 扫描所使用的 Profile（如有）。
        repo_name:
          description: 扫描的主代码仓库。多代码仓库扫描还会涵盖此处未列出的其他代码仓库。
          title: Repo Name
          type: string
        scan_id:
          description: 扫描的唯一标识符。
          title: Scan Id
          type: string
        scan_type:
          description: 扫描类型，在创建时确定。
          enum:
            - security
            - performance
            - db-queries
            - test-coverage
            - dead-code
            - code-quality
            - telemetry
            - accessibility
            - general
            - migration-docs
          title: Scan Type
          type: string
        status:
          description: >-
            扫描状态：waiting、pending、running、awaiting_user_input、completed、failed 或
            cancelled。
          enum:
            - waiting
            - pending
            - running
            - awaiting_user_input
            - completed
            - failed
            - cancelled
          title: Status
          type: string
      required:
        - scan_id
        - org_id
        - repo_name
        - host
        - status
        - profile
        - scan_type
        - created_at
      title: CodeScanResponse
      type: object
    CodeScanProfileResponse:
      description: 扫描所使用 Profile 的摘要。
      properties:
        name:
          description: Profile 的名称。
          title: Name
          type: string
        profile_id:
          description: Profile 的唯一标识符。
          title: Profile Id
          type: string
      required:
        - profile_id
        - name
      title: CodeScanProfileResponse
      type: object
  securitySchemes:
    bearerAuth:
      description: 服务用户凭据（前缀：cog_）
      scheme: bearer
      type: http

````