Onfido logo home page
Watch a demo
Get in touch
Arrow back Back to guides

Verify users against 2 different documents

Introduction

Follow this guide to be able to verify a single user against 2 different documents with a single live photo or live video.

Onfido allows you to complete 2 checks for a single applicant, against 2 different documents, without the user needing to upload a live photo or video twice.

Instead of asking the user to repeat the upload of a live photo or live video with a new document, it is possible to request the upload of a second document at the end of the standard capture flow. An additional check can then be submitted to compare the user's live photo or video, provided during the initial flow, with the second uploaded document. Using this process reduces friction and wait time for end users, allowing you to onboard customers quickly and efficiently whilst meeting the necessary requirements.

Overview of steps

The following diagram illustrates the flow for a check containing 2 Document reports, one for an ID document and one for a driving license, and a single Facial Similarity video report:

2 docs 1 biometric Diagram

Note: You can customize and re-order the steps for document and biometric capture based on the desired flow for your application.

Integration guidance

This guide assumes you're using the Onfido input-capture SDKs. If you have built your own capture experience you will need to adjust your experience to allow for the upload of 2 documents and 1 live photo or video in order to use this process.

Follow the steps below to create 2 checks for a single applicant against 2 different documents using the same live photo or video.

You may find our SDK reference pages for iOS, Android and Web useful.

1. Create an applicant

The first step in creating any check is to create an applicant from your backend server, using a valid API token.

For Document and Facial Similarity reports, you must at least specify the applicant's first and last names in the body of the request.

2. Generate an SDK token

Use your API token to make a request to the 'generate SDK token' endpoint, including the applicant ID you created in the previous step and a valid referrer.

You can use the same SDK token for both instances of the SDK.

3. Initialize the Onfido SDK

You'll need to setup the SDK to support the submission of 2 documents and 1 live photo or live video from an end user.

You can also customize the welcome screen of the SDK flow to specify to the end user which steps they will be presented with, including both document uploads.

The first instance of the SDK will allow the user to upload the first document and a live photo or video. The second instance of the SDK, once it has been re-initialized, will allow the user to upload the second document.

Example first initialization of the SDK (iOS)

func StartCheck(){
        GetSDKToken(tokenCreated: {response in
            sdkToken = response["token"].rawString()!
            let config = try! OnfidoConfig.builder()
                .withSDKToken(sdkToken)
                .withDocumentStep(ofType: .drivingLicence(config: nil))
                .withFaceStep(ofVariant: .video(withConfiguration: nil))
                .build()
            
            let onfidoFlow = OnfidoFlow(withConfiguration: config)
                .with(responseHandler: { results in
                    switch results {
                    case .success:
                        self.SendLicenceAndVideo()
                    case .cancel:
                        self.resetApp()
                    case .error(_):
                        self.resetApp()
                    @unknown default:
                        self.resetApp()
                    }
                })
            
            let onfidoRun = try! onfidoFlow.run()
            self.present(onfidoRun, animated: true, completion: nil)
        })
    }

Example handle completion of first step (iOS)

func SendLicenceAndVideo() {
        let parameters: [String:Any] = [
            "applicant_id": applicantId,
            "report_names": [
                "document",
                "facial_similarity_video"
            ],
            "document_ids": [
                firstDocumentId
            ]
        ]
        
        AF.request("https://\(remoteServer)/create_checks",
                   method: .post,
                   parameters: parameters,
                   encoding: JSONEncoding.default,
                   headers: headers
        ).responseJSON { response in
            let banner = StatusBarNotificationBanner(title: "Starting first check: DL + video", style: .info)
            banner.show(queuePosition: .front)
            firstCheck = JSON(response.value as Any)self.SecondStep()
        }
    }

4. Create a check

After the user has uploaded the first document and a live photo or video, create a check containing a Document report and one type of Facial Similarity report.

The first check will compare the first document uploaded to the live photo or video submitted.

5. Re-initialize the Onfido SDK

Without waiting for the first check to be completed, re-initialize the Onfido SDK for the second document capture flow.

The end user will not see that the SDK has been re-initialized, but will continue through the SDK flow process to upload a second document. After this step the user has completed the verification flow.

Note: You can re-initialize the SDK using the same SDK token or by generating a new SDK token.

Example second initialization of the SDK (iOS)

func SecondStep(){
        let config = try! OnfidoConfig.builder()
            .withSDKToken(sdkToken)
            .withDocumentStep(ofType: .passport(config: nil))
            .build()
        
        let onfidoFlow = OnfidoFlow(withConfiguration: config)
            .with(responseHandler: { results in
                switch results {
                case .success:
                    self.SendSecondDocument()
                case .cancel:
                    self.resetApp()
                case .error(_):
                    self.resetApp()
                @unknown default:
                    self.resetApp()
                }
            })
        
        let onfidoRun = try! onfidoFlow.run()
        self.present(onfidoRun, animated: true, completion: nil)
    }

Example handle completion of second step (iOS)

func SendSecondDocument() {
    // Note that a second check can't start on the same applicant while
    // another one is ongoing. Your backend should handle this logic by
    // implementing a Webhook listener and a check queue.
        let parameters: [String:Any] = [
            "applicant_id": applicantId,
            "report_names": [
                "document",
                "facial_similarity_video"
            ],
            "document_ids": [
                secondDocumentId
            ]
        ]
        AF.request("\(remoteServer)/check_loop",
                   method: .post,
                   parameters: parameters,
                   encoding: JSONEncoding.default).response{ response in
                    print(response.value as Any)
                   }
        self.resetApp()
        
        let alert = UIAlertController(title: "Data upload completed", message: "You can monitor check progress\nand status on your Onfido Dashboard", preferredStyle: .alert)
        
        alert.addAction(UIAlertAction(title: "Close", style: .default, handler: nil))
        
        self.present(alert, animated: true)
    }

6. Wait until the first check has been completed

If you have set up webhooks, a webhook notification will be sent upon completion of the first check.

You can retrieve an individual check or report's status and result via the API. Further details on how to retrieve checks can be found in our API reference.

Note: You cannot submit a second check on the same applicant while a check is already in progress.

7. Submit a second check

After the first check has been completed submit a second check containing a Document report and Facial Similarity report.

The second check will compare the second document uploaded to the live photo or live video submitted.

Note: If you require specific driving licence information, such as obtainment date, you can use the Document with Driving Licence Information document report in the associated check.

Note: Any Facial Similarity report will always compare to the latest uploaded identity document associated with the applicant ID.

Onfido

Our Solutions

Onfido uses 256-bit SSL encryption 100% of the time on every device.

BSI ISO/IEC27001

Onfido has been certified by BSI to ISO 27001 under certificate number IS 660122.

© Onfido™, 2020. All rights reserved.
Company Registration Number: 07479524.