> ## 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.

# 加入黑名单 API：拉黑会话项

> POST /v3/blocklist/add/：将 Didit 验证会话中的人脸、证件、电话号码或邮箱加入黑名单，使匹配的新会话被拒绝。



添加到黑名单 API 提示词
        将提示词复制到剪贴板



      
      

\<pre>

\`Blocklist the face, document, phone number or email address of one of my Didit verification sessions through the Management API.

Endpoint:
POST https://verification.didit.me/v3/blocklist/add/

Authentication:
Use the x-api-key header with my Didit API key. A scoped API key needs workflows: write.

Goal:
\- After reviewing a fraudulent session, block what it collected so the same person is declined next time.

Request body (application/json):
\{
"session_id": "33333333-4444-5555-6666-777777777777", // required: a verification session of my application
"blocklist_face": true,       // optional, default false
"blocklist_document": true,   // optional, default false
"blocklist_phone": false,     // optional, default false
"blocklist_email": false      // optional, default false
}
At least one blocklist_* flag must be true.

Behavior:
\- Didit uses the session's most recent record of each selected type.
\- Each selected record is flagged as blocklisted and gets an entry, linked to the session, in the matching system blocklist (added_by "api").
\- From then on, new sessions with a matching face, document number, phone number or email address are declined.
\- The session itself and sessions that already finished are not changed.
\- Safe to repeat: an item already listed keeps its single entry, and its blocklisted_at is refreshed.
\- All or nothing: Didit checks every selected item first. If one is missing, nothing is blocklisted.
\- A document needs its issuing state, document type, document number and full name.

Example call:
curl -X POST "https://verification.didit.me/v3/blocklist/add/" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"session_id": "33333333-4444-5555-6666-777777777777", "blocklist_face": true, "blocklist_document": true}'

Example response (200):
\{ "message": "Successfully updated blocklist." }

Failure modes:
\- 400: session_id is missing ({ "session_id": ["This field is required."] }) or not a UUID ({ "session_id": ["Must be a valid UUID."] }); the session is not a verification session of this application ({ "non_field_errors": ["Session not found"] }; business verification sessions are not accepted); no flag is true ({ "non_field_errors": ["Must specify at least one item to blocklist"] }); the session has no record of a selected type ({ "non_field_errors": ["Session does not have a face record"] }); or the document lacks a required field.
\- 401: the API key has expired.
\- 403: missing x-api-key (a wrong, revoked or expired key gets 401) ({ "detail": "You do not have permission to perform this action." }), or a scoped key without workflows: write.
\- 429: rate limited (see /integration/rate-limiting); back off and retry.

Side effects:
\- Writes entries to the system face, document, phone and email blocklists and blocks matching new sessions.

To block a value without a session, or an IP address, device fingerprint, user or business, use POST /v3/lists/{list_uuid}/entries/ on the matching system blocklist instead.

For the full integration shape, see /integration/integration-prompt.`

\</pre>



      
      

粘贴到

