Didit Face Match API
Overview
Compares two facial images to determine if they belong to the same person. Returns a similarity score (0-100).
Key constraints:
- - Supported formats: JPEG, PNG, WebP, TIFF
- Maximum file size: 5MB per image
- If multiple faces in an image, the largest face is used for comparison
- Both
user_image and ref_image are required
Capabilities: Similarity scoring, age estimation, gender detection, face bounding boxes, configurable decline threshold, optional image rotation for non-upright faces.
API Reference: https://docs.didit.me/standalone-apis/face-match
Feature Guide: https://docs.didit.me/core-technology/face-match/overview
Authentication
All requests require x-api-key header. Get your key from Didit Business Console → API & Webhooks, or via programmatic registration (see below).
Getting Started (No Account Yet?)
If you don't have a Didit API key, create one in 2 API calls:
- 1. Register:
POST https://apx.didit.me/auth/v2/programmatic/register/ with INLINECODE4 - Check email for a 6-character OTP code
- Verify:
POST https://apx.didit.me/auth/v2/programmatic/verify-email/ with {"email": "you@gmail.com", "code": "A3K9F2"} → response includes INLINECODE7
To add credits: GET /v3/billing/balance/ to check, POST /v3/billing/top-up/ with {"amount_in_dollars": 50} for a Stripe checkout link.
See the didit-verification-management skill for full platform management (workflows, sessions, users, billing).
Endpoint
CODEBLOCK0
Headers
| Header | Value | Required |
|---|
| INLINECODE11 | Your API key | Yes |
| INLINECODE12 |
multipart/form-data |
Yes |
Request Parameters (multipart/form-data)
| Parameter | Type | Required | Default | Constraints | Description |
|---|
| INLINECODE14 | file | Yes | — | JPEG/PNG/WebP/TIFF, max 5MB | User's face image to verify |
| INLINECODE15 |
file |
Yes | — | Same as above | Reference image to compare against |
|
face_match_score_decline_threshold | integer | No |
30 | 0-100 | Scores below this = Declined |
|
rotate_image | boolean | No |
false | — | Try 0/90/180/270 degree rotations to find upright face |
|
save_api_request | boolean | No |
true | — | Save in Business Console Manual Checks |
|
vendor_data | string | No | — | — | Your identifier for session tracking |
Example
CODEBLOCK1
CODEBLOCK2
Response (200 OK)
CODEBLOCK3
Status Values & Handling
| Status | Meaning | Action |
|---|
| INLINECODE23 | Score >= threshold | Faces match — proceed |
| INLINECODE24 |
Score < threshold or no face | Check
warnings for details. May need better image |
|
"In Review" | Needs manual review | Wait for review or retrieve via session API |
Error Responses
| Code | Meaning | Action |
|---|
| INLINECODE27 | Invalid request | Check file format, size, parameters |
| INLINECODE28 |
Invalid API key | Verify
x-api-key header |
|
403 | Insufficient credits | Top up at business.didit.me |
Response Field Reference
| Field | Type | Description |
|---|
| INLINECODE31 | string | INLINECODE32 , "Declined", INLINECODE34 |
| INLINECODE35 |
integer | 0-100 similarity score (higher = more similar).
null if no face found |
|
entities[].age | float | Estimated age |
|
entities[].bbox | array | Face bounding box
[x1, y1, x2, y2] |
|
entities[].confidence | float | Face detection confidence (0-1) |
|
entities[].gender | string |
"male" or
"female" |
|
best_angle | integer | Best rotation angle for the face |
|
warnings | array |
{risk, log_type, short_description, long_description} |
Warning Tags
| Tag | Description | Auto-Decline |
|---|
| INLINECODE47 | Reference or face image missing | Yes |
| INLINECODE48 |
No face detected in one or both images | Yes |
|
LOW_FACE_MATCH_SIMILARITY | Score below threshold — potential identity mismatch | Configurable |
Security best practice: Only store the status and score. Minimize biometric image data on your servers. Image URLs (in workflow mode) expire after 60 minutes.
Score Interpretation
| Score Range | Interpretation | Action |
|---|
| 90-100 | Very high confidence — same person | Auto-approve |
| 70-89 |
High confidence — likely same person | Approve (default threshold 30) |
| 50-69 | Moderate — possible match | Consider manual review |
| 30-49 | Low — likely different people | Declined at default threshold |
| 0-29 | Very low — different people | Declined |
Utility Scripts
CODEBLOCK4
Didit 人脸匹配 API
概述
比较两张人脸图像,判断是否属于同一个人。返回相似度评分(0-100)。
关键限制:
- - 支持的格式:JPEG、PNG、WebP、TIFF
- 最大文件大小:每张图片 5MB
- 如果图片中有多张人脸,使用最大的人脸进行比较
- userimage 和 refimage 均为必填项
功能: 相似度评分、年龄估计、性别检测、人脸边界框、可配置拒绝阈值、非正面人脸的可选图像旋转。
API 参考: https://docs.didit.me/standalone-apis/face-match
功能指南: https://docs.didit.me/core-technology/face-match/overview
身份验证
所有请求都需要 x-api-key 标头。从 Didit 业务控制台 → API 和 Webhooks 获取您的密钥,或通过编程方式注册(见下文)。
快速入门(还没有账户?)
如果您没有 Didit API 密钥,通过 2 个 API 调用创建一个:
- 1. 注册: POST https://apx.didit.me/auth/v2/programmatic/register/,携带 {email: you@gmail.com, password: MyStr0ng!Pass}
- 检查电子邮件 获取 6 位 OTP 验证码
- 验证: POST https://apx.didit.me/auth/v2/programmatic/verify-email/,携带 {email: you@gmail.com, code: A3K9F2} → 响应中包含 api_key
添加积分: GET /v3/billing/balance/ 检查余额,POST /v3/billing/top-up/ 携带 {amountindollars: 50} 获取 Stripe 结账链接。
完整的平台管理(工作流、会话、用户、计费)请参阅 didit-verification-management 技能。
端点
POST https://verification.didit.me/v3/face-match/
请求头
| 请求头 | 值 | 必填 |
|---|
| x-api-key | 您的 API 密钥 | 是 |
| Content-Type |
multipart/form-data |
是 |
请求参数(multipart/form-data)
| 参数 | 类型 | 必填 | 默认值 | 约束 | 描述 |
|---|
| userimage | 文件 | 是 | — | JPEG/PNG/WebP/TIFF,最大 5MB | 待验证的用户人脸图像 |
| refimage |
文件 |
是 | — | 同上 | 用于比较的参考图像 |
| face
matchscore
declinethreshold | 整数 | 否 | 30 | 0-100 | 低于此分数的结果 = 拒绝 |
| rotate_image | 布尔值 | 否 | false | — | 尝试 0/90/180/270 度旋转以找到正面人脸 |
| save
apirequest | 布尔值 | 否 | true | — | 保存在业务控制台手动检查中 |
| vendor_data | 字符串 | 否 | — | — | 用于会话跟踪的标识符 |
示例
python
import requests
response = requests.post(
https://verification.didit.me/v3/face-match/,
headers={x-api-key: YOURAPIKEY},
files={
user_image: (selfie.jpg, open(selfie.jpg, rb), image/jpeg),
refimage: (idphoto.jpg, open(id_photo.jpg, rb), image/jpeg),
},
data={facematchscoredeclinethreshold: 50},
)
typescript
const formData = new FormData();
formData.append(user_image, selfieFile);
formData.append(ref_image, referenceFile);
formData.append(facematchscoredeclinethreshold, 50);
const response = await fetch(https://verification.didit.me/v3/face-match/, {
method: POST,
headers: { x-api-key: YOURAPIKEY },
body: formData,
});
响应(200 OK)
json
{
request_id: a1b2c3d4-...,
face_match: {
status: Approved,
score: 80,
user_image: {
entities: [
{age: 27.63, bbox: [40, 40, 100, 100], confidence: 0.717, gender: male}
],
best_angle: 0
},
ref_image: {
entities: [
{age: 22.16, bbox: [156, 234, 679, 898], confidence: 0.717, gender: male}
],
best_angle: 0
},
warnings: []
},
created_at: 2025-05-01T13:11:07.977806Z
}
状态值及处理
| 状态 | 含义 | 操作 |
|---|
| Approved | 分数 >= 阈值 | 人脸匹配 — 继续 |
| Declined |
分数 < 阈值或未检测到人脸 | 查看 warnings 了解详情。可能需要更好的图像 |
| In Review | 需要人工审核 | 等待审核或通过会话 API 检索 |
错误响应
| 状态码 | 含义 | 操作 |
|---|
| 400 | 无效请求 | 检查文件格式、大小、参数 |
| 401 |
无效 API 密钥 | 验证 x-api-key 请求头 |
| 403 | 积分不足 | 在 business.didit.me 充值 |
响应字段参考
| 字段 | 类型 | 描述 |
|---|
| status | 字符串 | Approved、Declined、In Review |
| score |
整数 | 0-100 相似度评分(越高越相似)。未检测到人脸时为 null |
| entities[].age | 浮点数 | 估计年龄 |
| entities[].bbox | 数组 | 人脸边界框 [x1, y1, x2, y2] |
| entities[].confidence | 浮点数 | 人脸检测置信度(0-1) |
| entities[].gender | 字符串 | male 或 female |
| best_angle | 整数 | 人脸的最佳旋转角度 |
| warnings | 数组 | {risk, log
type, shortdescription, long_description} |
警告标签
| 标签 | 描述 | 自动拒绝 |
|---|
| NOREFERENCEIMAGE | 参考图像或人脸图像缺失 | 是 |
| NOFACEDETECTED |
一张或两张图像中未检测到人脸 | 是 |
| LOW
FACEMATCH_SIMILARITY | 分数低于阈值 — 潜在身份不匹配 | 可配置 |
安全最佳实践: 仅存储状态和分数。尽量减少服务器上的生物特征图像数据。图像 URL(在工作流模式下)60 分钟后过期。
分数解读
| 分数范围 | 解读 | 操作 |
|---|
| 90-100 | 非常高的置信度 — 同一个人 | 自动批准 |
| 70-89 |
高置信度 — 很可能是同一个人 | 批准(默认阈值 30) |
| 50-69 | 中等 — 可能匹配 | 考虑人工审核 |
| 30-49 | 低 — 很可能是不同的人 | 默认阈值下拒绝 |
| 0-29 | 非常低 — 不同的人 | 拒绝 |
实用脚本
bash
export DIDITAPIKEY=yourapikey
python scripts/matchfaces.py selfie.jpg idphoto.jpg
python scripts/matchfaces.py selfie.jpg idphoto.jpg --threshold 50 --rotate