/api/web/kycServiceTài liệu KYC Service REST API
Được tổng hợp từ các REST controller thực tế trong `workspace/service/service/kycService`, bao gồm API người dùng, liveness và xét duyệt back-office.
ApiResponse { code, message, data }multipart/form-data/admin/kycTổng quan tích hợp từ controller thực tế
Trang này được dựng từ route thật của `ApiKycController`, `ApiKycLivenessController` và `AdminKycController`, không phải mô tả khái quát chung.
Tạo hồ sơ KYC
Bắt đầu bằng `/submit` để lấy `profileId`, sau đó dùng ID này cho upload tài liệu, liveness và truy vấn trạng thái.
Gửi dữ liệu giấy tờ
Nếu đã có hạ tầng lưu file thì dùng `/document`; luồng khuyến nghị là `/document/upload` để upload ảnh và chạy OCR cùng lúc.
Xác nhận và nộp duyệt
Dùng `/document/confirm` để người dùng xác nhận dữ liệu OCR, rồi `/document/submit` để chuyển sang auto-approve hoặc manual review.
Liveness và trạng thái cuối
Luồng liveness gồm `/liveness/start` và `/liveness/verify`, còn trạng thái tổng thể lấy qua `/status/`.
Nguồn quét: /workspace/service/service/kycService/src/main/java/com/sargia/finger/kycService/rest
Trong service còn có nhóm endpoint mirror tại `/api/web/kycService/list`, `/detail/`, `/status/update`, trong khi namespace back-office chính là `/admin/kyc`.
Cấu trúc phản hồi dùng chung
Các controller được quét đều trả về `ApiResponse`, trong đó dữ liệu nghiệp vụ thực tế nằm trong `data`.
| Trường | Kiểu | Ví dụ |
|---|---|---|
code | number | 0 là thành công, giá trị khác 0 là lỗi hoặc business exception |
message | string | Thông điệp như success, query success, Document uploaded successfully |
data | object | Payload như profileId, status, detail hoặc list |
API phía người dùng
Tương ứng với `ApiKycController`, bao gồm tạo hồ sơ, upload giấy tờ, xác nhận trường, nộp duyệt và truy vấn trạng thái.
Create profile
/api/web/kycService/submitCreate a KYC profile and return the profileId used by all downstream calls. 建立 KYC 档案并返回后续接口共用的 profileId。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
userId | string | Có | body | user_10001 |
country | string | Có | body | SG |
Phản hồi chính
Ghi chú
- Returns `ApiResponse.ok().data("profileId", profileId)` on success.
Upload document metadata
/api/web/kycService/documentSubmit document metadata with image URLs or base64 references. 提交证件元数据,适合已有文件托管链路的接入方。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
profileId | string | Có | body | profile_123456 |
docType | string | Có | body | PASSPORT |
docNumber | string | Không | body | E12345678 |
frontImageUrl | string | Có | body | https://cdn.example/front.jpg |
backImageUrl | string | Không | body | https://cdn.example/back.jpg |
expiryDate | date | Không | body | 2030-12-31 |
issueCountry | string | Không | body | SG |
Phản hồi chính
Ghi chú
- The controller stores document metadata through `kycService.uploadDocument(...)`.
Upload and verify document
/api/web/kycService/document/uploadUpload front/back images, run OCR and quality checks, and return extracted identity fields. 上传证件图片并同步返回 OCR 与质量校验结果。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
profileId | string | Có | multipart | profile_123456 |
docType | string | Có | multipart | ID_CARD |
country | string | Có | multipart | SG |
frontImage | file | Có | multipart | id-front.jpg |
backImage | file | Không | multipart | id-back.jpg |
Phản hồi chính
Ghi chú
- When OCR succeeds, the response includes extracted identity fields for user confirmation.
- When verification fails, the controller returns `errorCode`, quality scores, and `errors`.
Confirm extracted fields
/api/web/kycService/document/confirmLet the user confirm or edit OCR results before the final review step. 用户确认或修正 OCR 字段,必要时触发人工审核。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
documentId | number | Có | query | 123456789 |
name | string | Không | body | Alex Tan |
idNumber | string | Không | body | S1234567A |
birthDate | date | Không | body | 1990-01-01 |
expiryDate | date | Không | body | 2030-12-31 |
issuer | string | Không | body | ICA Singapore |
nationality | string | Không | body | SGP |
userModified | boolean | Không | body | true |
Phản hồi chính
Ghi chú
- If `userModified` is true, the service message indicates the record will enter manual review.
Submit document for review
/api/web/kycService/document/submitFinalize the document step after user confirmation. 完成用户确认后,正式提交证件审核并返回最终状态。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
documentId | number | Có | query | 123456789 |
Phản hồi chính
Ghi chú
- The controller maps status 1/2/3 to auto-approved, manual review, and user-modified review.
Get verification status
/api/web/kycService/status/{profileId}Fetch the current KYC status, liveness result, and face-match information by profileId. 查询整个 KYC 档案的当前状态。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
profileId | string | Có | path | profile_123456 |
Phản hồi chính
Ghi chú
- Returns `data.status` as a `KycStatusDto` object rather than a flat primitive field.
Liveness callback
/api/web/kycService/callback/livenessServer-to-server callback used to persist liveness results. 这是服务侧回调入口,不是前端页面直接调用的接口。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
profileId | string | Có | body | profile_123456 |
sessionId | string | Không | body | 550e8400-e29b-41d4-a716-446655440000 |
confidence | number | Không | body | 96.2 |
result | string | Không | body | success |
errorMessage | string | Không | body | timeout |
Phản hồi chính
Ghi chú
- `LivenessCallback.toEntity()` is currently a placeholder conversion in the scanned service code.
API xác minh liveness
Tương ứng với `ApiKycLivenessController`, gồm tạo session, xác minh video và truy vấn session.
Start liveness session
/api/web/kycService/liveness/startCreate a five-minute session and return three randomized challenge actions. 创建 5 分钟有效的活体动作会话。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
profileId | string | Có | query | profile_123456 |
Phản hồi chính
Ghi chú
- The controller shuffles `LivenessActionEnum` values and returns exactly three actions.
Verify liveness videos
/api/web/kycService/liveness/verifyUpload three challenge videos and return the aggregated liveness result. 上传三个动作视频并返回活体验证结果。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
sessionId | string | Có | multipart | 550e8400-e29b-41d4-a716-446655440000 |
profileId | string | Có | multipart | profile_123456 |
video1 | file | Có | multipart | blink.mp4 |
video2 | file | Có | multipart | smile.mp4 |
video3 | file | Có | multipart | turn-left.mp4 |
Phản hồi chính
Ghi chú
- Failure uses `ApiResponse.error().code(20001)` with the liveness result still returned in `data.list`.
Get liveness session
/api/web/kycService/liveness/session/{sessionId}Read the current liveness session from cache and inspect its status. 查询缓存中的活体会话状态。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
sessionId | string | Có | path | 550e8400-e29b-41d4-a716-446655440000 |
Phản hồi chính
Ghi chú
- If the session is missing or expired, the controller returns an error message instead of null data.
API xét duyệt back-office
Tương ứng với `AdminKycController`, gồm danh sách, chi tiết và cập nhật trạng thái xét duyệt.
List KYC records
/admin/kyc/listQuery paginated KYC records for operations teams. 后台分页查询 KYC 档案列表并支持按 profileIds 过滤。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
profileIds | array<string> | Không | body | ["profile_123","profile_456"] |
page | number | Không | body | 1 |
limit | number | Không | body | 20 |
Phản hồi chính
Ghi chú
- The same list capability is also mirrored in `ApiKycController` at `/api/web/kycService/list`.
Get KYC detail
/admin/kyc/detail/{profileId}Fetch the full review payload for one profile, including document, liveness, and face-match data. 获取单个 KYC 档案的完整审核详情。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
profileId | string | Có | path | profile_123456 |
Phản hồi chính
Ghi chú
- A mirrored detail endpoint also exists at `/api/web/kycService/detail/{profileId}`.
Update review status
/admin/kyc/update-statusApprove, reject, or reset the KYC review state from the admin namespace. 在后台审核链路中更新 KYC 状态。
| Trường | Kiểu | Bắt buộc | Vị trí | Ví dụ |
|---|---|---|---|---|
profileId | string | Có | body | profile_123456 |
status | string | Có | body | 2 |
remark | string | Không | body | Manual review passed |
Phản hồi chính
Ghi chú
- Allowed status values in the DTO are `-1`, `0`, and `2`.
- The web-controller mirror path is `/api/web/kycService/status/update`.