获取可重用文档
使用此端点检查用户是否已有可重用的文档,然后再启动新的文档采集流程。如果找到文档,可以将其 documentId 直接传递给 POST /processes/v1(Document 类型)以跳过采集步骤。
端点
| 环境 | URL |
|---|---|
| Production | GET https://api.id.unico.app/documents/v1 |
| Sandbox | GET https://api.id.uat.unico.app/documents/v1 |
请求
请求头
| 请求头 | 值 |
|---|---|
Authorization | Bearer <access_token>(参见身份验证) |
APIKEY | 已启用文档采集与重用功能的已配置 API 密钥。 |
查询参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
code | string | 是 | 用户标识符(CPF 或 CURP,不含格式化字符)。 |
type | string | 是 | 要查询的文档类型。可接受的值:BR_RG、BR_CNH、BR_CIN、BR_PASSPORT。 |
备注
上述 type 值仅适用于此端点。请勿与以下内容混淆:
- POST 请求中的
subject.duiType— 使用DUI_TYPE_*前缀,标识的是人员而非文档类型(例如DUI_TYPE_BR_CPF)。 - 响应中的
documentType— 使用完整的注册路径(例如unico.moja.dictionary.br.cnh.v2.Cnh)。
示例
- cURL
- Node.js
curl -X GET "https://api.id.unico.app/documents/v1?code=12345678909&type=BR_CNH" \
-H "Authorization: Bearer $TOKEN" \
-H "APIKEY: $API_KEY"
import fetch from 'node-fetch';
const params = new URLSearchParams({ code: '12345678909', type: 'BR_CNH' });
const res = await fetch(
`https://api.id.unico.app/documents/v1?${params}`,
{
headers: {
Authorization: `Bearer ${accessToken}`,
APIKEY: apiKey
}
}
);
const data = await res.json();
// data.items[0].documentId → pass to POST /processes/v1 for reuse
响应
200 OK
{
"items": [
{
"documentType": "unico.moja.dictionary.br.cnh.v2.Cnh",
"documentId": "doc-abc-123"
}
]
}
| 字段 | 类型 | 描述 |
|---|---|---|
items | array | 为该用户找到的可重用文档列表。如果未找到与给定 code 和 type 匹配的可重用文档,则为空数组。 |
items[].documentType | string | 文档类型标识符。可能的值:unico.moja.dictionary.br.rg.v2.Rg、unico.moja.dictionary.br.cnh.v2.Cnh、unico.moja.dictionary.br.cin.v1.Cin、unico.moja.dictionary.br.passaporte.v1.Passaporte。 |
items[].documentId | string | 文档标识符。在 POST /processes/v1 中将此值传入 document.documentId 以重用该文档。 |
403 Forbidden
Bearer 令牌或 APIKEY 缺失、已过期或无效。
429 Too Many Requests
Rate limit reached. When your system receives an HTTP 429 error, you must implement mechanisms to prevent cascading failures and avoid worsening the restriction.
Best practices:
- Cool-down period (backoff): Immediately halt or throttle subsequent requests from your system. Do not continuously retry failed requests in a tight loop.
- Queueing & throttling: Buffer or queue outgoing requests on your end to control the traffic flow before re-sending them.
- Exponential backoff with jitter: When retrying, increase the waiting time exponentially between attempts (e.g., 1 s, 2 s, 4 s, 8 s) and add a small random delay ("jitter") to prevent a herd effect where all queued requests retry at the exact same millisecond.
警告
Continuously hitting a rate-limited endpoint without backing off can prolong the restriction period and severely impact your system's operational throughput. Properly throttling requests on your side ensures a smoother, more resilient integration.
For default limits, increase requests and additional details, see Rate Limits.