> ## 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 コードスキャンを開始します。必要に応じて、スキャンプロファイルまたはコミット SHA を指定できます

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

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

<div id="behavior">
  ## 動作
</div>

組織内の `repo_name` に対する新しいコードスキャンをキューに登録します。スキャンはスキャンディスパッチャーによって非同期で開始され、レスポンスとして初期 `status` が `waiting` または `pending` のスキャンレコードが返されます。[List Code Scans](/ja/api-reference/v3/code-scans/organizations-code-scans-list) をポーリングして進行状況を追跡し、スキャンが `completed` になったら、`scan_id` でフィルタリングした [List Code Scan Findings](/ja/api-reference/v3/code-scans/organizations-code-scans-findings) で結果を確認します。

スキャンは、呼び出し元のプリンシパル (リクエストを行ったサービスユーザーまたは PAT) に紐付けられます。Enterprise スコープで同等の機能を利用するには、[Start Code Scan (Enterprise)](/ja/api-reference/v3/code-scans/enterprise-code-scans-start) を参照してください。

<div id="request-fields">
  ### リクエストフィールド
</div>

* `repo_name` (必須) : 完全なリポジトリ名 (例: `owner/repo`) 。リポジトリには、組織の Git 統合を通じてあらかじめアクセスできる必要があります。
* `host`: 自動的に判別できない場合のリポジトリの Git ホスト。
* `profile_id`: 適用する[スキャンプロファイル](/ja/api-reference/v3/code-scans/organizations-code-scans-profiles)。`ingest` モードのプロファイルには、[Start Ingestion Scan](/ja/api-reference/v3/code-scans/organizations-code-scans-start-ingestion)を使用します。
* `scan_type`: 実行するスキャンタイプ。`profile_id` を指定する場合は、プロファイルのスキャンタイプと一致している必要があります。デフォルトはプロファイルのスキャンタイプで、プロファイルなしのスキャンでは `security` です。セキュリティ以外のスキャンタイプにはプロファイルが必要です。
* `commit_sha`: スキャン前にチェックアウトするコミット。デフォルトはリポジトリのデフォルトブランチの先頭コミットです。

<div id="errors">
  ### エラー
</div>

* `400`: `scan_type` がプロファイルと矛盾している場合、またはプロファイルなしでセキュリティ以外の `scan_type` が指定された場合。
* `403`: 組織が取り込み専用スキャンに制限されており、`ingest` モードのプロファイルが指定されていない場合。
* `404`: リポジトリまたはプロファイルを組織が参照できない場合。
* `409`: 組織のスキャンバックログが上限に達している場合。しばらくしてから再試行してください。


## OpenAPI

````yaml ja/v3-openapi.yaml POST /v3/organizations/{org_id}/code-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/organizations/{org_id}/code-scans:
    post:
      tags:
        - code-scans
      summary: コードスキャンを開始
      description: >-
        組織内のリポジトリに対して新しいコードスキャンを開始します。


        スキャンはキューに登録され、スキャンディスパッチャーによって非同期に開始されます。

        スキャンは、呼び出し元の主体（リクエストを行ったサービスユーザーまたは
        PAT）に帰属します。組織のスキャンバックログが上限に達している場合は、``409`` を返します。
      operationId: handle_start_code_scan_v3_organizations__org_id__code_scans_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/CodeScanCreateRequest'
        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:
    CodeScanCreateRequest:
      description: 新しいコードスキャンを開始するためのリクエストボディ。
      properties:
        commit_sha:
          anyOf:
            - type: string
            - type: 'null'
          description: スキャン前にチェックアウトするコミット。
          title: Commit Sha
        host:
          anyOf:
            - type: string
            - type: 'null'
          description: 既知の場合、リポジトリの Git ホスト。
          title: Host
        profile_id:
          anyOf:
            - type: string
            - type: 'null'
          description: スキャンに適用するスキャンプロファイル。
          title: Profile Id
        repo_name:
          description: スキャン対象のリポジトリの完全名。
          title: Repo Name
          type: string
        scan_type:
          anyOf:
            - enum:
                - security
                - performance
                - db-queries
                - test-coverage
                - dead-code
                - code-quality
                - telemetry
                - accessibility
                - general
                - migration-docs
              type: string
            - type: 'null'
          description: >-
            実行するスキャンのタイプ。プロファイルが指定されている場合は、そのスキャンタイプと一致する必要があります。デフォルトはプロファイルのタイプ、またはプロファイルなしのスキャンでは
            'security' です。セキュリティ以外のタイプにはプロファイルが必要で、プロファイルなしでは拒否されます。
          title: Scan Type
      required:
        - repo_name
      title: CodeScanCreateRequest
      type: object
    CodeScanResponse:
      description: 1件のコードスキャン。
      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: スキャンの実行時に使用されたプロファイル（ある場合）。
        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: スキャンの実行時に使用されたプロファイルの要約。
      properties:
        name:
          description: プロファイル名。
          title: Name
          type: string
        profile_id:
          description: プロファイルの一意の識別子。
          title: Profile Id
          type: string
      required:
        - profile_id
        - name
      title: CodeScanProfileResponse
      type: object
  securitySchemes:
    bearerAuth:
      description: 'サービスユーザーの認証情報（接頭辞: cog_）'
      scheme: bearer
      type: http

````