Face Recognition

submit_job method

Copy this code and replace sections marked with <>

let WebApi = require("smile-identity-core");
let partner_id = '<Put your 3 digit partner ID here>';
let default_callback = '<Put your default callback url here>';
let api_key = '<Put your base64 encoded API key here>'; // Download your API key from the Smile Identity portal
let sid_server = '0'; // Use '0' for the sandbox (test) server, use '1' for production server
// Initialize
connection = new WebApi(partner_id, default_callback, api_key, sid_server);
// Create required tracking parameters
let partner_params = {
user_id: '<put your unique ID for the user here>',
job_id: '<put unique job name here',
// Job Type Integer 1 for jobs that compare a selfie to an ID,
// 2 for authenticating a selfie against a previously registered user,
// 4 for registering a user,
// 8 for updating the enrolled photo
job_type: <1 | 2 | 4| 8>
};
// Create image list
// image_type_id
// 0 - Selfie image jpg or png
// 1 - ID card image jpg or png
// 2 - Selfie image jpg or png base64 encoded
// 3 - ID card image jpg or png base 64 encoded
let image_details = [
{
image_type_id: <0 | 2>,
image: '<path to selfie image or base64 image string>'
},
{ // Not required if suppling ID number info or job type 4 - registration only
image_type_id: <1 | 3>,
mage: '<path to ID card image or base64 image string>'
}
];
// Create ID number info
id_info = {
first_name: '<name>',
last_name: '<surname>',
country: '<country code>',
id_type: '<id type>',
id_number: '<valid id number>',
dob: '<date of birth>', // yyyy-mm-dd
entered: '<true | false>' // must be a string
};
// Create options
options = {
return_job_status: <true | false>,
return_history: <true | false>,
return_image_links: <true |false>
};
response = connection.submit_job(partner_params, image_details, id_info, options)

The response will be a promise. Please note that if you do not need to pass through id_info or options, you may omit calling those class and send through nil in submit_job, as follows:

$ response = connection.submit_job(partner_params, images, null, null);

or

$ response = connection.submit_job(partner_params, images, {}, {});

In the case of a Job Type 5 you can simply omit the the images and options keys. Remember that the response is immediate, so there is no need to query the job_status. There is also no enrollment so no images are required. The response for a job type 5 can be found in the response section below.

$ response = connection.submit_job(partner_params, null, id_info, null);

Example Response:

Should you choose to set return_job_status to false, the response will be a JSON containing:

{success: true, smile_job_id: smile_job_id}

However, if you have set return_job_status to true (with image_links and history) then you will receive a promise that will return a JSON Object response like below:

{
"job_success":true,
"result":{
"ConfidenceValue":"99",
"JSONVersion":"1.0.0",
"Actions":{
"Verify_ID_Number":"Verified",
"Return_Personal_Info":"Returned",
"Human_Review_Update_Selfie":"Not Applicable",
"Human_Review_Compare":"Not Applicable",
"Update_Registered_Selfie_On_File":"Not Applicable",
"Liveness_Check":"Not Applicable",
"Register_Selfie":"Approved",
"Human_Review_Liveness_Check":"Not Applicable",
"Selfie_To_ID_Authority_Compare":"Completed",
"Selfie_To_ID_Card_Compare":"Not Applicable",
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
},
"ResultText":"Enroll User",
"IsFinalResult":"true",
"IsMachineResult":"true",
"ResultType":"SAIA",
"PartnerParams":{
"job_type":"1",
"optional_info":"we are one",
"user_id":"HBBBBBBH57g",
"job_id":"HBBBBBBHg"
},
"Source":"WebAPI",
"ResultCode":"0810",
"SmileJobID":"0000001111"
},
"code":"2302",
"job_complete":true,
"signature":"...",
"history":[
{
"ConfidenceValue":"99",
"JSONVersion":"1.0.0",
"Actions":{
"Verify_ID_Number":"Verified",
"Return_Personal_Info":"Returned",
"Human_Review_Update_Selfie":"Not Applicable",
"Human_Review_Compare":"Not Applicable",
"Update_Registered_Selfie_On_File":"Not Applicable",
"Liveness_Check":"Not Applicable",
"Register_Selfie":"Approved",
"Human_Review_Liveness_Check":"Not Applicable",
"Selfie_To_ID_Authority_Compare":"Completed",
"Selfie_To_ID_Card_Compare":"Not Applicable",
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
},
"ResultText":"Enroll User",
"IsFinalResult":"true",
"IsMachineResult":"true",
"ResultType":"SAIA",
"PartnerParams":{
"job_type":"1",
"optional_info":"we are one",
"user_id":"HBBBBBBH57g",
"job_id":"HBBBBBBHg"
},
"Source":"WebAPI",
"ResultCode":"0810",
"SmileJobID":"0000001111"
}
],
"image_links":{
"selfie_image":"image_link"
},
"timestamp":"2019-10-10T12:32:04.622Z"
}

