SmartSelfie™ Authentication

Required Class: WebApi Class

Running SmartSelfie™ Authentication on Node.js

  1. Get your Smile ID Partner ID

  2. Get your API Key

  3. Create a Callback Endpoint

  4. Get your user's Selfie

  5. Get the user ID you initially used to register the user

  6. Submit the Job to Smile ID

  7. Interpret your results

Get your Partner ID

You can find your Partner ID in the menu list when logged into the portal.

Get your API Key

Your API Key is also in the developer section of the portal.

  • Click on the Generate New API Key button

  • Copy your api key (ensure you are in the right environment)

Create a Callback Endpoint

Responses from this product are asynchronous (based on various actions we carry out on the product) and are sent as soon as they are ready, you will need to setup a callback when submitting a job. You can read about creating a Callback URL here.

Get the User's Selfie

To successfully run SmartSelfie™ Authentication jobs you need to submit the user's selfie. There are two types of selfies that can be submitted

  • Selfie - a single colour-image selfie of user

  • (optional but required for proof of life) Liveness images - 8 colour images of user

The selfies can either be submitted as files (with the path to the image specified during submission) or as base64 encoded strings.

We recommend that you use our Web SDK to capture both of these types of images

Get the User's User ID

Since SmartSelfie™ Authentication entails comparing a user's selfie with the selfie they have on file in Smile ID, you must supply the User's existing user_id in the partner params (the user_id must be the same as the one you used when you ran a successful "Biometric KYC" or "Document Verification" for the user). If the User ID you supplied does not exist, the job will fail.

Submit the Job to Smile ID

You can copy the sample code below and edit with your partner and job details.

const smileIdentityCore = require("smile-identity-core");
const WebApi = smileIdentityCore.WebApi;

// Initialize
let partner_id = '<Your partner ID>'; // login to the Smile ID portal to view your partner id
let default_callback = '<Put your default callback url here>';
let api_key = '<Your API key>'; // copy your API key from the Smile ID portal
let sid_server = '<0 or 1>'; // Use '0' for the sandbox server, use '1' for production server

const connection = new WebApi(partner_id, default_callback, api_key, sid_server);

// Create required tracking parameters
let partner_params = {
    user_id: '<put previously registered user"s user_id here>',
    job_id: '<put your unique job ID here>',
    job_type: 2
};

// Create image list
// image_type_id Integer
// 0 - Selfie image jpg (if you have the full path of the selfie)
// 2 - Selfie image jpg base64 encoded (if you have the base64image string of the selfie)
// 4 - Liveness image jpg (if you have the full path of the liveness image)
// 6 - Liveness image jpg base64 encoded (if you have the base64image string of the liveness image)
let image_details = [
    {
      image_type_id: <0 | 2>,
      image: '<full path to selfie image or base64image string>'
     },
     { // Not required if you don't require proof of life (note photo of photo check will still be performed on the uploaded selfie)
       image_type_id: <4 | 6>,
       image: '<full path to liveness image or base64 image string>'
     }
  ];

// Set the options for the job
let options = {
  return_job_status: <true | false>, // Set to true if you want to get the job result in sync (in addition to the result been sent to your callback). If set to false, result is sent to callback url only.
  return_history: <true | false>, // Set to true to return results of all jobs you have ran for the user in addition to current job result. You must set return_job_status to true to use this flag.
  return_image_links: <true |false>, // Set to true to receive selfie and liveness images you uploaded. You must set return_job_status to true to use this flag.
  signature: true
};

// Submit the job.
// This method returns a promise
response = connection.submit_job(partner_params, image_details, {}, options)

Getting the Job Result

By default, you always get the result of your job in the callback url you provided, however for some use cases you might want to get the job result in sync after submission. The flag return_job_status can be set to true if you want to get the job result in sync.

Please note that the result you get in sync by setting the return_job_status flag to true might not be the final result if human review is required for the job. We recommend you use the responses sent to your callback to build your business logic as that is where we return the final result

Refer to the category column of result codes of SmartSelfie™ Authentication for the comprehensive list of final codes (approved or rejected) and in-progress codes (provisional approval or suspected for spoof).

Response when return_job_status is set to false

If return_job_status is set to false, the response will be a JSON string containing:

