> ## 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：封禁或标记用户

> 封禁、标记或激活 Didit 供应商用户。状态会同步至后续 KYC 会话和交易筛查。按调用次数付费的用户管理功能。



更新用户状态提示词
        将提示词复制到剪贴板



      
      

\<pre>

\`Goal: Flip ONLY the lifecycle status of a Didit User entity. Use the full PATCH /v3/users/{vendor_data}/ when you also need to touch other fields.

Endpoint: PATCH https://verification.didit.me/v3/users/{vendor_data}/update-status/
Auth header: x-api-key: <DIDIT_API_KEY>
Content-Type: application/json

Path param:
\- vendor_data (string, REQUIRED) — free-form string, NOT a UUID. URL-encode.

Request body:
\- status (enum, REQUIRED) — "ACTIVE" | "FLAGGED" | "BLOCKED" (VendorUserStatusChoices, NOT the session enum).
\- reason (string, optional, max 1000): why the status changed. Recorded as the comment of the STATUS_CHANGED entry in the user's activity (comments[].comment), only when the status actually changes. Webhooks do not carry it.

Status semantics:
\- ACTIVE  → normal. New sessions allowed for this vendor_data.
\- FLAGGED → still accepted, highlighted in Console for manual review; filterable with ?status=FLAGGED.
\- BLOCKED → terminal. Adds vendor_data to the system blocklist. Subsequent session creations for the same identifier are rejected with a blocklist hit. Flipping back to ACTIVE/FLAGGED removes the blocklist entry automatically.

curl:
curl -X PATCH 'https://verification.didit.me/v3/users/user-abc-123/update-status/' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"status": "BLOCKED", "reason": "Chargeback fraud pattern confirmed"}'

Response 200: full updated UserDetailItem (same shape as GET /v3/users/{vendor_data}/). See /reference/data-models.

Side effects:
\- Toggles the system blocklist entry when entering/leaving BLOCKED.
\- Writes one STATUS_CHANGED entry to the user's comments activity log (actor = API key identity), with reason as its comment.
\- Idempotent — re-sending the same status is a no-op (no extra audit row, no extra blocklist toggle).

Failure modes:
\- 400 — validation:
\{ "status": "This field is required." }
\{ "status": "Invalid status. Valid options are: ACTIVE, FLAGGED, BLOCKED" }
\{ "reason": ["Ensure this field has no more than 1000 characters."] }
\- 401 — missing/invalid x-api-key. { "detail": "Authentication credentials were not provided." }
\- 403 — the API key is revoked or is not valid for this application. { "detail": "You do not have permission to perform this action." }
\- 403: a scoped API key without users write. { "detail": "This API key has no write access to people." }
\- 404 — vendor_data not found (or deleted). { "detail": "Not found." }
\- 429 — rate-limited.

For end-to-end Didit integration, paste in the full prompt at /integration/integration-prompt.`

\</pre>



      
      

粘贴到

## 概述在 `ACTIVE`、`FLAGGED` 和 `BLOCKED` 之间切换[用户实体](https://docs.didit.me/zh/entities/users/overview.md)的状态。完整的状态机说明请参阅[实体生命周期](https://docs.didit.me/zh/entities/lifecycle.md)。## 何时使用- **阻止用户**：确认存在欺诈或违反合规要求后使用。
- **标记用户**：等待人工审核期间使用，不直接阻止该用户。
- **解除阻止**：用户完成整改后使用。
- **同步外部信号**：例如，当你自己的欺诈引擎将某用户评分超过阈值时，通过此端点将其切换为 `FLAGGED`。## 注意事项- 有效值为 `ACTIVE`、`FLAGGED` 和 `BLOCKED`。无效值将返回 400。
- 可以传入可选的 `reason`（最多 1000 个字符），记录状态变更的原因。
  Didit 会将其保存为该用户活动记录中状态变更条目的备注：即用户的 `comments[].comment`，并显示在 Business Console 的 **活动** 中。
  仅当状态确实发生变化时才会记录。
- `BLOCKED` 用户的所有新会话都将被自动拒绝，所有新交易也都将被自动拒绝。
- 触发 `user.status.updated` Webhook 事件，其中包含 `previous_status` 和 `status`。
  该 Webhook 不包含 `reason`。## 执行规则| 状态 | 对新会话的影响 | 对新交易的影响 |