You can also view your response asynchronously at the callback that you have set, it will look as follows:

{
"job_success":true,
"result":{
"ConfidenceValue":"99",
"JSONVersion":"1.0.0",
"Actions":{
"Verify_ID_Number":"Verified",
"Return_Personal_Info":"Returned",
"Human_Review_Update_Selfie":"Not Applicable",
"Human_Review_Compare":"Not Applicable",
"Update_Registered_Selfie_On_File":"Not Applicable",
"Liveness_Check":"Not Applicable",
"Register_Selfie":"Approved",
"Human_Review_Liveness_Check":"Not Applicable",
"Selfie_To_ID_Authority_Compare":"Completed",
"Selfie_To_ID_Card_Compare":"Not Applicable",
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
},
"ResultText":"Enroll User",
"IsFinalResult":"true",
"IsMachineResult":"true",
"ResultType":"SAIA",
"PartnerParams":{
"job_type":"1",
"optional_info":"we are one",
"user_id":"HBBBBBBH57g",
"job_id":"HBBBBBBHg"
},
"Source":"WebAPI",
"ResultCode":"0810",
"SmileJobID":"0000001111"
},
"code":"2302",
"job_complete":true,
"signature":"HKBhxcv+1qaLy\C7PjVtk257dE=|1577b051a4313ed5e3e4d29893a66f966e31af0a2d2f6bec2a7f2e00f2701259",
"history":[
{
"ConfidenceValue":"99",
"JSONVersion":"1.0.0",
"Actions":{
"Verify_ID_Number":"Verified",
"Return_Personal_Info":"Returned",
"Human_Review_Update_Selfie":"Not Applicable",
"Human_Review_Compare":"Not Applicable",
"Update_Registered_Selfie_On_File":"Not Applicable",
"Liveness_Check":"Not Applicable",
"Register_Selfie":"Approved",
"Human_Review_Liveness_Check":"Not Applicable",
"Selfie_To_ID_Authority_Compare":"Completed",
"Selfie_To_ID_Card_Compare":"Not Applicable",
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
},
"ResultText":"Enroll User",
"IsFinalResult":"true",
"IsMachineResult":"true",
"ResultType":"SAIA",
"PartnerParams":{
"job_type":"1",
"optional_info":"we are one",
"user_id":"HBBBBBBH57g",
"job_id":"HBBBBBBHg"
},
"Source":"WebAPI",
"ResultCode":"0810",
"SmileJobID":"0000001111"
}
],
"image_links":{
"selfie_image":"image_link"
},
"timestamp":"2019-10-10T12:32:04.622Z"
}

You can also view your response asynchronously at the callback that you have set, it will look as follows:

{
"ResultCode": "1220",
"ResultText": "Authenticated",
"ResultType": "DIVA",
"SmileJobID": "0000000001",
"JSONVersion": "1.0.0",
"IsFinalResult": "true",
"PartnerParams": {
"job_id": "e7ca3e6c-e527-7165-b0b5-b90db1276378",
"user_id": "07a0c120-98d7-4fdc-bc62-3c6bfd16c60e",
"job_type": 2
},
"ConfidenceValue": "100.000000",
"IsMachineResult": "true"
}

If an error occurs, the Web Api package will throw an error. Be sure to catch any error that occurs as in this example:

const connection = new webApi(partner_id, default_callback, api_key, sid_server);
const response = connection.submit_job(partner_params, image_details, id_info, options);
response.then((result) => {
// evaluate result if options.return_job_status was true
}).catch((error) => {
// figure out what went wrong
});