跳转到主要内容

创建文档流程

MarkdownChatGPTClaude

此端点处理两种共享相同路径但请求体参数不同的文档流程:

  • 新采集 — 以 base64 格式提交文档图像进行处理(需要 document.files)。
  • 复用 — 通过引用之前采集的文档跳过采集步骤(需要 document.documentId)。

实际执行哪种流程取决于请求体中是否提供了 document.documentId。

在创建文档流程之前,请使用获取可复用文档检查用户是否已有可供复用的文档。

完整集成流程请参阅 API 概览。

端点​

环境URL
生产环境POST https://api.id.unico.app/processes/v1
沙盒环境POST https://api.id.uat.unico.app/processes/v1

请求​

请求头
请求头值
AuthorizationBearer <access_token>(参见身份验证)
APIKEY已启用文档采集与复用功能的 API 密钥。
Content-Typeapplication/json
请求体参数
字段类型必填描述
subject.duiTypeinteger是文档类型标识符。请参阅下方的 duiType 值。
subject.codestring是由 subject.duiType 定义的用户标识符值。不含点号或破折号。
subject.namestring否全名。
subject.genderstring否M 或 F。
subject.birthDatestring (ISO 8601)否出生日期(YYYY-MM-DD)。
subject.emailstring否电子邮件地址。
subject.phonestring否E.164 格式电话号码。
document.purposestring是业务目的。可选值:creditprocess、carpurchase、paybypaycheck、onboarding、fgts。
document.authProcessIdstring是与此文档采集关联的生物特征流程 ID。
document.filesarray是base64 格式的文档图像(正面和/或背面)。
document.files[].datastring是base64 格式的文档图像(PNG、JPEG 或 WebP,最大 800 KB)。
subsidiaryIdstring否分支机构 ID — 仅在存在多个分支机构时需要。
duiType 值
国家代码描述
AR6阿根廷护照
AR7阿根廷 DNI
AR49阿根廷驾驶证(Licencia Nacional de Conducir)
AT34奥地利税号(STNR)
BE36比利时国家号码(NN)
BR1巴西 CPF
BR5巴西护照
BR14巴西 CNPJ
CA28加拿大 SIN
CH33瑞士 AHV/AVS 号码
CL9智利 RUN
CL52智利护照
CL57智利驾驶证(Licencia de Conducir)
CO26哥伦比亚 NIT
CO53哥伦比亚护照
CO55哥伦比亚驾驶证(Licencia de Conducción)
CO56哥伦比亚公民身份证(Cédula de Ciudadanía)
DE41德国税务识别号码(IdNr)
DK29丹麦 CPR
EC10厄瓜多尔 NI
ES50西班牙外国人身份号码(NIE)
ES51西班牙国民身份证(DNI)
FI35芬兰个人身份代码(HETU)
FR46法国税务参考号码(SPI)
GB30英国国民保险号码(NINO)
GT12危地马拉 CUI
ID16印度尼西亚 NIK
IE47爱尔兰个人公共服务号码(PPSN)
IT37意大利税务代码(CF)
LU48卢森堡国民身份号码(Matricule)
MX2墨西哥 CURP
MX25墨西哥 RFC(自然人)
MX58墨西哥驾驶证(Licencia de Conducir)
NG8尼日利亚 NIN
NG20尼日利亚银行验证号码(BVN)
NG43尼日利亚 BVN 令牌(哈希)
NG44尼日利亚 NIN 令牌(哈希)
NL42荷兰公民服务号码(BSN)
NO39挪威国民身份号码(Fødselsnummer)
PE27秘鲁 RUC
PE40秘鲁 DNI
PE54秘鲁护照
PL31波兰 PESEL
PT45葡萄牙税务识别号码(NIF)
SE32瑞典个人号码(PNR)
SE38瑞典协调号码(Samordningsnummer)
TR24土耳其身份证号码(TCKN)
US4美国 SSN
US11美国护照
US18美国驾驶执照
US21美国护照卡
US22美国聚碳酸酯护照
US23美国身份证
UY13乌拉圭 CI
ZZ15电子邮件地址
ZZ17电话号码
—0未指定
—3Unico 内部标识符

示例​

curl -X POST https://api.id.unico.app/processes/v1 \
-H "Authorization: Bearer $TOKEN" \
-H "APIKEY: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subject": {
"duiType": 1,
"code": "12345678909",
"name": "Luke Skywalker"
},
"document": {
"purpose": "onboarding",
"authProcessId": "80371b2a-3ac7-432e-866d-57fe37896ac6",
"files": [
{ "data": "/9j/4AAQSkZJR..." }
]
}
}'

响应​

