API Reference
Base URL: https://api.pii-fi.com/api
api.pii-fi.com は性能テストやトライアル向けのデモ環境です。
本番環境ではお客様ごとに専用環境をご用意し、専用のエンドポイントを提供いたします。
Authentication
すべてのAPIリクエストには、Authorization ヘッダーにAPIキーを含める必要があります。
Authorization: Bearer YOUR_API_KEY
Required Headers
| Header | Required | Description |
|---|---|---|
Content-Type |
Required | application/json |
Authorization |
Required | Bearer YOUR_API_KEY |
APIキーが無効または未指定の場合、401 Unauthorized エラーが返されます。
PII Detection API
POST /detect
テキストからPIIを検出し、マスキングします。
Request Body
| Parameter | Required | Description |
|---|---|---|
text |
Required | 処理対象のテキスト(string) |
deidentification_type |
Optional | 非識別化方式(default: replace)Values: replace, mask, full_mask, hash, fake |
language |
Optional | 言語コード(default: ja) |
include_context |
Optional | エンティティ詳細を含める(default: true) |
include_mapping_info |
Optional | 復元用マッピング情報を含める(fake時のみ有効) |
use_markers |
Optional | マーカー形式を使用(fake時のみ有効) |
enabled_entities |
Optional | 検出するエンティティタイプのリスト(string[]) |
deidentification_type Values
| Value | Description | Example |
|---|---|---|
replace |
タグ形式で置換 | 田中太郎 → <人名> |
mask |
部分マスク(一部文字を残す) | 090-1234-5678 → 090-****-5678 |
full_mask |
完全マスク(すべて*に置換) |
田中太郎 → **** |
hash |
ハッシュ値に置換 | 田中太郎 → JPII_PERSON_NAME_a1b2c3d4 |
fake |
ダミーデータに置換(復元可能) | 田中太郎 → 山田花子 |
Request Example
curl -X POST https://api.pii-fi.com/api/detect \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"text": "田中太郎(090-1234-5678)のメールはtanaka@example.comです。",
"deidentification_type": "fake",
"include_mapping_info": true
}'
Response
{
"deidentified_text": "山田花子(080-9876-5432)のメールはyamada@example.comです。",
"entities": [
{
"entity_type": "JPII_PERSON_NAME",
"original_entity_type": "JP_COMPLEX_NAME",
"original_text": "田中太郎",
"masked_text": "山田花子",
"start": 0,
"end": 4,
"confidence_score": 0.95
},
{
"entity_type": "JPII_PHONE_NUMBER",
"original_text": "090-1234-5678",
"masked_text": "080-9876-5432",
"start": 5,
"end": 18,
"confidence_score": 0.98
},
{
"entity_type": "JPII_EMAIL_ADDRESS",
"original_text": "tanaka@example.com",
"masked_text": "yamada@example.com",
"start": 24,
"end": 42,
"confidence_score": 0.99
}
],
"mapping_info": {
"mappings": [
{
"original": "田中太郎",
"fake": "山田花子",
"entity_type": "JPII_PERSON_NAME"
},
{
"original": "090-1234-5678",
"fake": "080-9876-5432",
"entity_type": "JPII_PHONE_NUMBER"
},
{
"original": "tanaka@example.com",
"fake": "yamada@example.com",
"entity_type": "JPII_EMAIL_ADDRESS"
}
]
},
"processing_info": {
"processing_time_seconds": 0.15
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
deidentified_text |
string | マスキング後のテキスト |
entities |
array | 検出されたエンティティのリスト |
mapping_info |
object | 復元用マッピング情報(include_mapping_info=true時) |
processing_info |
object | 処理情報 |
POST /detect/batch
複数のテキストを一括で処理します。
最大100件まで。100件を超えると 400 Bad Request エラーが返されます。
Request Body
リクエストオブジェクトの配列を送信します。
[
{"text": "田中太郎です", "deidentification_type": "replace"},
{"text": "電話: 090-1234-5678", "deidentification_type": "mask"}
]
Response
各テキストの処理結果の配列が返されます。
[
{
"deidentified_text": "<人名>です",
"entities": [...]
},
{
"deidentified_text": "電話: 090-****-5678",
"entities": [...]
}
]
Restore API
POST /restore
fake 方式でマスキングされたテキストを元のPII値に復元します。
Request Body
| Parameter | Required | Description |
|---|---|---|
text |
Required | 復元対象のテキスト |
mapping_info |
Required | /detect で取得したマッピング情報 |
mode |
Optional | 復元モード: simple or marker(default: simple) |
Restore Modes
| Mode | Description |
|---|---|
simple |
単純な文字列置換で復元 |
marker |
[[PII_XXX:値]] マーカー形式を使用して復元 |
Request Example
curl -X POST https://api.pii-fi.com/api/restore \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"text": "山田花子様、ご連絡ありがとうございます。",
"mapping_info": {
"mappings": [
{"original": "田中太郎", "fake": "山田花子", "entity_type": "JPII_PERSON_NAME"}
]
},
"mode": "simple"
}'
Response
{
"restored_text": "田中太郎様、ご連絡ありがとうございます。",
"replace_count": 1,
"processing_info": {
"processing_time_seconds": 0.01
},
"stats": {
"total_mappings": 1,
"successful_replacements": 1
}
}
Policy Management API
ポリシーは、PII-Fi の検出精度を決定づける最重要設定です。
どの認識器を有効にするか、パターンマッチとNERのどちらを優先するか、辞書マッチングの優先度をどう設定するか —— これらすべてがポリシーで制御されます。
- priority調整:同じ位置で複数の認識器が反応したとき、どちらを採用するか決定
- エンティティ有効/無効:業務に不要なエンティティを無効化して誤検出を削減
- マスキングカスタマイズ:置換文字列、マスク文字、ダミーデータを自由に設定
- allow_list:「本社」「部長」など誤検出しやすい単語を除外
- confidence_threshold:信頼度の閾値を調整して検出感度をコントロール
デフォルトポリシーで動作確認後、業務要件に合わせてポリシーをチューニングすることで、 検出精度を大幅に向上させることができます。 詳細なスキーマ仕様は Policy Schema を参照してください。
GET /policy/list
利用可能なポリシー一覧を取得します。
Response
{
"policies": ["default", "strict", "minimal"],
"active": "default",
"count": 3
}
GET /policy/active
現在アクティブなポリシー名を取得します。
GET /policy/named/{name}
指定したポリシーの詳細を取得します。
PUT /policy/named/{name}
ポリシーを作成または更新します。
ポリシー変更APIには楽観的ロックが必要です。まずGETでETagを取得し、変更時にIf-Matchヘッダーで送信します。
Request Body
{
"policy": {
"version": "2.0",
"entities": {
"name": {"enabled": true},
"phone": {"enabled": true},
"email": {"enabled": false}
}
}
}
ポリシーJSONの完全な仕様(エンティティキー一覧、priority調整、マスキングカスタマイズ等)は Policy Schema を参照してください。
Example: Create Policy
# ETag取得
ETAG=$(curl -s -I https://api.pii-fi.com/api/policy/active \
-H "Authorization: Bearer YOUR_API_KEY" | grep -i etag | awk '{print $2}' | tr -d '\r')
# ポリシー作成
curl -X PUT https://api.pii-fi.com/api/policy/named/my_policy \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "If-Match: $ETAG" \
-d '{
"policy": {
"version": "2.0",
"entities": {
"name": {"enabled": true},
"email": {"enabled": false}
}
}
}'
DELETE /policy/named/{name}
ポリシーを削除します。
defaultポリシーは削除できません- アクティブなポリシーは削除できません
POST /policy/activate/{name}
指定したポリシーをアクティブ化します。
POST /policy/reload
アクティブなポリシーをリロードします。
Custom Recognizers API
独自のパターンでPIIを検出するカスタム認識器を管理します。
GET /policy/recognizers
カスタム認識器の一覧を取得します。
POST /policy/recognizers
カスタム認識器を追加します。
Request Body
| Parameter | Required | Description |
|---|---|---|
id |
Required | 認識器ID(例: custom.employee_id) |
name |
Required | 認識器名 |
entity_type |
Required | エンティティタイプ(例: JPII_EMPLOYEE_ID) |
patterns |
Required | パターン定義のリスト |
category |
Optional | カテゴリ(default: custom) |
priority |
Optional | 優先度(default: 75) |
context |
Optional | コンテキストキーワード(string[]) |
Pattern Definition
{
"name": "employee_id_pattern",
"regex": "EMP-\\d{6}",
"score": 0.9
}
DELETE /policy/recognizers/{recognizer_id}
カスタム認識器を削除します。
Dictionary API
会社名・製品名・禁止ワードなど、固有名詞を辞書ベースで検出するための機能です。
GET /policy/dictionaries
辞書一覧を取得します。
POST /policy/dictionaries
辞書を作成します。
Request Body
| Parameter | Required | Description |
|---|---|---|
id |
Required | 辞書ID(例: dict.companies) |
name |
Required | 辞書名 |
entity_type |
Required | エンティティタイプ |
entries |
Required | エントリのリスト |
priority |
Optional | 優先度(default: 80) |
normalize |
Optional | 正規化を有効にするか(default: true) |
fuzzy |
Optional | ファジーマッチング(default: false) |
GET /policy/dictionaries/{dictionary_id}
指定した辞書を取得します。
DELETE /policy/dictionaries/{dictionary_id}
辞書を削除します。
POST /policy/dictionaries/{dictionary_id}/entries
辞書にエントリを追加します。
DELETE /policy/dictionaries/{dictionary_id}/entries
辞書からエントリを削除します。
Contextual Pipeline API
文脈解析パイプラインは、周辺テキストの文脈から機密カテゴリを自動分類する高度な認識器です。 同じ数値でも「年収500万円」と「売上高500万円」を区別して、それぞれ適切なカテゴリに分類できます。
GET /policy/pipelines
文脈解析パイプライン一覧を取得します。
Response
{
"pipelines": [
{
"id": "pipeline.financial",
"name": "金融情報分類パイプライン",
"description": "金額の文脈を解析し、個人収入・企業収益・戦略情報を分類",
"categories": [
{"id": "PERSONAL_INCOME", "label": "個人収入"},
{"id": "CORPORATE_EARNINGS", "label": "企業収益"},
{"id": "CORPORATE_STRATEGIC", "label": "戦略情報"}
],
"enabled": true
}
],
"count": 1
}
POST /policy/pipelines
文脈解析パイプラインを作成します。
Request Body
| Parameter | Required | Description |
|---|---|---|
id |
Required | パイプラインID(例: pipeline.financial) |
name |
Required | パイプライン名 |
categories |
Required | 分類カテゴリのリスト |
description |
Optional | 説明 |
context_rules |
Optional | 文脈ルール(キーワードベースの分類ルール) |
priority |
Optional | 優先度(default: 85) |
Category Definition
{
"id": "PERSONAL_INCOME",
"label": "個人収入",
"context_keywords": ["年収", "月収", "給与", "給料", "手取り", "所得"],
"entity_type": "JPII_PERSONAL_INCOME"
}
Request Example
# ETag取得
ETAG=$(curl -s -I https://api.pii-fi.com/api/policy/active \
-H "Authorization: Bearer YOUR_API_KEY" | grep -i etag | awk '{print $2}' | tr -d '\r')
# パイプライン作成
curl -X POST https://api.pii-fi.com/api/policy/pipelines \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "If-Match: $ETAG" \
-d '{
"id": "pipeline.financial",
"name": "金融情報分類パイプライン",
"description": "金額の文脈を解析し、機密カテゴリを自動分類",
"categories": [
{
"id": "PERSONAL_INCOME",
"label": "個人収入",
"context_keywords": ["年収", "月収", "給与", "給料", "手取り"],
"entity_type": "JPII_PERSONAL_INCOME"
},
{
"id": "CORPORATE_EARNINGS",
"label": "企業収益",
"context_keywords": ["売上", "売上高", "収益", "利益", "営業利益"],
"entity_type": "JPII_CORPORATE_EARNINGS"
},
{
"id": "CORPORATE_STRATEGIC",
"label": "戦略情報",
"context_keywords": ["M&A", "買収", "合併", "出資", "投資額"],
"entity_type": "JPII_CORPORATE_STRATEGIC"
}
],
"priority": 85
}'
DELETE /policy/pipelines/{pipeline_id}
文脈解析パイプラインを削除します。
ドメイン特化型パイプラインの構築
大量の自社ドキュメントから業界固有の表現や社内用語に対応した高精度なパイプラインを構築したい場合は、 当社の認識器学習構築サービス(有償)をご利用ください。 詳しくはお問い合わせフォームからご連絡ください。
検出結果での文脈分類
文脈解析パイプラインが有効な場合、同じ「500万円」でも周辺文脈から異なるカテゴリに分類されます。
入力テキスト例
田中氏の年収は500万円です。A社の売上高は500万円でした。B社のM&A金額は500万円と報道されています。
検出結果
{
"deidentified_text": "<人名>の<個人収入>です。A社の<企業収益>でした。B社の<戦略情報>と報道されています。",
"entities": [
{
"entity_type": "JPII_PERSON_NAME",
"original_text": "田中氏",
"masked_text": "<人名>",
"confidence_score": 0.95
},
{
"entity_type": "JPII_PERSONAL_INCOME",
"original_text": "年収は500万円",
"masked_text": "<個人収入>",
"confidence_score": 0.92,
"context_classification": {
"pipeline_id": "pipeline.financial",
"category": "PERSONAL_INCOME",
"category_label": "個人収入",
"context_keywords_matched": ["年収"]
}
},
{
"entity_type": "JPII_CORPORATE_EARNINGS",
"original_text": "売上高は500万円",
"masked_text": "<企業収益>",
"confidence_score": 0.91,
"context_classification": {
"pipeline_id": "pipeline.financial",
"category": "CORPORATE_EARNINGS",
"category_label": "企業収益",
"context_keywords_matched": ["売上高"]
}
},
{
"entity_type": "JPII_CORPORATE_STRATEGIC",
"original_text": "M&A金額は500万円",
"masked_text": "<戦略情報>",
"confidence_score": 0.89,
"context_classification": {
"pipeline_id": "pipeline.financial",
"category": "CORPORATE_STRATEGIC",
"category_label": "戦略情報",
"context_keywords_matched": ["M&A"]
}
}
]
}
同じ「500万円」という金額でも、周辺の文脈キーワード(年収/売上高/M&A)によって 個人収入・企業収益・戦略情報と 自動的に区別して分類されます。
Utility API
GET /entity_types
検出可能なエンティティタイプの一覧を取得します。
Error Responses
HTTP Status Codes
| Code | Description |
|---|---|
200 |
成功 |
400 |
不正なリクエスト |
401 |
認証エラー |
404 |
リソースが見つからない |
422 |
バリデーションエラー |
500 |
サーバーエラー |
Error Response Format
{
"detail": "Error message here"
}
Validation Error (422)
{
"detail": [
{
"type": "literal_error",
"loc": ["body", "deidentification_type"],
"msg": "Input should be 'replace', 'mask', 'full_mask', 'hash' or 'fake'",
"input": "invalid_type"
}
]
}