{success: true, smile_job_id: <the generated smile_job_id>}

The job result will be sent to the callback url you provided, it will look as follows:

{
  "Actions": {
    "Human_Review_Compare": "Not Applicable",
    "Human_Review_Liveness_Check": "Passed",
    "Human_Review_Update_Selfie": "Not Applicable",
    "Liveness_Check": "Passed",
    "Register_Selfie": "Not Applicable",
    "Return_Personal_Info": "Not Applicable",
    "Selfie_Provided": "Passed",
    "Selfie_To_ID_Authority_Compare": "Not Applicable",
    "Selfie_To_ID_Card_Compare": "Not Applicable",
    "Selfie_To_Registered_Selfie_Compare": "Completed",
    "Update_Registered_Selfie_On_File": "Not Applicable",
    "Verify_ID_Number": "Not Applicable"
  },
  "ConfidenceValue": "99",
  "PartnerParams": {
    "job_id": "KE_TEST_1013",
    "job_type": "2",
    "user_id": "KE_TESTTEST_1012"
  },
  "ResultCode": "1220",
  "ResultText": "Authenticated",
  "SmileJobID": "0000057497",
  "Source": "WebAPI",
  "timestamp": "2021-06-21T15:10:15.729Z",
  "signature": "----signature-----"
}

Response when return_job_status is set to true

If you have use cases that require you to get the result in sync, you can set the return_job_status to true. We advise that you use the result sent to your callback to make final decisions as there are times when the submitted job requires human review, the final result after the review is completed can not be retrieved by setting the return_job_status to true.

If you set return_job_status to true (with image_links and history also set to true) then you will receive the JSON object containing the machine result like below:

{
  "timestamp": "2022-03-31T15:07:04.806Z",
  "signature": "---signature---",
  "job_complete": true,
  "job_success": true,
  "code": "2302",
  "result": {
    "Source": "WebAPI",
    "Actions": {
      "Liveness_Check": "Under Review",
      "Register_Selfie": "Not Applicable",
      "Selfie_Provided": "Passed",
      "Verify_ID_Number": "Not Applicable",
      "Human_Review_Compare": "Not Applicable",
      "Return_Personal_Info": "Not Applicable",
      "Selfie_To_ID_Card_Compare": "Not Applicable",
      "Human_Review_Update_Selfie": "Not Applicable",
      "Human_Review_Liveness_Check": "Not Applicable",
      "Selfie_To_ID_Authority_Compare": "Not Applicable",
      "Update_Registered_Selfie_On_File": "Not Applicable",
      "Selfie_To_Registered_Selfie_Compare": "Completed"
    },
    "ResultCode": "0824",
    "ResultText": "Provisional Authentication - Under Review",
    "SmileJobID": "0000000194",
    "PartnerParams": {
      "job_id": "003",
      "user_id": "rb_ekyc+ss_test_user_005",
      "job_type": "2"
    },
    "ConfidenceValue": "99"
  },
  "history": [
    {
      "Source": "WebAPI",
      "Actions": {
        "Liveness_Check": "Under Review",
        "Register_Selfie": "Not Applicable",
        "Selfie_Provided": "Passed",
        "Verify_ID_Number": "Not Applicable",
        "Human_Review_Compare": "Not Applicable",
        "Return_Personal_Info": "Not Applicable",
        "Selfie_To_ID_Card_Compare": "Not Applicable",
        "Human_Review_Update_Selfie": "Not Applicable",
        "Human_Review_Liveness_Check": "Not Applicable",
        "Selfie_To_ID_Authority_Compare": "Not Applicable",
        "Update_Registered_Selfie_On_File": "Not Applicable",
        "Selfie_To_Registered_Selfie_Compare": "Completed"
      },
      "ResultCode": "0824",
      "ResultText": "Provisional Authentication - Under Review",
      "SmileJobID": "0000000194",
      "PartnerParams": {
        "job_id": "003",
        "user_id": "test_user_005",
        "job_type": "2"
      },
      "ConfidenceValue": "99"
    }
  ],
  "image_links": {
    "selfie_image": "---image link---"
  },
  "success": true,
  "smile_job_id": "0000000194"
}

Interpret your Results

You can read more about result codes and responses in the SmartSelfie™ Authentication section of the docs.

Last updated