コードスキャンを開始
curl --request POST \
--url https://api.devin.ai/v3/enterprise/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/enterprise/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/enterprise/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/enterprise/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/enterprise/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/enterprise/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/enterprise/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"
}コードスキャン(Enterprise)
コードスキャンを開始(Devin API)
v3 Enterprise API を使用して、組織内のリポジトリに対する新しい Devin コードスキャンを開始します。必要に応じて、スキャンプロファイルまたはコミットを指定できます
POST
/
v3
/
enterprise
/
organizations
/
{org_id}
/
code-scans
コードスキャンを開始
curl --request POST \
--url https://api.devin.ai/v3/enterprise/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/enterprise/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/enterprise/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/enterprise/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/enterprise/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/enterprise/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/enterprise/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"
}権限
UseAccountCodeScans 権限を持つ、サービスユーザーまたはパーソナルアクセストークンが必要です。
動作
repo_name に対する新しいコードスキャンをキューに追加します。スキャンはスキャンディスパッチャーによって非同期で開始されます。レスポンスとして、初期 status が waiting または pending のスキャンレコードが返されます。コードスキャンの一覧をポーリングして進行状況を追跡し、スキャンが completed になったら、scan_id でフィルタリングしたコードスキャン検出結果の一覧で結果を確認します。
スキャンは、呼び出し元のプリンシパル (リクエストを行ったサービスユーザーまたは PAT) に紐付けられます。
リクエストフィールド
repo_name(必須) : 完全なリポジトリ名 (例:owner/repo) 。リポジトリには、組織の Git 統合を通じてすでにアクセスできる必要があります。host: 推測できない場合に指定する、リポジトリの Git ホスト。profile_id: 適用するスキャンプロファイル。ingestモードのプロファイルには、Start Ingestion Scanを使用します。scan_type: 実行するスキャンの種類。profile_idを指定する場合は、プロファイルのスキャンタイプと一致する必要があります。デフォルトはプロファイルの種類です。プロファイルを指定しないスキャンではsecurityがデフォルトになります。セキュリティ以外のスキャンタイプにはプロファイルが必要です。commit_sha: スキャン前にチェックアウトするコミット。デフォルトはリポジトリのデフォルトブランチの HEAD です。
エラー
scan_typeがプロファイルと競合している場合、またはプロファイルを指定せずにセキュリティ以外のscan_typeを指定した場合は400。- 組織が取り込み専用スキャンに制限されており、
ingestモードのプロファイルが指定されていない場合は403。 - 組織、リポジトリ、またはプロファイルが Enterprise アカウントから参照できない場合は
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 
