KYC API Docs

เอกสาร KYC Service REST API

จัดทำจาก REST controller จริงภายใน `workspace/service/service/kycService` ครอบคลุม API ฝั่งผู้ใช้ การตรวจจับ liveness และการตรวจสอบฝั่งแอดมิน

Base path/api/web/kycService
Response envelopeApiResponse { code, message, data }
รูปแบบอัปโหลดmultipart/form-data
Admin namespace/admin/kyc
Scanned Source

ภาพรวมการเชื่อมต่อจาก controller จริง

หน้านี้อ้างอิงจาก route จริงใน `ApiKycController`, `ApiKycLivenessController` และ `AdminKycController` ไม่ใช่คำอธิบายทั่วไป

01

สร้างโปรไฟล์ KYC

เริ่มจากเรียก `/submit` เพื่อรับ `profileId` แล้วใช้ค่านี้ต่อในขั้นตอนอัปโหลดเอกสาร ตรวจ liveness และเช็กสถานะ

02

ส่งข้อมูลเอกสาร

ถ้ามีระบบเก็บไฟล์อยู่แล้วใช้ `/document` ได้ แต่สำหรับการเชื่อมต่อมาตรฐานแนะนำ `/document/upload` เพื่ออัปโหลดภาพและรัน OCR พร้อมกัน

03

ยืนยันและส่งตรวจ

ใช้ `/document/confirm` ให้ผู้ใช้ตรวจข้อมูลที่ดึงออกมา แล้วใช้ `/document/submit` เพื่อส่งเข้าอนุมัติอัตโนมัติหรือรีวิวด้วยคน

04

Liveness และสถานะสุดท้าย

ขั้นตอน liveness ใช้ `/liveness/start` และ `/liveness/verify` ส่วนผลรวมทั้งหมดดึงได้จาก `/status/`

แหล่งที่สแกน: /workspace/service/service/kycService/src/main/java/com/sargia/finger/kycService/rest

ใน service ยังมี endpoint แบบ mirror ที่ `/api/web/kycService/list`, `/detail/`, `/status/update` ขณะที่ namespace ฝั่งแอดมินหลักคือ `/admin/kyc`

Envelope

โครงสร้างตอบกลับร่วม

controller ที่สแกนทั้งหมดตอบกลับด้วย `ApiResponse` และข้อมูลธุรกิจจริงจะอยู่ใน `data`

ฟิลด์ประเภทตัวอย่าง
codenumber0 คือสำเร็จ ค่าอื่นคือผิดพลาดหรือ business exception
messagestringข้อความเช่น success, query success, Document uploaded successfully
dataobjectpayload จริง เช่น profileId, status, detail หรือ list
Core Web API

API ฝั่งผู้ใช้

อิงจาก `ApiKycController` ครอบคลุมการสร้างโปรไฟล์ อัปโหลดเอกสาร ยืนยันข้อมูล ส่งตรวจ และเช็กสถานะ

POST
PublicRecommended

Create profile

/api/web/kycService/submit

Create a KYC profile and return the profileId used by all downstream calls. 建立 KYC 档案并返回后续接口共用的 profileId。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
userIdstringใช่bodyuser_10001
countrystringใช่bodySG

ค่าที่ตอบกลับสำคัญ

profileId

หมายเหตุ

  • Returns `ApiResponse.ok().data("profileId", profileId)` on success.
POST
Public

Upload document metadata

/api/web/kycService/document

Submit document metadata with image URLs or base64 references. 提交证件元数据,适合已有文件托管链路的接入方。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
profileIdstringใช่bodyprofile_123456
docTypestringใช่bodyPASSPORT
docNumberstringไม่bodyE12345678
frontImageUrlstringใช่bodyhttps://cdn.example/front.jpg
backImageUrlstringไม่bodyhttps://cdn.example/back.jpg
expiryDatedateไม่body2030-12-31
issueCountrystringไม่bodySG

ค่าที่ตอบกลับสำคัญ

codemessage

หมายเหตุ

  • The controller stores document metadata through `kycService.uploadDocument(...)`.
POST
PublicRecommended

Upload and verify document

/api/web/kycService/document/upload

Upload front/back images, run OCR and quality checks, and return extracted identity fields. 上传证件图片并同步返回 OCR 与质量校验结果。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
profileIdstringใช่multipartprofile_123456
docTypestringใช่multipartID_CARD
countrystringใช่multipartSG
frontImagefileใช่multipartid-front.jpg
backImagefileไม่multipartid-back.jpg

ค่าที่ตอบกลับสำคัญ

documentIdverifiednameidNumberbirthDateexpiryDatefrontQualityScorebackQualityScoreerrors

หมายเหตุ

  • When OCR succeeds, the response includes extracted identity fields for user confirmation.
  • When verification fails, the controller returns `errorCode`, quality scores, and `errors`.
POST
Public

Confirm extracted fields

/api/web/kycService/document/confirm

Let the user confirm or edit OCR results before the final review step. 用户确认或修正 OCR 字段,必要时触发人工审核。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
documentIdnumberใช่query123456789
namestringไม่bodyAlex Tan
idNumberstringไม่bodyS1234567A
birthDatedateไม่body1990-01-01
expiryDatedateไม่body2030-12-31
issuerstringไม่bodyICA Singapore
nationalitystringไม่bodySGP
userModifiedbooleanไม่bodytrue