| - | - | - |
| `ACTIVE` | 正常流程 | 正常流程 |
| `FLAGGED` | 允许，但转入 `IN_REVIEW` | 允许；可能根据规则自动升级 |
| `BLOCKED` | 自动拒绝 | 自动拒绝 |## 权限主密钥和拥有完全访问权限的 [API 密钥](https://docs.didit.me/zh/console/api-keys.md) 始终可以调用此端点。
具有自定义访问权限的密钥需要 **People**（`users`）写入权限。
仅限某些工作流或已通过的会话的密钥无法访问此 endpoint。控制台的[角色与权限](https://docs.didit.me/zh/console/roles-permissions.md)决定团队成员在控制台中可以执行的操作。
在 API 密钥请求中不会评估这些角色和权限。## 相关内容- [实体生命周期](https://docs.didit.me/zh/entities/lifecycle.md)
- [用户黑名单](https://docs.didit.me/zh/entities/users/blocklist.md)
- [实体 Webhook](https://docs.didit.me/zh/entities/webhooks.md)


## OpenAPI

````yaml zh/openapi-25.json PATCH /v3/users/{vendor_data}/update-status/
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/users/{vendor_data}/update-status/:
    patch:
      tags:
        - Users
      summary: 更新用户状态
      description: >-
        仅切换用户的生命周期 `status`：`ACTIVE`、`FLAGGED` 或 `BLOCKED`（非会话状态）。`BLOCKED` 会将
        `vendor_data` 添加到系统黑名单中；脱离 `BLOCKED` 状态则会移除该条目。每次变更都会记录为用户的
        `STATUS_CHANGED` 活动，并将可选的 `reason` 作为其 `comment`。发送当前状态不会产生任何更改，也不会记录
        `reason`。`user.status.updated` Webhook 不包含 `reason`。
      operationId: update_user_status
      parameters:
        - name: vendor_data
          in: path
          required: true
          schema:
            type: string
          description: 您对该用户的唯一标识符。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/EntityStatusUpdateRequest'
                - type: object
                  properties:
                    reason:
                      type: string
                      nullable: true
                      maxLength: 1000
                      description: >-
                        状态变更的原因。仅在状态实际变更时，记录在用户活动的状态变更条目（`comments[].comment`，以及
                        Business Console 中的 **Activity**）上。Webhook 不包含此项。
            examples:
              Activate:
                summary: 重新激活用户
                value:
                  status: ACTIVE
              Flag:
                summary: 标记用户以待审核
                value:
                  status: FLAGGED
              Block:
                summary: 拉黑该用户（添加到系统黑名单）
                value:
                  status: BLOCKED
              Block with reason:
                summary: 拉黑该用户并记录原因
                value:
                  status: BLOCKED
                  reason: Chargeback fraud pattern confirmed
      responses:
        '200':
          description: 用户状态已更新。返回完整用户记录。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserDetailItem'
              examples:
                Blocked:
                  value:
                    didit_internal_id: f4e5e1f2-94a9-4f86-8c16-2b7d9b4db418
                    vendor_data: user-abc-123
                    display_name: null
                    full_name: John Michael Doe
                    date_of_birth: '1990-05-15'
                    effective_name: John Michael Doe
                    status: BLOCKED
                    metadata:
                      tier: premium
                      source: website
                    portrait_image_url: https://<media-host>/...
                    session_count: 3
                    approved_count: 2
                    declined_count: 0
                    in_review_count: 1
                    issuing_states:
                      - USA
                    approved_emails:
                      - john@example.com
                    approved_phones:
                      - '+14155551234'
                    features:
                      ID_VERIFICATION: Approved
                      LIVENESS: Approved
                      FACE_MATCH: Approved
                      AML: Approved
                    features_list:
                      - feature: ID_VERIFICATION
                        status: Approved
                      - feature: LIVENESS
                        status: Approved
                      - feature: FACE_MATCH
                        status: Approved
                      - feature: AML
                        status: Approved
                    last_session_at: '2025-06-15T10:30:00Z'
                    last_activity_at: '2025-06-15T10:30:00Z'
                    first_session_at: '2025-06-01T08:00:00Z'
                    tags:
                      - uuid: 9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d
                        tag:
                          uuid: e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b
                          name: VIP
                          color: '#2567FF'
                          description: null
                          source: custom
                          created_at: '2025-05-01T09:00:00Z'
                          updated_at: '2025-05-01T09:00:00Z'
                        added_by_email: analyst@acme.com
                        added_by_name: Jane Analyst
                        created_at: '2025-06-02T11:00:00Z'
                    comments:
                      - uuid: c1111111-2222-4333-8444-555555555555
                        comment_type: STATUS_CHANGED
                        comment: Chargeback fraud pattern confirmed
                        actor_email: null
                        actor_name: null
                        previous_status: ACTIVE
                        new_status: BLOCKED
                        previous_value: null
                        new_value: null
                        changed_fields: []
                        metadata: null
                        mentioned_emails: []
                        created_at: '2025-06-15T10:30:00Z'
                    created_at: '2025-06-01T08:00:00Z'
                    updated_at: '2025-06-15T10:30:00Z'
        '400':
          description: '`status` 缺失或无效，或 `reason` 超过 1000 个字符。'
          content:
            application/json:
              examples:
                Missing status:
                  value:
                    status:
                      - This field is required.
                Bad status:
                  value:
                    status:
                      - >-
                        Invalid status. Valid options are: ACTIVE, FLAGGED,
                        BLOCKED
                Reason too long:
                  value:
                    reason:
                      - Ensure this field has no more than 1000 characters.
        '401':
          description: >-
            未提供凭证。对 `/v3/users/*` 路径的请求如果不包含 `x-api-key` 请求头（或 `Authorization:
            Bearer` token），将在到达 API 之前被身份验证中间件拒绝。
          content:
            application/json:
              examples:
                Missing credentials:
                  value:
                    detail: >-
                      You must be authenticated with a valid access token to
                      access this endpoint.
        '403':
          description: 该密钥无法更新此应用的用户。缺少密钥返回 `403`；错误、已撤销或已过期的密钥返回 `401`。
          content:
            application/json:
              examples:
                Forbidden:
                  value:
                    detail: You do not have permission to perform this action.
        '404':
          description: 该应用下不存在带有提供的 `vendor_data` 的（未删除）用户。
          content:
            application/json:
              examples:
                Not found:
                  value:
                    detail: Not found.
        '429':
          description: 超出速率限制；请退避并在 `Retry-After` 指定的间隔后重试。
          content:
            application/json:
              examples:
                Rate limited:
                  value:
                    detail: Request was throttled. Expected available in 30 seconds.
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: curl
          source: >-
            curl -X PATCH
            'https://verification.didit.me/v3/users/user-abc-123/update-status/'
            \
              -H 'x-api-key: YOUR_API_KEY' \
              -H 'Content-Type: application/json' \
              -d '{"status": "BLOCKED"}'
        - lang: python
          label: Python
          source: |-
            from didit import Didit

            # Reads DIDIT_API_KEY.
            client = Didit()

            result = client.users.update_status(
                "user-123",
                status="ACTIVE",
            )
            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.users.updateStatus("user-123", {
              status: "ACTIVE",
            });
            console.log(result);
        - lang: go
          label: Go
          source: "ctx := context.Background()\n// Reads DIDIT_API_KEY.\nclient := didit.NewClient()\n\nresult, err := client.Users.UpdateStatus(ctx, \"user-123\", didit.UsersUpdateStatusParams{\n\tStatus: \"ACTIVE\",\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.EntityStatusUpdateRequest;

            import me.didit.types.UsersUpdateStatusParams;


            // Reads DIDIT_API_KEY.

            Didit client = new Didit();


            var result = client.users().updateStatus("user-123",
            UsersUpdateStatusParams.builder()
                    .status(EntityStatusUpdateRequest.Status.of("ACTIVE"))
                    .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->users->updateStatus('user-123', [
                'status' => 'ACTIVE',
            ]);
            print_r($result->toArray());
        - lang: ruby
          label: Ruby
          source: |-
            require "didit"

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

            result = didit.users.update_status(
              "user-123",
              status: "ACTIVE"
            )
            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.Users.UpdateStatusAsync("user-123", new
            UsersUpdateStatusParams

            {
                Status = "ACTIVE",
            });

            Console.WriteLine(JsonSerializer.Serialize(result));
components:
  schemas:
    EntityStatusUpdateRequest:
      type: object
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - ACTIVE
            - FLAGGED
            - BLOCKED
          description: 新的生命周期状态。`BLOCKED` 还会将 `vendor_data` 添加到系统黑名单中。
    UserDetailItem:
      type: object
      description: 完整的用户详情。在 UserListItem 基础上扩展了元数据、备注和 updated_at。
      allOf:
        - $ref: '#/components/schemas/UserListItem'
        - type: object
          properties:
            metadata:
              type: object
              description: 您附加到此用户的自定义元数据 JSON。默认为 `{}`。
            tags:
              type: array
              description: >-
                标签分配情况。注意：与列表响应中使用的扁平 `{uuid, name, color}`
                结构不同，详情响应中的每个条目均为标签*链接*对象（`{uuid, tag: {...}, added_by_email,
                added_by_name, created_at}`）。
              items:
                type: object
                properties:
                  uuid:
                    type: string
                    format: uuid
                    description: 标签分配的 UUID（而非标签本身的 UUID）。
                  tag:
                    type: object
                    properties:
                      uuid:
                        type: string
                        format: uuid
                      name:
                        type: string
                      color:
                        type: string
                      description:
                        type: string
                        nullable: true
                      source:
                        type: string
                        enum:
                          - didit
                          - custom
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
                  added_by_email:
                    type: string
                    nullable: true
                  added_by_name:
                    type: string
                    nullable: true
                  created_at:
                    type: string
                    format: date-time
            comments:
              type: array
              items:
                type: object
                properties:
                  uuid:
                    type: string
                    format: uuid
                  comment_type:
                    type: string
                    enum:
                      - COMMENT
                      - STATUS_CHANGED
                      - METADATA_UPDATED
                      - TAG_ADDED
                      - TAG_REMOVED
                      - PROFILE_UPDATED
                  comment:
                    type: string
                    nullable: true
                  actor_email:
                    type: string
                    nullable: true
                  actor_name:
                    type: string
                    nullable: true
                  previous_status:
                    type: string
                    nullable: true
                    enum:
                      - ACTIVE
                      - FLAGGED
                      - BLOCKED
                      - null
                  new_status:
                    type: string
                    nullable: true
                    enum:
                      - ACTIVE
                      - FLAGGED
                      - BLOCKED
                      - null
                  previous_value:
                    type: object
                    nullable: true
                    description: PROFILE_UPDATED 条目的先前字段值。
                  new_value:
                    type: object
                    nullable: true
                    description: PROFILE_UPDATED 条目的新字段值。
                  changed_fields:
                    type: array
                    items:
                      type: string
                    description: 由 PROFILE_UPDATED 条目更改的字段名称。
                  metadata:
                    type: object
                    nullable: true
                  mentioned_emails:
                    type: array
                    items:
                      type: string
                  created_at:
                    type: string
                    format: date-time
              description: 该用户的活动日志和评论（状态变更、资料修改、手动备注）。
            updated_at:
              type: string
              format: date-time
    UserListItem:
      type: object
      description: 已验证的用户。
      properties:
        didit_internal_id:
          type: string
          format: uuid
          description: Didit 为此用户分配的稳定内部 UUID。
        vendor_data:
          type: string
          nullable: true
          description: 您对此用户的唯一标识符（创建会话时传入）。未提供供应商标识符时可为 null。
        display_name:
          type: string
          nullable: true
          description: 您设置的自定义显示名称
        full_name:
          type: string
          nullable: true
          description: 从已验证证件中提取的姓名
        date_of_birth:
          type: string
          format: date
          nullable: true
        effective_name:
          type: string
          nullable: true
          description: 最佳可用名称：如果已设置则为 display_name，否则为 full_name
        status:
          type: string
          enum:
            - ACTIVE
            - FLAGGED
            - BLOCKED
          description: >-
            用户记录的生命周期状态（并非会话状态）。`ACTIVE` 为默认值，`FLAGGED` 标记该用户需要人工关注，`BLOCKED`
            会阻止该 `vendor_data` 创建新会话。
        portrait_image_url:
          type: string
          nullable: true
          description: 用户肖像照片的预签名 URL（数小时后过期）
        session_count:
          type: integer
          description: 该用户的验证会话总数
        approved_count:
          type: integer
          description: 已通过的会话数量
        declined_count:
          type: integer
          description: 已拒绝的会话数量
        in_review_count:
          type: integer
          description: 审核中的会话数量
        issuing_states:
          type: array
          items:
            type: string
          description: >-
            此用户已通过的身份证件上显示的签发国家/地区的 ISO 3166-1 alpha-3 代码，例如 `["USA",
            "ESP"]`。无时为空数组。
        approved_emails:
          type: array
          items:
            type: string
          description: 从该用户已通过的会话中收集的已验证邮箱地址，例如 `["john@example.com"]`。
        approved_phones:
          type: array
          items:
            type: string
          description: 从该用户已通过的会话中收集的已验证电话号码，例如 `["+14155551234"]`。
        features:
          type: object
          description: >-
            该用户所有会话的每项功能汇总状态。可选键：`ID_VERIFICATION`、`NFC`、`LIVENESS`、`FACE_MATCH`、`POA`、`QUESTIONNAIRE`、`EMAIL_VERIFICATION`、`PHONE`、`AML`、`IP_ANALYSIS`、`AGE_ESTIMATION`、`DATABASE_VALIDATION`。可选值：`Approved`、`Declined`、`In
            Review`、`Not Finished`、`Resub Requested`。
        features_list:
          type: array
          items:
            type: object
            properties:
              feature:
                type: string
              status:
                type: string
          description: 与 `features` 相同的数据，为 `{feature, status}` 对象的有序数组。
        last_session_at:
          type: string
          format: date-time
          nullable: true
          description: 最近一次会话的时间戳
        first_session_at:
          type: string
          format: date-time
          nullable: true
          description: 首次会话的时间戳
        last_activity_at:
          type: string
          format: date-time
          nullable: true
          description: 该用户最近一次活动的时间戳（会话、交易、状态变更、数据编辑等）。
        tags:
          type: array
          items:
            type: object
            properties:
              uuid:
                type: string
                format: uuid
              name:
                type: string
              color:
                type: string
          description: 分配给该用户的标签
        created_at:
          type: string
          format: date-time
  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.