将一次验证会话收集的人脸、身份证件、电话号码或电子邮箱地址加入黑名单。Didit 会将每条所选记录标记为已加入黑名单，并将其添加到对应的系统黑名单中，并与该会话关联。此后，人脸、证件号码、电话号码或电子邮箱地址与黑名单匹配的新会话都会被拒绝。> [!NOTE]
>
> 该调用要么全部成功，要么全部不执行：如果会话中没有所选类型的记录，或证件缺少签发国家/地区、证件类型、证件号码或姓名，接口将返回 `400`，且不会加入任何黑名单。对已在黑名单中的项目重复调用是安全的。如需查看当前被封禁的内容，请使用[列出已加入黑名单的项目](https://docs.didit.me/zh/management-api/blocklist/list.md)。如需解除封禁，请使用[从黑名单中移除](https://docs.didit.me/zh/management-api/blocklist/remove.md)。如需封禁 IP 地址、设备指纹、用户、企业或不关联会话的值，请使用[创建条目](https://docs.didit.me/zh/management-api/lists/create-entry.md)将其添加到对应的系统黑名单中。有关黑名单的执行方式，请参阅[用户黑名单](https://docs.didit.me/zh/entities/users/blocklist.md)。


## OpenAPI

````yaml zh/openapi-25.json POST /v3/blocklist/add/
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/blocklist/add/:
    post:
      tags:
        - Blocklist
      summary: 将会话条目添加到黑名单
      description: >-
        将应用的某个人员验证会话的人脸、身份证件、电话号码或邮箱地址加入黑名单。对于所选的每种类型，Didit
        会获取该会话的最新记录，将其标记为已加入黑名单，并向匹配的系统黑名单添加一条关联到该会话的条目（`added_by:
        "api"`），因此具有匹配人脸、证件号码、电话号码或邮箱地址的新会话将被拒绝。首先会检查每个选定的项目，因此如果缺少其中任何一项，则不会将任何内容加入黑名单；对已列出的项目重复调用会保留其单条条目并刷新
        `blocklisted_at`。会话本身以及已完成的会话不会发生更改。限定作用域的 API 密钥需要 `workflows: write`
        权限。
      operationId: add_to_blocklist
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - session_id
              description: 至少一个 `blocklist_*` 标志必须为 `true`。
              properties:
                session_id:
                  type: string
                  format: uuid
                  description: 您应用的个人验证会话。已删除的会话会被拒绝。
                blocklist_face:
                  type: boolean
                  default: false
                  description: 将该会话的人脸加入黑名单。
                blocklist_document:
                  type: boolean
                  default: false
                  description: 将该会话的身份证件加入黑名单。证件需要具备签发州、证件类型、证件号码和姓名。
                blocklist_phone:
                  type: boolean
                  default: false
                  description: 将该会话的电话号码加入黑名单。
                blocklist_email:
                  type: boolean
                  default: false
                  description: 将该会话的邮箱地址加入黑名单。
            examples:
              Face and document:
                value:
                  session_id: 33333333-4444-5555-6666-777777777777
                  blocklist_face: true
                  blocklist_document: true
              Phone only:
                value:
                  session_id: 33333333-4444-5555-6666-777777777777
                  blocklist_phone: true
      responses:
        '200':
          description: 所选项目已被列入黑名单。
          content:
            application/json:
              schema:
                type: object
                required:
                  - message
                properties:
                  message:
                    type: string
                    description: 始终为 `Successfully updated blocklist.`
              examples:
                Blocklisted:
                  value:
                    message: Successfully updated blocklist.
        '400':
          description: 请求体无效、会话不是该应用的验证会话，或者不包含所选类型的记录。没有任何内容被加入黑名单。
          content:
            application/json:
              examples:
                Unknown session:
                  value:
                    non_field_errors:
                      - Session not found
                No item selected:
                  value:
                    non_field_errors:
                      - Must specify at least one item to blocklist
                No face record:
                  value:
                    non_field_errors:
                      - Session does not have a face record
                Incomplete document:
                  value:
                    non_field_errors:
                      - >-
                        To blocklist a document, the document must have an
                        issuing state, document type, document number and full
                        name
                Invalid session id:
                  value:
                    session_id:
                      - Must be a valid UUID.
                Missing session id:
                  value:
                    session_id:
                      - This field is required.
        '401':
          description: 作用域 API 密钥已过期。其他身份验证失败将返回 `403`。
          content:
            application/json:
              examples:
                Expired API key:
                  value:
                    detail: This API key has expired.
        '403':
          description: >-
            缺少 `x-api-key` 请求头（错误、已撤销或已过期的密钥会返回 `401`），或者限定权限的 API 密钥缺少
            `workflows: write`，抑或是从其允许名单之外的 IP 地址使用。
          content:
            application/json:
              examples:
                Missing or invalid API key:
                  value:
                    detail: You do not have permission to perform this action.
                Scoped key without workflows access:
                  value:
                    detail: This API key has no write access to workflows.
        '429':
          $ref: '#/components/responses/RateLimitedWrite'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: |-
            curl -X POST 'https://verification.didit.me/v3/blocklist/add/' \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{
                "session_id": "33333333-4444-5555-6666-777777777777",
                "blocklist_face": true,
                "blocklist_document": true
              }'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.blocklist.add(
                session_id="33333333-4444-5555-6666-777777777777",
                blocklist_face=True,
                blocklist_document=True,
            )
            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.blocklist.add({
              session_id: "33333333-4444-5555-6666-777777777777",
              blocklist_face: true,
              blocklist_document: true,
            });
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.Blocklist.Add(ctx, didit.BlocklistAddParams{\n\tSessionID:         \"33333333-4444-5555-6666-777777777777\",\n\tBlocklistFace:     didit.Bool(true),\n\tBlocklistDocument: didit.Bool(true),\n})\nif err != nil {\n\tlog.Fatal(err)\n}\nfmt.Printf(\"%+v\\n\", result)"
        - lang: java
          label: Java
          source: |-
            import me.didit.Didit;
            import me.didit.types.BlocklistAddParams;

            // Reads DIDIT_API_KEY.
            Didit client = new Didit();

            var result = client.blocklist().add(BlocklistAddParams.builder()
                    .sessionId("33333333-4444-5555-6666-777777777777")
                    .blocklistFace(true)
                    .blocklistDocument(true)
                    .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->blocklist->add([
                'session_id' => '33333333-4444-5555-6666-777777777777',
                'blocklist_face' => true,
                'blocklist_document' => true,
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

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

            result = didit.blocklist.add(
              session_id: "33333333-4444-5555-6666-777777777777",
              blocklist_face: true,
              blocklist_document: true
            )
            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.Blocklist.AddAsync(new BlocklistAddParams
            {
                SessionId = "33333333-4444-5555-6666-777777777777",
                BlocklistFace = true,
                BlocklistDocument = true,
            });
            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  responses:
    RateLimitedWrite:
      description: 已超出每个 API 密钥每分钟 300 次请求的共享写入限制。在重试之前请遵循 `Retry-After`。
      content:
        application/json:
          schema:
            type: object
            required:
              - detail
            properties:
              detail:
                type: string
          example:
            detail: >-
              Write request rate limit exceeded. You can make up to 300 requests
              per minute.
  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。

````

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