API リファレンス
SPHIOR Security API を使えば、あらゆる言語・フレームワーク・環境のコードを脆弱性スキャンし、決定論的な修正ガイドをあなたの AI エージェントに渡せます。
認証
すべてのリクエストは Authorization ヘッダーに Bearer トークンとして API キーを含める必要があります。
curl https://api.sphior.com/v1/scan \
-H "Authorization: Bearer sk_live_your_api_key_here" \
-H "Content-Type: application/json"/v1/scanコードスキャン
コードスニペットのセキュリティ脆弱性を分析します。重大度、CVSS スコア、行番号、修正推奨を含む結果を返します。完全に決定論的(AI なし): 同じコードは常に同じ結果を返し、再現可能で監査に耐えます。
リクエストボディ
| パラメータ | 型 | 説明 |
|---|---|---|
| coderequired | string | 分析対象のソースコード。最大サイズはプランに依存(10KB〜10MB)。 |
| languagerequired | string | プログラミング言語: javascript, typescript, python, go, java, ruby, php, sql |
| policy_id | string | 適用するカスタムポリシー ID(Business+ プラン)。デフォルトは OWASP ルールセット。 |
リクエスト例
curl -X POST https://api.sphior.com/v1/scan \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"code": "app.get(\"/user\", (req, res) => { db.query(\"SELECT * FROM users WHERE id=\" + req.query.id) })",
"language": "javascript"
}'レスポンス例
{
"scan_id": "scan_01j9x7z3k8q4b5c2d6e7f8g9h0",
"status": "completed",
"language": "javascript",
"findings": [
{
"id": "find_001",
"type": "sql_injection",
"severity": "critical",
"cvss": 9.8,
"line": 2,
"column": 11,
"message": "Unsanitized user input passed directly to SQL query",
"cwe": "CWE-89",
"owasp": "A03:2021",
"fix_hint": "Use parameterized queries: db.query('SELECT * FROM users WHERE id = ?', [req.query.id])"
}
],
"summary": {
"critical": 1, "high": 0, "medium": 0, "low": 0, "info": 0
},
"ai_calls": 0,
"cached": false,
"latency_ms": 12
}/v1/fix修正ガイドを取得
前回のスキャンの finding ID を指定すると、決定論的な修正ガイド(なぜ問題か・修正手順・該当位置・AI エージェントへの指示)を返します。SPHIOR はパッチを書かずソースコードも送信しません。修正は顧客の AI(MCP 経由)が適用します。
リクエストボディ
| パラメータ | 型 | 説明 |
|---|---|---|
| scan_idrequired | string | 前回の /v1/scan コールで返された ID。 |
| finding_idrequired | string | 修正を生成する対象の finding。 |
| context | string | 追加の周辺コードコンテキスト(最良の結果にはファイル全体を推奨)。 |
レスポンス例
{
"fix_id": "fix_01j9x8a1b2c3d4e5f6g7h8i9j0",
"scan_id": "scan_01j9x7z3k8q4b5c2d6e7f8g9h0",
"finding_id": "find_001",
"patched_code": null,
"fix_context": {
"finding_id": "find_001",
"rule_id": "pattern.js.sql_concat",
"severity": "critical",
"cwe": "CWE-89",
"owasp": "A03:2021",
"why": "OS command / SQL injection: untrusted input reaches the query and can execute arbitrary statements.",
"remediation_steps": [
"Review the flagged code and identify the interpolated value.",
"Use a parameterized query (e.g. WHERE id = ?) with bound parameters.",
"Add a regression test covering the fixed behavior."
],
"agent_instructions": "Open the file in your workspace and read the actual code yourself (it is NOT included here). Apply the remediation steps. A human must review your change before merge.",
"data_boundary_note": "SPHIOR does not transmit your source code. This payload contains only finding metadata and deterministic remediation guidance."
},
"latency_ms": 9
}/v1/rulesルール一覧
プランで利用可能なすべてのアクティブなセキュリティルールを一覧表示します。ルール ID、カテゴリ、重大度、対応言語を返します。Business+ プランではコンソールからカスタムルールを作成可能。
curl https://api.sphior.com/v1/rules \
-H "Authorization: Bearer sk_live_..." \
-G -d "language=javascript" -d "severity=critical"クエリパラメータ
| パラメータ | 型 | 説明 |
|---|---|---|
| language | string | 言語でフィルタ(例: python, go)。省略で全言語。 |
| severity | string | 重大度でフィルタ: critical, high, medium, low, info |
| category | string | OWASP カテゴリでフィルタ(例: injection, auth, crypto) |
Webhook
API コンソールで Webhook URL を登録すると、スキャン完了時、重大な脆弱性検出時、支出上限到達時にリアルタイムイベントを受信できます。
イベントタイプ
scan.completedスキャン完了時に発火。ペイロードに scan_id、サマリー、検出件数を含む。
scan.critical_found重大度 Critical の脆弱性検出時に即座に発火。
spend_cap.reached月間支出が設定した上限に達した時に発火。
spend_cap.warning支出が上限の 80% に達した時に発火。
エラーコード
SPHIOR API は標準的な HTTP ステータスコードを使用します。エラーレスポンスは error と code フィールドを含む JSON です。
| ステータス | コード | 意味 |
|---|---|---|
| 401 | unauthenticated | API キーが未指定または無効です。 |
| 403 | forbidden | このキーにはこの操作の権限がありません。 |
| 400 | invalid_request | 不正な JSON、必須フィールドの欠落、またはサポートされていない言語。 |
| 413 | payload_too_large | コードサイズがプランの上限を超えています。 |
| 429 | spend_cap_reached | 月間支出上限に達しました。ルールのみの結果が返されます。 |
| 429 | rate_limited | 1 秒あたりのリクエスト数が多すぎます。バックオフしてリトライしてください。 |
| 500 | internal_error | 予期しないサーバーエラー。指数バックオフでリトライしてください。 |
// Error response shape
{
"error": "Missing required field: language",
"code": "invalid_request",
"status": 400
}SDK
公式 SDK は TypeScript/JavaScript と Python で利用可能です。両方とも型付きレスポンス、自動リトライ、支出上限認識を備えた REST API ラッパーです。
TypeScript / Node.js
npm install @sphior/sdkimport { SphiorClient } from "@sphior/sdk";
const sphior = new SphiorClient({ apiKey: process.env.SPHIOR_API_KEY });
const result = await sphior.scan({
code: fs.readFileSync("./auth.ts", "utf8"),
language: "typescript",
});
for (const finding of result.findings) {
console.log(`${finding.severity.toUpperCase()}: ${finding.message} (line ${finding.line})`);
console.log("Fix hint:", finding.fix_hint);
}
// Hand a finding to your own AI agent to fix (deterministic guidance, no code sent):
const guidance = await sphior.fix({ scan_id: result.scan_id, finding_id: result.findings[0].id });
console.log(guidance.fix_context.remediation_steps);Python
pip install sphior-sdkfrom sphior import SphiorClient
client = SphiorClient(api_key=os.environ["SPHIOR_API_KEY"])
result = client.scan(
code=open("app.py").read(),
language="python",
)
for finding in result.findings:
print(f"{finding.severity.upper()}: {finding.message} (line {finding.line})")
print("Fix hint:", finding.fix_hint)
# Hand a finding to your own AI agent to fix (deterministic guidance, no code sent):
guidance = client.fix(scan_id=result.scan_id, finding_id=result.findings[0].id)
print(guidance.fix_context["remediation_steps"])料金
SPHIOR Security API はアクセスに対するシンプルなプラットフォーム料金制です。スキャンと修正ガイドは完全決定論エンジンで動作し、AI コール従量課金はありません。プランはレート制限・コードサイズ上限・サポートで異なります。
| Plan | Platform fee | Scanning | Fix guidance |
|---|---|---|---|
| Free | $0/mo | Included | Included |
| Developer | $29/mo | Included | Included |
| Business | $99/mo | Included | Included |
| Enterprise | $299+/mo | Included | Included |
