Message Handling
Overview
This document explains how to handle the submissionStatus submission state parameter and various code values returned by AAI KYC iframe, helping you correctly identify user KYC submission status.
Submission Status Parameter
submissionStatus Field
When DV (Document Verification) product completes document submission, or IDV (Identity Verification) product completes document and liveness submission, the iframe will push the following data to your page through message event:
| Value | Description |
|---|---|
SUBMITTED | User has successfully submitted KYC materials (document or document + liveness) |
UNSUBMITTED | User has not successfully submitted materials |
Important Note: submissionStatus = SUBMITTED only indicates KYC materials have been submitted, not that verification passed. Actual verification results need to be determined by the backend Get Result API field.
Status Determination Logic
1. Submitted Status (SUBMITTED)
When submissionStatus === 'SUBMITTED', it indicates user has completed material submission. You can:
- Capture user's material submission action
- Update user review status
- Trigger subsequent business processes
Handling Example:
if (submissionStatus === 'SUBMITTED') {
console.log('KYC materials submitted');
updateUserAuditStatus(); // Example: trigger business logic to update user audit status
return;
}2. Unsubmitted Status (UNSUBMITTED)
When submissionStatus === 'UNSUBMITTED', handle differently based on the code field:
2.1 Specific Codes Requiring Dedicated Handling
The following codes need separate handling with corresponding business logic:
| Code | Description | Recommended Action |
|---|---|---|
CAMERA_ISSUE | Unable to open camera | Guide user to check camera permissions or switch device |
NOT_SUPPORT | Browser not supported | Prompt user to switch browser (Chrome/Safari recommended) |
RESELECT_REGION | Region not supported | Guide user to reselect a supported region |
RESELECT_DOC_TYPE | Document type not supported | Guide user to reselect a supported document type |
2.2 Other Codes - Guide to Resubmit
For codes other than the above, they all indicate unsuccessful submission. Recommend guiding user to retry the KYC submission process.
Complete Code Example
window.addEventListener('message', (event) => {
const { type, code, submissionStatus, shortUrl } = event.data;
if (type === 'complete') {
// 1. Listen for SUBMITTED status: capture material submission action
if (submissionStatus === 'SUBMITTED') {
console.log('KYC materials submitted');
updateUserAuditStatus(); // Example: trigger business logic to update user audit status
return;
}
// 2. Handle UNSUBMITTED status: unsubmitted material scenarios
if (submissionStatus === 'UNSUBMITTED') {
switch (code) {
// 2.1 Specific codes execute corresponding handling logic
case 'CAMERA_ISSUE': //camera not supported or can not open camera(This event is sent only when the fallback flow is disabled in your configuration.)
handleCameraIssue();
break;
case 'NOT_SUPPORT': // browser not support(wasm,getUserMedia api not support etc)(This event is sent only when the fallback flow is disabled in your configuration.)
handleBrowserIssue();
break;
case 'RESELECT_REGION':
handleReselectRegion();
break;
case 'RESELECT_DOC_TYPE':
handleReselectDocType();
break;
// 2.2 Other codes guide to resubmit
default:
console.log('User did not successfully submit KYC materials');
guideRetryKycProcess(); // Example: guide user to retry KYC submission process
break;
}
return;
}
} else if (type === 'copy') {
console.log('shortUrl', shortUrl);
}
});DV Product (Document Verification)
Submission Scenarios
When user submits single or double-sided document to backend and navigates to result page, the following code is triggered:
| Code | Description | submissionStatus |
|---|---|---|
SUCCESS | Document verification successful | SUBMITTED |
Backend Behavior: Directly triggers callback
Non-Submission Scenarios
The following scenarios do not trigger callback, user has not completed submission:
| Code | Description | submissionStatus | Trigger Scenario |
|---|---|---|---|
DOCUMENT_AUTO_SCAN_TRY_COUNT_EXCEED | Document auto-scan retry count exceeded | UNSUBMITTED | Too many retries caused by scanning, AAI dialog pops up, user clicks confirm |
DOCUMENT_MANUAL_TRY_COUNT_EXCEED | Document manual capture retry count exceeded | UNSUBMITTED | Too many retries caused by manual capture, AAI dialog pops up, user clicks confirm |
DOCUMENT_GALLERY_TRY_COUNT_EXCEED | Gallery upload retry count exceeded | UNSUBMITTED | Too many retries caused by gallery upload, AAI dialog pops up, user clicks confirm |
RESELECT_REGION | User-selected region not supported | UNSUBMITTED | Frontend prompts unsupported region, AAI dialog pops up, user clicks reselect |
RESELECT_DOC_TYPE | User-selected document type not supported | UNSUBMITTED | Frontend prompts unsupported document type, AAI dialog pops up, user clicks reselect |
CAMERA_ISSUE | Unable to open camera | UNSUBMITTED | camera not supported or can not open camera and the fallback flow is disabled in your configuration. |
NOT_SUPPORT | Browser not supported | UNSUBMITTED | Browser version too old or incompatible and the fallback flow is disabled in your configuration. |
IAM_FAILED | Session token expired | UNSUBMITTED | User submits after leaving page open for over 1 hour |
Backend Behavior: Does not trigger callback
IDV Product (Document + Liveness Verification)
Submission Scenarios
When user completes liveness detection submission, the following codes are triggered:
| Code | Description | submissionStatus |
|---|---|---|
SUCCESS | Liveness detection and face comparison successful | SUBMITTED |
LIVENESS_ATTACK | Liveness attack detected (using photo, video, or mask, etc.) | SUBMITTED |
SIMILARITY_FAILED | Face comparison failed, insufficient similarity between liveness photo and document photo | SUBMITTED |
FACE_QUALITY_TOO_POOR | Face image quality too low (blurry, insufficient lighting, or wrong angle) | SUBMITTED |
ERROR | System error, backend processing exception or network issue | SUBMITTED |
Backend Behavior: Directly triggers callback
Important Notes:
- As long as user completes liveness detection submission,
submissionStatuswill beSUBMITTED - Even if codes like
LIVENESS_ATTACK,SIMILARITY_FAILEDare returned, it still counts as submitted
Non-Submission Scenarios
The following scenarios do not trigger callback, user has not completed submission:
| Code | Description | submissionStatus | Trigger Scenario |
|---|---|---|---|
LIVENESS_TRY_COUNT_EXCEED | Liveness detection retry count exceeded | UNSUBMITTED | Liveness prompts too many retries, user clicks popup button |
CAMERA_ISSUE | Unable to open camera | UNSUBMITTED | Camera permission denied or device not supported |
NOT_SUPPORT | Browser not supported | UNSUBMITTED | Browser version too old or incompatible |
IAM_FAILED | Session token expired | UNSUBMITTED | User submits after leaving page open for over 1 hour |
| - | User did not complete document submission | UNSUBMITTED | Only submitted one side of double-sided document, or both attempts failed for single-sided document |
| - | User submitted document but not liveness | UNSUBMITTED | Completed document submission but did not perform liveness detection |
Backend Behavior: Does not trigger callback
Complete Code Reference
DV Product Code List
| Code | Description | Type |
|---|---|---|
SUCCESS | Document verification successful | Submission |
DOCUMENT_AUTO_SCAN_TRY_COUNT_EXCEED | Document auto-scan retry count exceeded | Non-submission |
DOCUMENT_MANUAL_TRY_COUNT_EXCEED | Document manual capture retry count exceeded | Non-submission |
DOCUMENT_GALLERY_TRY_COUNT_EXCEED | Gallery upload retry count exceeded | Non-submission |
RESELECT_REGION | User-selected region not supported, need to reselect | Non-submission |
RESELECT_DOC_TYPE | User-selected document type not supported, need to reselect | Non-submission |
CAMERA_ISSUE | Unable to open camera | Non-submission |
NOT_SUPPORT | Browser not supported | Non-submission |
IAM_FAILED | Session token expired | Non-submission |
IDV Product Code List
| Code | Description | Type |
|---|---|---|
SUCCESS | Liveness detection and face comparison successful | Submission |
LIVENESS_ATTACK | Liveness attack detected (using photo, video, or mask, etc.) | Submission |
SIMILARITY_FAILED | Face comparison failed, insufficient similarity between liveness photo and document photo | Submission |
FACE_QUALITY_TOO_POOR | Face image quality too low (blurry, insufficient lighting, or wrong angle) | Submission |
ERROR | System error, backend processing exception or network issue | Submission |
LIVENESS_TRY_COUNT_EXCEED | Liveness detection retry count exceeded | Non-submission |
CAMERA_ISSUE | Unable to open camera | Non-submission |
NOT_SUPPORT | Browser not supported | Non-submission |
IAM_FAILED | Session token expired | Non-submission |
Key Terminology
- Submission State: User completes operation and successfully submits data to backend, backend triggers callback to return processing result,
submissionStatus = SUBMITTED - Non-Submission State: User operation does not meet submission conditions, backend does not trigger callback,
submissionStatus = UNSUBMITTED - DV: Document Verification
- IDV: Identity Verification (includes document and liveness detection)
- Callback: Backend synchronous callback, used to notify processing results
FAQ
Q: What is the relationship between submissionStatus and code?
submissionStatusindicates whether submission action was completed (SUBMITTED / UNSUBMITTED)codeindicates processing result after submission or reason for failuresubmissionStatus = SUBMITTED+code = SUCCESS: KYC data (ID document or liveness check) successfully submitted and under review.submissionStatus = SUBMITTED+ other codes (e.g.,LIVENESS_ATTACK): Submitted but verification failedsubmissionStatus = UNSUBMITTED: Submission not completed, code indicates specific reason
Q: How to determine if KYC verification under review?
- DV Product:
submissionStatus = SUBMITTEDandcode = SUCCESSmeans document verification under review - IDV Product:
submissionStatus = SUBMITTEDandcode = SUCCESSmeans under review - All other cases indicate verification failed or not submitted
Q: Why is submissionStatus SUBMITTED for LIVENESS_ATTACK?
Because user has completed the submission action of liveness detection, but the verification result determined it as an attack. SUBMITTED means "materials submitted", not "verification passed".
Q: What happens if user exits midway or refreshes the page?
No callback will be triggered, and no message event will occur.
Q: How to handle token expiration (IAM_FAILED)?
- User submission after session timeout (typically 1 hour) will return this code
- Recommend regenerating KYC URL
- Guide user to restart the process
Best Practices
- Always check both submissionStatus and code: Only by combining both can you accurately understand user status
- Provide clear user guidance for specific codes: Such as
CAMERA_ISSUE,NOT_SUPPORT, etc.
Updated 8 days ago
