コードスキャンを開始
curl --request POST \
--url https://api.devin.ai/v3/organizations/{org_id}/code-scans \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"repo_name": "<string>",
"commit_sha": "<string>",
"host": "<string>",
"profile_id": "<string>"
}
'import requests
url = "https://api.devin.ai/v3/organizations/{org_id}/code-scans"
payload = {
"repo_name": "<string>",
"commit_sha": "<string>",
"host": "<string>",
"profile_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
repo_name: '<string>',
commit_sha: '<string>',
host: '<string>',
profile_id: '<string>'
})
};
fetch('https://api.devin.ai/v3/organizations/{org_id}/code-scans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.devin.ai/v3/organizations/{org_id}/code-scans",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repo_name' => '<string>',
'commit_sha' => '<string>',
'host' => '<string>',
'profile_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.devin.ai/v3/organizations/{org_id}/code-scans"
payload := strings.NewReader("{\n \"repo_name\": \"<string>\",\n \"commit_sha\": \"<string>\",\n \"host\": \"<string>\",\n \"profile_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.devin.ai/v3/organizations/{org_id}/code-scans")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"repo_name\": \"<string>\",\n \"commit_sha\": \"<string>\",\n \"host\": \"<string>\",\n \"profile_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devin.ai/v3/organizations/{org_id}/code-scans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"repo_name\": \"<string>\",\n \"commit_sha\": \"<string>\",\n \"host\": \"<string>\",\n \"profile_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": 123,
"host": "<string>",
"org_id": "<string>",
"profile": {
"name": "<string>",
"profile_id": "<string>"
},
"repo_name": "<string>",
"scan_id": "<string>",
"scan_type": "security",
"status": "waiting"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}コードスキャン(組織)
コードスキャンを開始(Devin API)
v3 組織 API を介してリポジトリに対する新しい Devin コードスキャンを開始します。必要に応じて、スキャンプロファイルまたはコミット SHA を指定できます
POST
/
v3
/
organizations
/
{org_id}
/
code-scans
コードスキャンを開始
curl --request POST \
--url https://api.devin.ai/v3/organizations/{org_id}/code-scans \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"repo_name": "<string>",
"commit_sha": "<string>",
"host": "<string>",
"profile_id": "<string>"
}
'import requests
url = "https://api.devin.ai/v3/organizations/{org_id}/code-scans"
payload = {
"repo_name": "<string>",
"commit_sha": "<string>",
"host": "<string>",
"profile_id": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
repo_name: '<string>',
commit_sha: '<string>',
host: '<string>',
profile_id: '<string>'
})
};
fetch('https://api.devin.ai/v3/organizations/{org_id}/code-scans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.devin.ai/v3/organizations/{org_id}/code-scans",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repo_name' => '<string>',
'commit_sha' => '<string>',
'host' => '<string>',
'profile_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.devin.ai/v3/organizations/{org_id}/code-scans"
payload := strings.NewReader("{\n \"repo_name\": \"<string>\",\n \"commit_sha\": \"<string>\",\n \"host\": \"<string>\",\n \"profile_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.devin.ai/v3/organizations/{org_id}/code-scans")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"repo_name\": \"<string>\",\n \"commit_sha\": \"<string>\",\n \"host\": \"<string>\",\n \"profile_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devin.ai/v3/organizations/{org_id}/code-scans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"repo_name\": \"<string>\",\n \"commit_sha\": \"<string>\",\n \"host\": \"<string>\",\n \"profile_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"created_at": 123,
"host": "<string>",
"org_id": "<string>",
"profile": {
"name": "<string>",
"profile_id": "<string>"
},
"repo_name": "<string>",
"scan_id": "<string>",
"scan_type": "security",
"status": "waiting"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}{
"status": 123,
"title": "<string>",
"detail": "<string>",
"errors": [
{}
],
"instance": "<string>",
"type": "about:blank"
}権限
UseCodeScans 権限を持つサービスユーザーまたはパーソナルアクセストークンが必要です。
動作
repo_name に対する新しいコードスキャンをキューに登録します。スキャンはスキャンディスパッチャーによって非同期で開始され、レスポンスとして初期 status が waiting または pending のスキャンレコードが返されます。List Code Scans をポーリングして進行状況を追跡し、スキャンが completed になったら、scan_id でフィルタリングした List Code Scan Findings で結果を確認します。
スキャンは、呼び出し元のプリンシパル (リクエストを行ったサービスユーザーまたは PAT) に紐付けられます。Enterprise スコープで同等の機能を利用するには、Start Code Scan (Enterprise) を参照してください。
リクエストフィールド
repo_name(必須) : 完全なリポジトリ名 (例:owner/repo) 。リポジトリには、組織の Git 統合を通じてあらかじめアクセスできる必要があります。host: 自動的に判別できない場合のリポジトリの Git ホスト。profile_id: 適用するスキャンプロファイル。ingestモードのプロファイルには、Start Ingestion Scanを使用します。scan_type: 実行するスキャンタイプ。profile_idを指定する場合は、プロファイルのスキャンタイプと一致している必要があります。デフォルトはプロファイルのスキャンタイプで、プロファイルなしのスキャンではsecurityです。セキュリティ以外のスキャンタイプにはプロファイルが必要です。commit_sha: スキャン前にチェックアウトするコミット。デフォルトはリポジトリのデフォルトブランチの先頭コミットです。
エラー
400:scan_typeがプロファイルと矛盾している場合、またはプロファイルなしでセキュリティ以外のscan_typeが指定された場合。403: 組織が取り込み専用スキャンに制限されており、ingestモードのプロファイルが指定されていない場合。404: リポジトリまたはプロファイルを組織が参照できない場合。409: 組織のスキャンバックログが上限に達している場合。しばらくしてから再試行してください。
承認
サービスユーザーの認証情報(接頭辞: cog_)
パスパラメータ
組織 ID(プレフィックス: org-)
例:
"org-abc123def456"
ボディ
application/json
新しいコードスキャンを開始するためのリクエストボディ。
スキャン対象のリポジトリの完全名。
スキャン前にチェックアウトするコミット。
既知の場合、リポジトリの Git ホスト。
スキャンに適用するスキャンプロファイル。
実行するスキャンのタイプ。プロファイルが指定されている場合は、そのスキャンタイプと一致する必要があります。デフォルトはプロファイルのタイプ、またはプロファイルなしのスキャンでは 'security' です。セキュリティ以外のタイプにはプロファイルが必要で、プロファイルなしでは拒否されます。
利用可能なオプション:
security, performance, db-queries, test-coverage, dead-code, code-quality, telemetry, accessibility, general, migration-docs レスポンス
成功レスポンス
1件のコードスキャン。
スキャンの作成日時(Unix秒)。
既知の場合のリポジトリの Git ホスト。
スキャンが属する組織。
スキャンの実行時に使用されたプロファイル(ある場合)。
Show child attributes
Show child attributes
スキャンの主要なリポジトリ。マルチリポジトリスキャンには、ここに記載されていない追加のリポジトリも含まれます。
スキャンの一意の識別子。
作成時に記録されるスキャンのタイプ。
利用可能なオプション:
security, performance, db-queries, test-coverage, dead-code, code-quality, telemetry, accessibility, general, migration-docs スキャンのステータス: waiting、pending、running、awaiting_user_input、completed、failed、または cancelled。
利用可能なオプション:
waiting, pending, running, awaiting_user_input, completed, failed, cancelled 