ค่าที่ตอบกลับสำคัญ

documentIdstatusverifiedextractedInfo

หมายเหตุ

  • If `userModified` is true, the service message indicates the record will enter manual review.
POST
Public

Submit document for review

/api/web/kycService/document/submit

Finalize the document step after user confirmation. 完成用户确认后,正式提交证件审核并返回最终状态。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
documentIdnumberใช่query123456789

ค่าที่ตอบกลับสำคัญ

documentIdstatusverifiederrors

หมายเหตุ

  • The controller maps status 1/2/3 to auto-approved, manual review, and user-modified review.
GET
PublicRecommended

Get verification status

/api/web/kycService/status/{profileId}

Fetch the current KYC status, liveness result, and face-match information by profileId. 查询整个 KYC 档案的当前状态。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
profileIdstringใช่pathprofile_123456

ค่าที่ตอบกลับสำคัญ

statusstatusDescriptionkycLevelriskScorelivenessStatusfaceMatchPassed

หมายเหตุ

  • Returns `data.status` as a `KycStatusDto` object rather than a flat primitive field.
POST
Callback

Liveness callback

/api/web/kycService/callback/liveness

Server-to-server callback used to persist liveness results. 这是服务侧回调入口,不是前端页面直接调用的接口。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
profileIdstringใช่bodyprofile_123456
sessionIdstringไม่body550e8400-e29b-41d4-a716-446655440000
confidencenumberไม่body96.2
resultstringไม่bodysuccess
errorMessagestringไม่bodytimeout

ค่าที่ตอบกลับสำคัญ

codemessage

หมายเหตุ

  • `LivenessCallback.toEntity()` is currently a placeholder conversion in the scanned service code.
Liveness API

API ตรวจจับ liveness

อิงจาก `ApiKycLivenessController` สำหรับสร้าง session ตรวจวิดีโอ และดูสถานะ session

POST
PublicRecommended

Start liveness session

/api/web/kycService/liveness/start

Create a five-minute session and return three randomized challenge actions. 创建 5 分钟有效的活体动作会话。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
profileIdstringใช่queryprofile_123456

ค่าที่ตอบกลับสำคัญ

sessionIdactionsexpireTimetimeout

หมายเหตุ

  • The controller shuffles `LivenessActionEnum` values and returns exactly three actions.
POST
PublicRecommended

Verify liveness videos

/api/web/kycService/liveness/verify

Upload three challenge videos and return the aggregated liveness result. 上传三个动作视频并返回活体验证结果。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
sessionIdstringใช่multipart550e8400-e29b-41d4-a716-446655440000
profileIdstringใช่multipartprofile_123456
video1fileใช่multipartblink.mp4
video2fileใช่multipartsmile.mp4
video3fileใช่multipartturn-left.mp4

ค่าที่ตอบกลับสำคัญ

verifiedconfidencecompletedActionsfailedActionsmessage

หมายเหตุ

  • Failure uses `ApiResponse.error().code(20001)` with the liveness result still returned in `data.list`.
GET
Public

Get liveness session

/api/web/kycService/liveness/session/{sessionId}

Read the current liveness session from cache and inspect its status. 查询缓存中的活体会话状态。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
sessionIdstringใช่path550e8400-e29b-41d4-a716-446655440000

ค่าที่ตอบกลับสำคัญ

sessionIdprofileIdactionsexpireTimestatuscreateTime

หมายเหตุ

  • If the session is missing or expired, the controller returns an error message instead of null data.
Admin Review API

API ฝั่งแอดมิน

อิงจาก `AdminKycController` สำหรับรายการ รายละเอียด และอัปเดตสถานะการตรวจสอบ

POST
Admin

List KYC records

/admin/kyc/list

Query paginated KYC records for operations teams. 后台分页查询 KYC 档案列表并支持按 profileIds 过滤。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
profileIdsarray<string>ไม่body["profile_123","profile_456"]
pagenumberไม่body1
limitnumberไม่body20

ค่าที่ตอบกลับสำคัญ

totalpagescurrentsizerecords

หมายเหตุ

  • The same list capability is also mirrored in `ApiKycController` at `/api/web/kycService/list`.
GET
Admin

Get KYC detail

/admin/kyc/detail/{profileId}

Fetch the full review payload for one profile, including document, liveness, and face-match data. 获取单个 KYC 档案的完整审核详情。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
profileIdstringใช่pathprofile_123456

ค่าที่ตอบกลับสำคัญ

detail

หมายเหตุ

  • A mirrored detail endpoint also exists at `/api/web/kycService/detail/{profileId}`.
POST
Admin

Update review status

/admin/kyc/update-status

Approve, reject, or reset the KYC review state from the admin namespace. 在后台审核链路中更新 KYC 状态。

ฟิลด์ประเภทจำเป็นตำแหน่งตัวอย่าง
profileIdstringใช่bodyprofile_123456
statusstringใช่body2
remarkstringไม่bodyManual review passed

ค่าที่ตอบกลับสำคัญ

codemessage

หมายเหตุ

  • Allowed status values in the DTO are `-1`, `0`, and `2`.
  • The web-controller mirror path is `/api/web/kycService/status/update`.