200 OK
{
"id": "80371b2a-3ac7-432e-866d-57fe37896ac6",
"status": 3,
"document": {
"id": "doc-abc-123",
"type": "unico.moja.dictionary.br.cnh.v2.Cnh",
"cpfMatch": true,
"faceMatch": true,
"content": {
"numero": "12345678",
"nomeCivil": "Luke Skywalker",
"dataNascimento": "2000-05-20T00:00:00Z",
"categoria": "B",
"dataExpiracao": "2030-05-20T00:00:00Z"
},
"fileUrls": [
"https://storage.unico.app/documents/doc-abc-123/front.jpg"
]
}
}
字段类型描述
idstring (UUID)流程标识符。
statusinteger3(成功完成),5(失败完成)。
document.idstring采集的文档标识符。可在后续请求的 document.documentId 中使用此值进行复用。
document.typestring识别到的文档类型,以完全限定的字典名称表示。请参阅下方的 document.type 值。
document.cpfMatchboolean若从文档中提取的标识符与 subject.code 匹配,则为 true。
document.faceMatchboolean若文档人脸与 document.authProcessId 中的生物特征自拍匹配,则为 true。
document.contentobject通过 OCR 提取的字段。结构因文档类型而异 — 点击此处查看字段详情。
document.fileUrlsarray用于下载文档图像的临时 URL(有效期 10 分钟)。

document.content 中仅包含成功提取的字段;OCR 无法读取的内容会被省略,而不是返回为空。

document.type 值
统一架构

所有使用统一架构的文档类型(即字段参考中的 unified_schema)在 document.type 中均以 unico.moja.dictionary.<country>.generic.v1.<DocumentType> 的形式返回,其中 <country> 是小写的 ISO 3166-1 alpha-2 代码,<DocumentType> 是识别到的类型。例如:

  • unico.moja.dictionary.ar.generic.v1.IdCard: 阿根廷身份证
  • unico.moja.dictionary.us.generic.v1.PolycarbonatePassport: 美国聚碳酸酯护照
专用架构

使用各自专用字段架构的文档类型(列于字段参考的 specific_document_schemas 之下)如下表所示:

国家/地区值文档
BRunico.moja.dictionary.br.rg.v2.RgRG
BRunico.moja.dictionary.br.cnh.v2.CnhCNH(驾照)
BRunico.moja.dictionary.br.cin.v1.CinCIN
BRunico.moja.dictionary.br.passaporte.v1.Passaporte护照
MXunico.moja.dictionary.mx.ine.v1.IneINE 选民证
MXunico.moja.dictionary.mx.lpc.v1.LpcLicencia para conducir(驾照)
MXunico.moja.dictionary.mx.pasaporte.v1.Pasaporte护照
—unico.moja.dictionary.other.unknown.v1.Unknown无法识别类型 — document.content 为空

当 document.type 为 unico.moja.dictionary.other.unknown.v1.Unknown 时,不执行 OCR 提取,也不返回任何字段。

错误代码​

代码消息描述
99989The document is invalid.document 对象结构无效。
99988The document is empty.请求体中缺少 document 对象。
20900O base64 informado não é válido.base64 参数无效。可能原因:不是图像或存在注入攻击。
20807A imagem precisa estar no padrão HD ou possuir uma resolução superior a 640 x 480.上传的图像分辨率过低。
20509The subject.name field is invalid.subject.name 包含无效字符。
20508The subject.gender field is invalid.subject.gender 必须为 M 或 F。
20507O parâmetro subject.code é inválido.标识符值格式非标准或不存在。
20506O base64 informado é muito grande. O tamanho máximo suportado é até 800kb.图像大小超过 800 KB;请压缩为 JPEG92。
20505O base64 informado não é suportado. Os formatos aceitos são png, jpeg e webp.base64 格式无效或不受支持。
20068The document.documentId or document.files parameter must be present.document.documentId 和 document.files 均未提供。
20067The document.purpose parameter is invalid.document.purpose 中的值无法识别。
20066The document.authProcessId parameter is invalid.document.authProcessId 中的值无效。
20062The useCase field is invalid.useCase 字段中的值无法识别。
20021The subject.phone field is invalid.subject.phone 格式无效(国际区号 + 区号 + 号码,共 13 位字符)。
20019The subject.birthDate field is invalid.subject.birthDate 不符合 ISO 8601 格式(YYYY-MM-DD)。
20009O parâmetro imagebase64 não foi informado.缺少文档图像参数。
20008The subject.email field is invalid.subject.email 中的邮箱格式无效。
20005O parâmetro subject.code não foi informado.缺少 subject.code 参数。
20004O parâmetro subject não foi informado.缺少 subject 参数。
20003The request body is missing or invalid.负载为空或无效。
20002O parâmetro APIKey não foi informado.请求头中缺少 APIKEY 参数。
20001O parâmetro authtoken não foi informado.请求头中缺少集成令牌参数。
10508The JWT with the captured face has already been used.JWT 只能使用一次。
10507The JWT with the captured face is expired.JWT 已过期;必须在 10 分钟内发送。
10506The imageBase64 field is not a valid JWT from SDK.imageBase64 不是 SDK 生成的有效 JWT。

下一步​

  • 在调用此端点之前检查文档是否已可用,请参阅获取可复用文档。
  • 有关生物特征流程创建(document.authProcessId 必需),请参阅创建流程。