> ## 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 Enterprise API，使用导入 Profile 启动摄取模式的 Devin 代码扫描，以分流外部扫描器发现的发现项

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

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

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

将 `摄取模式` 代码扫描加入队列。摄取扫描不会从头开始发现问题，而是接收由其他来源生成的发现项 (例如 SAST 报告) ，并由 Devin 针对代码仓库对其进行分流和验证。扫描由扫描调度器异步启动，并归属于调用主体。

<div id="request-fields">
  ### 请求字段
</div>

* `repo_name` (必填) ：完整的代码仓库名称，例如 `owner/repo`。
* `profile_id` (必填) ：`ingest` 模式的[扫描 Profile](/zh/api-reference/v3/code-scans/enterprise-code-scans-profiles)。`discover` 模式的 Profile 会被拒绝，并返回 `400`。
* `host`：代码仓库的 Git 主机；如果无法自动推断，则需要提供此字段。
* `attachment_urls`：提供给扫描的 Devin 附件 URL (例如导出的扫描器报告) 。请先通过[附件 API](/zh/api-reference/v3/attachments/post-organizations-attachments)上传文件。

<div id="errors">
  ### 错误
</div>

* 当 `profile_id` 不属于摄取模式 Profile 时，返回 `400`。
* 当企业账户无权查看组织、代码仓库或 Profile 时，返回 `404`。
* 当组织的扫描待办列表已满时，返回 `409`。请稍后重试。


## OpenAPI

````yaml zh/v3-openapi.yaml POST /v3/enterprise/organizations/{org_id}/code-scans/ingestion
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/organizations/{org_id}/code-scans/ingestion:
    post:
      tags:
        - code-scans
      summary: 启动数据摄取扫描
      description: |-
        在组织中的代码仓库上启动摄取模式代码扫描。

        扫描将由扫描调度器异步排队并启动。
        仅接受摄取模式 Profile；非摄取 Profile 将被拒绝，
        并返回 ``400``。可选附件 URL（通过 attachments API 上传）
        将提供给扫描。当组织的扫描
        待办列表已满时，返回 ``409``。
      operationId: >-
        handle_start_ingestion_scan_v3_enterprise_organizations__org_id__code_scans_ingestion_post
      parameters:
        - description: 组织 ID（前缀：org-）
          in: path
          name: org_id
          required: true
          schema:
            example: org-abc123def456
            title: Org Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StartIngestionScanRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/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:
    StartIngestionScanRequest:
      description: |-
        用于启动摄取模式代码扫描的请求体。

        仅接受摄取（ingest-mode）扫描 Profile：该 Profile 会针对指定代码仓库运行。
      properties:
        attachment_urls:
          anyOf:
            - items:
                format: uri
                maxLength: 2083
                minLength: 1
                type: string
              maxItems: 10
              type: array
            - type: 'null'
          description: 提供给扫描的 Devin 附件 URL，例如通过 attachments API 上传的文件。附件必须属于正在扫描的组织。
          title: Attachment Urls
        host:
          anyOf:
            - type: string
            - type: 'null'
          description: 代码仓库的 Git 主机（如已知）。
          title: Host
        profile_id:
          description: 要运行的摄取模式扫描 Profile。必须是摄取 Profile；非摄取 Profile 将被拒绝并返回 400。
          title: Profile Id
          type: string
        repo_name:
          description: 要扫描的代码仓库全名。
          title: Repo Name
          type: string
      required:
        - repo_name
        - profile_id
      title: StartIngestionScanRequest
      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
    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
    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

````