> ## Documentation Index
> Fetch the complete documentation index at: https://docs.didit.me/llms.txt
> Use this file to discover all available pages before exploring further.

# 欺诈检查费用预估与输入校验

> 在运行请求之前，您可以使用 Didit 校验输入内容，并预估所选 Fraud Check（欺诈检查）服务的相关费用，提前了解计费情况。

请发送与您计划用于[欺诈检查](https://docs.didit.me/zh/standalone-apis/fraud-check.md)的请求体相同的内容。
规划操作不会创建检查或会话，不调用数据补充供应商，不读取网络历史记录，也不收取任何费用。

每个模块都将 `available` 与 `will_run` 区分开来。
`availability_reason` 说明所提供的输入是否支持该模块，`selection_reason` 则说明该模块为何被选中或未被选中。
请让不可用的开关保持可见，并显示其输入要求。

`networks_cross_org` 需要 Enterprise 套餐，且您组织的共享模式需设为 `global`。
若未满足这些条件，或您的组织未启用 Networks，规划结果会以 `available: false` 和 `availability_reason: "entitlement_required"` 报告该情况。
选择该模块的检查会以相同原因跳过它。
沙盒应用不受套餐或共享模式限制：只要提供受支持的标识符，该模块即可运行，并返回空的示例结果。

`estimated_price` 是以返回的 `currency` 为单位的十进制字符串。
价格为 null 表示不可用或未定价，而非免费。
顶层估算金额汇总所选的可运行模块；`can_afford` 还会检查适用的计费方式。
更改标识符、上下文或选择后，请重新规划。
执行时会重新检查资格和价格，因此规划结果既不是预留，也不保证外部数据源会作出响应。


## OpenAPI

````yaml zh/openapi-25.json POST /v3/fraud/checks/plan/
openapi: 3.0.0
info:
  version: 3.0.0
  title: Didit Verification API
  description: 身份证件验证 API。使用 x-api-key 请求头进行身份验证。
servers:
  - url: https://verification.didit.me
security: []
tags: []
paths:
  /v3/fraud/checks/plan/:
    post:
      tags:
        - Fraud Check
      summary: 计划欺诈检查
      description: 验证所选检查并估算其价格，无需实际执行、创建会话或计费。
      operationId: plan_create
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/FraudCheckRequestRequest'
          application/json:
            schema:
              $ref: '#/components/schemas/FraudCheckRequestRequest'
            example:
              client_reference: review-attempt-001
              subject:
                identifiers:
                  - type: email
                    value: applicant@example.com
                attributes:
                  first_name: Alex
                  last_name: Example
              checks:
                include:
                  - networks_same_org
                  - networks_cross_org
                  - email_risk
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/FraudCheckRequestRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FraudCheckPlan'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FraudBadRequestErrorMessage'
          description: ''
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
      x-codeSamples:
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.fraud_checks.plan(
                client_reference="review-attempt-001",
                subject={
                    "identifiers": [{
                        "type": "email",
                        "value": "applicant@example.com",
                    }],
                    "attributes": {
                        "first_name": "Alex",
                        "last_name": "Example",
                    },
                },
                checks={
                    "include": ["networks_same_org", "networks_cross_org", "email_risk"],
                },
            )
            print(result)
        - lang: javascript
          label: Node.js
          source: |-
            import Didit from "@didit-protocol/sdk-node";

            // Reads DIDIT_API_KEY.
            const didit = new Didit();

            const result = await didit.fraudChecks.plan({
              client_reference: "review-attempt-001",
              subject: {
                identifiers: [{
                  type: "email",
                  value: "applicant@example.com",
                }],
                attributes: {
                  first_name: "Alex",
                  last_name: "Example",
                },
              },
              checks: {
                include: ["networks_same_org", "networks_cross_org", "email_risk"],
              },
            });
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.FraudChecks.Plan(ctx, didit.FraudCheckRequestRequest{\n\tClientReference: didit.String(\"review-attempt-001\"),\n\tSubject: didit.FraudCheckSubjectRequest{\n\t\tIdentifiers: []didit.FraudCheckIdentifierRequest{{\n\t\t\tType:  didit.FraudTypeEnum(\"email\"),\n\t\t\tValue: \"applicant@example.com\",\n\t\t}},\n\t\tAttributes: didit.Some(didit.FraudCheckAttributesRequest{\n\t\t\tFirstName: didit.String(\"Alex\"),\n\t\t\tLastName:  didit.String(\"Example\"),\n\t\t}),\n\t},\n\tChecks: didit.Some(didit.FraudCheckModuleSelectionRequest{\n\t\tInclude: didit.Some([]didit.FraudExcludeEnum{didit.FraudExcludeEnum(\"networks_same_org\"), didit.FraudExcludeEnum(\"networks_cross_org\"), didit.FraudExcludeEnum(\"email_risk\")}),\n\t}),\n})\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: >-
            import java.util.List;

            import me.didit.Didit;

            import me.didit.types.FraudCheckAttributesRequest;

            import me.didit.types.FraudCheckIdentifierRequest;

            import me.didit.types.FraudCheckModuleSelectionRequest;

            import me.didit.types.FraudCheckRequestRequest;

            import me.didit.types.FraudCheckSubjectRequest;

            import me.didit.types.FraudExcludeEnum;

            import me.didit.types.FraudTypeEnum;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result =
            client.fraudChecks().plan(FraudCheckRequestRequest.builder()
                    .clientReference("review-attempt-001")
                    .subject(FraudCheckSubjectRequest.builder()
                            .identifiers(List.of(FraudCheckIdentifierRequest.builder()
                                    .type(FraudTypeEnum.of("email"))
                                    .value("applicant@example.com")
                                    .build()))
                            .attributes(FraudCheckAttributesRequest.builder()
                                    .firstName("Alex")
                                    .lastName("Example")
                                    .build())
                            .build())
                    .checks(FraudCheckModuleSelectionRequest.builder()
                            .include(List.of(FraudExcludeEnum.of("networks_same_org"), FraudExcludeEnum.of("networks_cross_org"), FraudExcludeEnum.of("email_risk")))
                            .build())
                    .build());
            System.out.println(result);
        - lang: php
          label: PHP
          source: |-
            <?php

            require 'vendor/autoload.php';

            use Didit\DiditClient;

            // Reads DIDIT_API_KEY.
            $didit = new DiditClient();

            $result = $didit->fraudChecks->plan([
                'client_reference' => 'review-attempt-001',
                'subject' => [
                    'identifiers' => [[
                        'type' => 'email',
                        'value' => 'applicant@example.com',
                    ]],
                    'attributes' => [
                        'first_name' => 'Alex',
                        'last_name' => 'Example',
                    ],
                ],
                'checks' => [
                    'include' => ['networks_same_org', 'networks_cross_org', 'email_risk'],
                ],
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

            # Reads DIDIT_API_KEY.
            didit = Didit::Client.new

            result = didit.fraud_checks.plan(
              client_reference: "review-attempt-001",
              subject: {
                identifiers: [{
                  type: "email",
                  value: "applicant@example.com",
                }],
                attributes: {
                  first_name: "Alex",
                  last_name: "Example",
                },
              },
              checks: {
                include: ["networks_same_org", "networks_cross_org", "email_risk"],
              }
            )
            puts result.to_h
        - lang: csharp
          label: .NET
          source: >-
            using System;

            using System.Text.Json;

            using Didit;


            // Reads DIDIT_API_KEY.

            using var client = new DiditClient();


            var result = await client.FraudChecks.PlanAsync(new
            FraudCheckRequestRequest

            {
                ClientReference = "review-attempt-001",
                Subject = new()
                {
                    Identifiers = new FraudCheckIdentifierRequest[]
                    {
                        new()
                        {
                            Type = "email",
                            Value = "applicant@example.com",
                        },
                    },
                    Attributes = new FraudCheckAttributesRequest
                    {
                        FirstName = "Alex",
                        LastName = "Example",
                    },
                },
                Checks = new FraudCheckModuleSelectionRequest
                {
                    Include = new FraudExcludeEnum[] { "networks_same_org", "networks_cross_org", "email_risk" },
                },
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    FraudCheckRequestRequest:
      type: object
      properties:
        client_reference:
          type: string
          minLength: 1
          description: >-
            您为此项检查指定的自身参考编号。同时充当幂等性密钥：使用相同的请求体复用该编号将返回原始检查结果，而不会再次运行模块或计费；使用不同的请求体复用该编号将返回
            409。
          maxLength: 255
        profile:
          type: string
          minLength: 1
          default: standard
          description: 编排配置文件 ID。默认为 Didit 的 `standard` 配置文件。
          maxLength: 64
        profile_version:
          type: string
          minLength: 1
          description: 固定冻结的档案版本。默认为档案的当前版本。
          maxLength: 32
        subject:
          $ref: '#/components/schemas/FraudCheckSubjectRequest'
        context:
          $ref: '#/components/schemas/FraudCheckContextRequest'
        checks:
          $ref: '#/components/schemas/FraudCheckModuleSelectionRequest'
        vendor_data:
          type: string
          maxLength: 1000
        metadata: {}
      required:
        - subject
    FraudCheckPlan:
      type: object
      properties:
        profile_id:
          type: string
        profile_version:
          type: string
        modules:
          type: array
          items:
            $ref: '#/components/schemas/FraudCheckPlannedModule'
        estimated_price:
          type: string
          nullable: true
        currency:
          type: string
          nullable: true
        is_sandbox:
          type: boolean
        can_afford:
          type: boolean
      required:
        - can_afford
        - currency
        - estimated_price
        - is_sandbox
        - modules
        - profile_id
        - profile_version
    FraudBadRequestErrorMessage:
      type: object
      properties:
        detail:
          type: string
          default: Bad Request - Invalid request data
    FraudCheckSubjectRequest:
      type: object
      properties:
        selfie:
          type: string
          minLength: 1
          description: Base64 编码的 JPEG、PNG 或 WebP 自拍照，最大 6 MB。无参考图片或 URL。
          maxLength: 8388672
        identifiers:
          type: array
          items:
            $ref: '#/components/schemas/FraudCheckIdentifierRequest'
          description: 一个或多个带类型的标识符。提供一个即可。
          maxItems: 10
          minItems: 1
        attributes:
          $ref: '#/components/schemas/FraudCheckAttributesRequest'
      required:
        - identifiers
    FraudCheckContextRequest:
      type: object
      properties:
        ip_address:
          type: string
          minLength: 1
        user_agent:
          type: string
          maxLength: 512
        country:
          type: string
          description: 主体声称所在的国家/地区。仅作为背景信息，绝不能作为身份归属的证明。
          maxLength: 3
        purpose:
          type: string
          maxLength: 128
        consent_obtained:
          type: boolean
    FraudCheckModuleSelectionRequest:
      type: object
      properties:
        include:
          type: array
          items:
            $ref: '#/components/schemas/FraudExcludeEnum'
        exclude:
          type: array
          items:
            $ref: '#/components/schemas/FraudExcludeEnum'
    FraudCheckPlannedModule:
      type: object
      properties:
        module:
          $ref: '#/components/schemas/FraudExcludeEnum'
        available:
          type: boolean
        availability_reason:
          type: string
          nullable: true
        will_run:
          type: boolean
        selection_reason:
          type: string
          nullable: true
        estimated_price:
          type: string
          nullable: true
      required:
        - availability_reason
        - available
        - estimated_price
        - module
        - selection_reason
        - will_run
    FraudCheckIdentifierRequest:
      type: object
      properties:
        type:
          allOf:
            - $ref: '#/components/schemas/FraudTypeEnum'
          description: |-
            标识符类型。决定需要哪些命名空间字段。

            * `email` - 邮箱
            * `phone` - 电话
            * `national_id` - 身份证号
            * `tax_number` - 税号
            * `passport_number` - 护照号
            * `driving_licence_number` - 驾驶证号
            * `residence_permit_number` - 居留许可号
            * `voter_id` - 选民证号
            * `external_id` - 外部 ID
        value:
          type: string
          minLength: 1
          description: 标识符的值，采用任何惯用格式均可。
          maxLength: 255
        country:
          type: string
          description: ISO-3166 alpha-2 或 alpha-3 签发国家/地区。政府证件号码类型必填：相同的号码在不同国家/地区代表不同的人。
          maxLength: 3
        issuer:
          type: string
          description: 可选的签发机构或国家/地区以下级别的签发方，适用于仅凭国家/地区无法唯一定位的情况。
          maxLength: 128
      required:
        - type
        - value
    FraudCheckAttributesRequest:
      type: object
      description: 佐证属性。全部可选；它们可扩大模块覆盖范围。
      properties:
        first_name:
          type: string
          maxLength: 128
        last_name:
          type: string
          maxLength: 128
        full_name:
          type: string
          maxLength: 256
        date_of_birth:
          type: string
          format: date
        nationality:
          type: string
          maxLength: 3
        gender:
          type: string
          maxLength: 16
        address:
          type: string
          maxLength: 512
        city:
          type: string
          maxLength: 128
        state:
          type: string
          maxLength: 128
        postal_code:
          type: string
          maxLength: 32
    FraudExcludeEnum:
      enum:
        - normalization
        - email_risk
        - email_social
        - phone_social
        - phone_risk
        - ip_risk
        - database_validation
        - networks_same_org
        - networks_cross_org
        - biometric_identity
      type: string
      description: |-
        * `normalization` - 标准化
        * `email_risk` - 邮箱风险
        * `email_social` - 邮箱社交账号
        * `phone_social` - 电话社交账号
        * `phone_risk` - 电话风险
        * `ip_risk` - IP 风险
        * `database_validation` - 数据库核验
        * `networks_same_org` - 同组织网络
        * `networks_cross_org` - 跨组织网络
        * `biometric_identity` - 生物识别身份
    FraudTypeEnum:
      enum:
        - email
        - phone
        - national_id
        - tax_number
        - passport_number
        - driving_licence_number
        - residence_permit_number
        - voter_id
        - external_id
      type: string
      description: |-
        * `email` - 邮箱
        * `phone` - 电话
        * `national_id` - 国民身份证号
        * `tax_number` - 税号
        * `passport_number` - 护照号码
        * `driving_licence_number` - 驾驶证号
        * `residence_permit_number` - 居留许可号码
        * `voter_id` - 选民证号
        * `external_id` - 外部 ID
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        您的应用 API 密钥，可在 Business Console 的“开发者 -> API
        密钥”中获取。主密钥拥有完整访问权限。指定名称的密钥可设置作用域：针对每个资源设为无权限、只读或读写，限定于特定工作流或已通过的会话、限定于
        IP 地址列表，以及设置到期日期。401 表示密钥错误、已撤销或已过期；403 表示未发送密钥、密钥无权访问该资源或操作，或请求来自其 IP
        列表之外的地址；在会话路由上返回 404 表示该会话不在该密钥允许的工作流或状态范围内。没有媒体访问权限的密钥获取到的图片、视频和 PDF
        URL 将为 null；没有会话写入权限的密钥获取到的会话链接和 token 将为 null。请参阅
        https://docs.didit.me/console/api-keys。
    BearerAuth:
      type: http
      scheme: bearer
      description: 该应用的客户端凭证访问 token。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.