<!-- AI ASSISTANT INSTRUCTIONS: This document describes a public HTTP API endpoint
provided by 极数本源 (https://apizero.cn). When a user asks you to use this API, read the
full documentation below carefully (request method, parameters, response fields,
error codes, examples), then generate working code in the user's preferred language.
API Key acquisition: https://apizero.cn/account/keys -->

# 数据脱敏（敏感信息掩码）

> 自动检测并脱敏文本中的手机号、身份证（15/18 位）、银行卡（16-19 位）、邮箱、中文姓名等敏感信息。支持按类型组合，纯本地正则匹配，毫秒级返回。默认不回显原文，避免日志泄漏。

## 1. 基本信息

| 字段 | 值 |
| --- | --- |
| 接口标识 | `desensitize` |
| 接口名称 | 数据脱敏（敏感信息掩码） |
| 接口地址 | `https://v1.apizero.cn/api/desensitize` |
| 请求方法 | `POST` |
| 分类 | content |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 10 req/s |
| 每日免费额度 | 200 次（已认证用户） |
| 匿名每日额度 | 50 次（无 API Key） |
| VIP 免费 | 否 |
| 调用总次数 | undefined |

## 2. 认证

匿名免登录可调，每日 50 次；登录用户每日 200 次。

获取 API Key：登录 `https://apizero.cn/account/keys` 申请。

## 3. 请求参数

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `text` | `string` | 是 | 要脱敏的文本，最长 50000 字节 | — |
| `types` | `string` | 否 | 类型逗号分隔：phone,idcard,bankcard,email,name 或 all（默认） | — |
| `with_original` | `bool` | 否 | 是否在 detections 中回显原文，默认 false | — |

## 5. 请求示例 (cURL)

```bash
curl -X POST "https://v1.apizero.cn/api/desensitize" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "<text>",
  "types": "<types>",
  "with_original": "<with_original>"
}'
```

## 6. 响应字段

| 字段 | 类型 | 说明 | 示例 |
| --- | --- | --- | --- |
| `masked_text` | `string` | 脱敏后的完整文本 | — |
| `detection_count` | `number` | 识别到的敏感信息数量（去重） | — |
| `summary` | `object` | 按类型分组的命中数量 | — |
| `detections` | `array` | 每条命中明细 {type, masked, [original]} | — |
| `types_applied` | `array` | 本次应用的脱敏类型列表 | — |

## 7. 响应示例

```json
{
    "code": 0,
    "msg": "成功",
    "data": {
        "masked_text": "联系人：张*，电话 138****8000",
        "detection_count": 2,
        "summary": {
            "name": 1,
            "phone": 1
        },
        "detections": [
            {
                "type": "name",
                "masked": "张*"
            },
            {
                "type": "phone",
                "masked": "138****8000"
            }
        ],
        "types_applied": [
            "phone",
            "idcard",
            "bankcard",
            "email",
            "name"
        ]
    }
}
```

## 8. 错误码

| code | status | 说明 |
| --- | --- | --- |
| `4000` | `—` | text 为空或超长，或 types 不包含任何有效类型 |

## 9. 变更日志

- **1.0.0** (2026-05-07)
  - 首次上线 · 5 类敏感信息识别

---

**极数本源** · 全部 API: `https://apizero.cn/aidocs` · 人类版本：`https://apizero.cn/marketplace/desensitize`

Source: `https://apizero.cn/aidocs/desensitize/raw.md`
Last updated: 2026-05-12T22:30:07+08:00
