メインコンテンツへスキップ
すべての DPDP エンドポイントは client.dpdp 上の型付きメソッドとして利用可能です。サブクライアントは自動的に付着します — RailScoreClient を構築して client.dpdp.* に到達します。非同期クライアント (AsyncRAILClient) は await client.dpdp.* で同じメソッドを公開します。
from rail_score_sdk import RailScoreClient

client = RailScoreClient(api_key="YOUR_RAIL_API_KEY")
scan = client.dpdp.scan("Applicant PAN ABCDE1234F", pii_action="mask")

インド個人識別情報のコンテンツをスキャン

Aadhaar (Verhoeff 検証済み)、PAN、UPI、モバイル、その他を検出し、児童シグナル (S.9) と目的のずれ (S.4) を検出します。detectmask、または block を選択します。
result = client.dpdp.scan(
    "Applicant PAN is ABCDE1234F and mobile 9876543210.",
    pii_action="detect",
    purpose="loan_advisory",
)
print(result.compliant, [p.type for p in result.pii_found])

意思決定をゲート

evaluate は決定的な判定を返します — allowblock、または require_action — あなたが行おうとしているアクション向け。
decision = client.dpdp.evaluate(
    action="make_decision",
    context={"user_id": "u_42", "purpose": "loan_advisory"},
    session_id="sess_1a2b3c",  # オプション、決定をセッションに関連付ける
)

if decision.verdict == "require_action":
    print("未処理の義務:", decision.required_actions)

イベントを記録

emit は 1–50 のコンプライアンスイベントを記録し、それらがトリガーする法定タイマーを自動開始します (例えば、dsr.received はレスポンスクロックを開始します)。
client.dpdp.emit(
    [
        {"type": "notice.shown", "data": {"user_id": "u_42"}},
        {"type": "consent.granted", "data": {"user_id": "u_42", "purpose": "loan_advisory"}},
    ],
    session_id="sess_1a2b3c",
)

ワークフローステップの必要なアクション

required = client.dpdp.require(
    session_id="sess_1a2b3c",
    workflow_step="data_processing",
)
for action in required.required_actions:
    print(action)

セッション

セッションは 1 つのデータ主体のジャーニーをまとめるスレッドです。create_sessionpurpose を必須とします — SDK は空の場合、ラウンドトリップを無駄にすることはなく、すぐに ValueError を発生させます。
session = client.dpdp.create_session(
    purpose="loan_advisory",
    entity_type="data_fiduciary",
)
fetched = client.dpdp.get_session(session.session_id)
print(fetched.state.consent_status)

タイマー

ステータス、タイプ、または期限までの日数でフィルタリングされた規制期限タイマーをリストします。
timers = client.dpdp.list_timers(status="active", approaching_days=30)
print(timers.summary.total_active)
for t in timers.timers:
    print(t.type, t.days_remaining)

証拠 (Pro+)

セッションの記録された証跡から監査級パケットをアセンブルします。
packet = client.dpdp.evidence(
    evidence_type="dsr_response",
    params={"session_id": "sess_1a2b3c", "request_id": "r_9"},
)

システム監査

dpdp_audit はシステム説明の段階的なコンプライアンス評価を実行し、エンティティ固有のコンテキストと罰則露出スコアリング付き。ホストされたコンプライアンスチェックをラップするため、ホスト型のみ
from rail_score_sdk import DPDPHostedOnlyError

try:
    audit = client.dpdp.dpdp_audit(
        content="Our fintech processes Aadhaar for KYC; consent via checkbox.",
        entity_type="data_fiduciary",
        sector="finance",
    )
    print(audit.overall_label, audit.total_penalty_exposure_crore)
except DPDPHostedOnlyError:
    # ホストされていない監査を提供しない自社ホストエージェントを指していると発生します。
    print("dpdp_audit はホスト型 API に対してのみ実行されます。")
dpdp_audit と基礎となるコンプライアンスチェックはホスト型 API 上でのみ利用可能です。自社ホスト RAIL エージェントに対しては、SDK は生の 404/501 の代わりに DPDPHostedOnlyError を発生させます。

エラーハンドリング

DPDP メソッドは標準 SDK エラー (AuthenticationErrorRateLimitError、Pro 以下の evidence 向け InsufficientTierError) と DPDP 固有のエラーを発生させます。
from rail_score_sdk import DPDPHostedOnlyError
from rail_score_sdk import AuthenticationError, RateLimitError

try:
    client.dpdp.scan("...", pii_action="block")
except AuthenticationError:
    print("API キーを確認してください")
except RateLimitError:
    print("リクエストを減速してください")

関連

DPDP API リファレンス

すべてのエンドポイント、クレジットコスト、レスポンスエンベロープ。

構成

アプリケーションのポリシー、プラン機能、次元を検査します。