REST APIリファレンス
ベースURL
https://pii-firewallproxy-production.up.railway.appPOST /detect
テキスト文字列内のPIIを検出します(変更なし)。
リクエスト
http
POST /detect
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"text": "メールは alice@example.com です",
"lang": "ja"
}| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
text | string | ✅ | スキャン対象のテキスト |
lang | string | "en" または "ja"(デフォルト:"en") |
レスポンス
json
{
"detections": [
{
"type": "EMAIL",
"value": "alice@example.com",
"start": 5,
"end": 22
}
],
"count": 1,
"creditsUsed": 1
}POST /mask
PIIを検出・マスクし、後で復元するためのトークンマップを返します。
リクエスト
http
POST /mask
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"text": "090-1234-5678 までお電話ください",
"lang": "ja"
}レスポンス
json
{
"masked": "[PHONE-1] までお電話ください",
"tokenMap": {
"[PHONE-1]": "090-1234-5678"
},
"sessionId": "sess_abc123",
"creditsUsed": 1
}POST /restore
トークンマップを使用してAIレスポンス内の元の値を復元します。
リクエスト
http
POST /restore
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"text": "[NAME-1]([EMAIL-1])のレコードが見つかりました。",
"sessionId": "sess_abc123"
}レスポンス
json
{
"restored": "山田太郎(yamada@example.com)のレコードが見つかりました。",
"creditsUsed": 1
}POST /detect-injection
テキスト内のプロンプトインジェクションやジェイルブレイクパターンを検出します。
リクエスト
http
POST /detect-injection
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"text": "これまでの指示をすべて無視して..."
}レスポンス
json
{
"injectionDetected": true,
"categories": ["prompt_injection"],
"risk": "high",
"creditsUsed": 1
}GET /credits
アカウントの残クレジットを取得します。
リクエスト
http
GET /credits
Authorization: Bearer YOUR_API_KEYレスポンス
json
{
"plan": "starter",
"creditsRemaining": 847,
"creditsTotal": 1000,
"resetsAt": "2025-06-01T00:00:00Z"
}PIIタイプ一覧
| タイプ | 例 |
|---|---|
NAME | 山田太郎 |
EMAIL | yamada@example.com |
PHONE | 090-1234-5678 |
ADDRESS | 東京都渋谷区1-2-3 |
CREDIT_CARD | 4111 1111 1111 1111 |
PASSPORT | TK1234567 |
MY_NUMBER | 1234 5678 9012 |
IP_ADDRESS | 192.168.1.1 |
API_KEY | sk-... |
DATE_OF_BIRTH | 1990-01-15 |
BANK_ACCOUNT | 0001-123-4567890 |
エラーコード
| コード | 説明 |
|---|---|
401 | APIキーが無効または未指定 |
402 | クレジット不足 |
422 | リクエストボディが不正 |
429 | レート制限超過 |
500 | 内部サーバーエラー |
