Please select required verification services to generate integration code
Face Verification
Document Verification
Address Verification
2 Factor Authentication
AML Checks

Please select request options


Verification Mode ?
Redirect Url ?
Show Consent ? ?
Show Privacy Policy ? ?
Allow Offline ? ?
Show Results ? ?

Please select the information you want to verify


For Document Service
Name
Date of birth
Issue date
Expiry date
Document number

For Address Service
Name
Issue date

Who will provide the verification data to Shufti Pro?
End-User will provide the verification data
Shufti Pro Customer will provide the verification data
Shufti Pro should automatically extract data from documents?
Yes ?
No ?
    
POST /api/ HTTP/1.1
Host: shuftipro.com
Content-Type: application/json
Authorization: Basic WU9VUl9DTElFTlRJRDpZT1VSX1NFQ1JFVF9LRVk=
{
  //your unique request reference
  "reference"           : "1234567",
  //URL where you will receive the webhooks from Shufti Pro
  "callback_url"         : "http://www.example.com/",
  //end user country
  "country"             : "",
  //select ISO2 code for your desired language on verification screen
  "language"             : "EN",
  //URL where end-user will be redirected after verification completed
  "redirect_url"           : "", 
  //what kind of proofs will be provided to Shufti Pro for verification
  "verification_mode"     : "",
  //allow end-user to upload verification proofs or not if webcam is not accessible
  "allow_offline"         : "1",
  //privacy policy screen will be shown to end-user
  "show_privacy_policy" : "1",
  //verification results screen will be shown to end-user
  "show_results"         : "1",
  //consent screen will be shown to user
  "show_consent"       : "1"
  //face onsite verification
  "face": {
     "proof" : ""
  },
  //face offsite verification
  "face": {
     "proof" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAALCAYAAABCm8wlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoPAxIb88htFgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACxSURBVBjTdY6xasJgGEXP/RvoonvAd8hDyD84+BZBEMSxL9GtQ8Fis7i6BkGI4DP4CA4dnQON3g6WNjb2wLd8nAsHWsR3D7JXt18kALFwz2dGmPVhJt0IcenUDVsgu91eCRZ9IOMfAnBvSCz8I3QYL0yV6zfyL+VUxKWfMJuOEFd+dE3pC1Finwj0HfGBeKGmblcFTIN4U2C4m+hZAaTrASSGox6YV7k+ARAp4gIIOH0BmuY1E5TjCIUAAAAASUVORK5CYII="
  }, 
  //document onsite verification with OCR
  "document"         : {
     "proof"              : "",
     "supported_types"    : ["id_card","driving_license","passport"],
     "name"              : "",
     "dob"                : "",
     "issue_date"          : "",
     "expiry_date"        : "",
     "document_number"  : ""
  },
  //document onsite verification without OCR
  "document"         : {
     "proof"            : "",
     "supported_types"  : ["id_card","driving_license","passport"],
     "name"            : {
        "first_name"     : "John",
        "middle_name"   : "Middleman",
        "last_name"     : "Doe"
     },
     "dob"                : "1980-11-12",
     "issue_date"          : "1990-09-07",
     "expiry_date"        : "2050-10-10",
     "document_number"  : "0989-7752-6291-2387"
  },
  //document offsite verification without OCR
  "document" : {
     "proof"              : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAALCAYAAABCm8wlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoPAxIb88htFgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACxSURBVBjTdY6xasJgGEXP/RvoonvAd8hDyD84+BZBEMSxL9GtQ8Fis7i6BkGI4DP4CA4dnQON3g6WNjb2wLd8nAsHWsR3D7JXt18kALFwz2dGmPVhJt0IcenUDVsgu91eCRZ9IOMfAnBvSCz8I3QYL0yV6zfyL+VUxKWfMJuOEFd+dE3pC1Finwj0HfGBeKGmblcFTIN4U2C4m+hZAaTrASSGox6YV7k+ARAp4gIIOH0BmuY1E5TjCIUAAAAASUVORK5CYII=",
     "additional_proof"    : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAALCAYAAABCm8wlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoPAxIb88htFgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACxSURBVBjTdY6xasJgGEXP/RvoonvAd8hDyD84+BZBEMSxL9GtQ8Fis7i6BkGI4DP4CA4dnQON3g6WNjb2wLd8nAsHWsR3D7JXt18kALFwz2dGmPVhJt0IcenUDVsgu91eCRZ9IOMfAnBvSCz8I3QYL0yV6zfyL+VUxKWfMJuOEFd+dE3pC1Finwj0HfGBeKGmblcFTIN4U2C4m+hZAaTrASSGox6YV7k+ARAp4gIIOH0BmuY1E5TjCIUAAAAASUVORK5CYII=",
     "supported_types"    : ["id_card","driving_license","passport"],
     "name"              : {
         "first_name"      : "John",
         "middle_name"  : "Middleman",
         "last_name"      : "Doe"
     },
     "dob"                : "1980-11-12",
     "issue_date"          : "1990-09-07",
     "expiry_date"        : "2050-10-10",
     "document_number"  : "0989-7752-6291-2387"
  },
  //document offsite verification with OCR
  "document"         : {
     "proof"              : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAALCAYAAABCm8wlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoPAxIb88htFgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACxSURBVBjTdY6xasJgGEXP/RvoonvAd8hDyD84+BZBEMSxL9GtQ8Fis7i6BkGI4DP4CA4dnQON3g6WNjb2wLd8nAsHWsR3D7JXt18kALFwz2dGmPVhJt0IcenUDVsgu91eCRZ9IOMfAnBvSCz8I3QYL0yV6zfyL+VUxKWfMJuOEFd+dE3pC1Finwj0HfGBeKGmblcFTIN4U2C4m+hZAaTrASSGox6YV7k+ARAp4gIIOH0BmuY1E5TjCIUAAAAASUVORK5CYII=",
     "additional_proof"    : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAALCAYAAABCm8wlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoPAxIb88htFgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACxSURBVBjTdY6xasJgGEXP/RvoonvAd8hDyD84+BZBEMSxL9GtQ8Fis7i6BkGI4DP4CA4dnQON3g6WNjb2wLd8nAsHWsR3D7JXt18kALFwz2dGmPVhJt0IcenUDVsgu91eCRZ9IOMfAnBvSCz8I3QYL0yV6zfyL+VUxKWfMJuOEFd+dE3pC1Finwj0HfGBeKGmblcFTIN4U2C4m+hZAaTrASSGox6YV7k+ARAp4gIIOH0BmuY1E5TjCIUAAAAASUVORK5CYII=",
     "supported_types"    : ["id_card","driving_license","passport"],
     "name"              : "",
     "dob"                : "",
     "issue_date"          : "",
     "expiry_date"        : "",
     "document_number"  : ""
  },
  //address onsite verification with OCR
  "address"         : {
     "proof"                : "",
     "supported_types"      : ["id_card","bank_statement"],
     "name"                : "",
        "issue_date"            : "",
        "full_address"          : "",
        "address_fuzzy_match"  : "1"
  }
  //address onsite verification without OCR
  "address"         : {
     "proof"            : "",
     "supported_types"  : ["id_card","bank_statement"],
     "name"            : {
        "first_name"    : "John",
        "middle_name"  : "Middleman",
        "last_name"    : "Doe"
     },
     "full_address"          : "3339 Maryland Avenue, Largo, Florida",
     "address_fuzzy_match"  : "1",
     "issue_date"            : "1990-09-07"
  },
  //address offsite verification without OCR
  "address" : {
     "proof"             : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAALCAYAAABCm8wlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoPAxIb88htFgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACxSURBVBjTdY6xasJgGEXP/RvoonvAd8hDyD84+BZBEMSxL9GtQ8Fis7i6BkGI4DP4CA4dnQON3g6WNjb2wLd8nAsHWsR3D7JXt18kALFwz2dGmPVhJt0IcenUDVsgu91eCRZ9IOMfAnBvSCz8I3QYL0yV6zfyL+VUxKWfMJuOEFd+dE3pC1Finwj0HfGBeKGmblcFTIN4U2C4m+hZAaTrASSGox6YV7k+ARAp4gIIOH0BmuY1E5TjCIUAAAAASUVORK5CYII=",
     "supported_types"   : ["id_card","bank_statement"],
      "name"             : {
        "first_name"    : "John",
        "middle_name"  : "Middleman",
        "last_name"    : "Doe"
     },
     "full_address"          : "3339 Maryland Avenue, Largo, Florida",
     "address_fuzzy_match"  : "1",
     "issue_date"            : "1990-09-07"
  },
  //address offsite verification with OCR
  "address"         : {
     "proof"                : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAALCAYAAABCm8wlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoPAxIb88htFgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACxSURBVBjTdY6xasJgGEXP/RvoonvAd8hDyD84+BZBEMSxL9GtQ8Fis7i6BkGI4DP4CA4dnQON3g6WNjb2wLd8nAsHWsR3D7JXt18kALFwz2dGmPVhJt0IcenUDVsgu91eCRZ9IOMfAnBvSCz8I3QYL0yV6zfyL+VUxKWfMJuOEFd+dE3pC1Finwj0HfGBeKGmblcFTIN4U2C4m+hZAaTrASSGox6YV7k+ARAp4gIIOH0BmuY1E5TjCIUAAAAASUVORK5CYII=",
     "supported_types"      : ["id_card","bank_statement"],
     
        "name"                : "",
        "full_address"          : "",
        "address_fuzzy_match"  : "1",
        "issue_date"            : ""
     }
  //consent onsite verification
  "consent":{
        "proof"            : "",
        "supported_types"  : ["handwritten","printed"],
        "text"              : "this is a customized text"
  },
  //consent offsite verification
  "consent":{
        "proof"            : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAALCAYAAABCm8wlAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4QoPAxIb88htFgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAACxSURBVBjTdY6xasJgGEXP/RvoonvAd8hDyD84+BZBEMSxL9GtQ8Fis7i6BkGI4DP4CA4dnQON3g6WNjb2wLd8nAsHWsR3D7JXt18kALFwz2dGmPVhJt0IcenUDVsgu91eCRZ9IOMfAnBvSCz8I3QYL0yV6zfyL+VUxKWfMJuOEFd+dE3pC1Finwj0HfGBeKGmblcFTIN4U2C4m+hZAaTrASSGox6YV7k+ARAp4gIIOH0BmuY1E5TjCIUAAAAASUVORK5CYII=",
        "supported_types"  : ["handwritten","printed"],
        "text"              : "this is a customized text"
  },
  //phone verification
  "phone": {
        "phone_number"  : "+4400000000",
        "random_code"  : "23234",
        "text"            : "Your verification code is 23234"
  },
  //background/AML checks verification without ocr
  "background_checks": {
        "name"             : {
                "first_name"    : "John",
                "middle_name" : "Middleman",
                "last_name"    : "Doe"
        },
        "dob"             : "1980-11-12"
  }
  //background/AML checks verification with ocr
  "background_checks":  ""
}
    
    
    
/**
* NOTE:
* Install or include the js-sha256 libaray to calculate the response sha256 hash
* install via npm:
* - npm i js-sha256
* or include from cdn:
* - https://cdnjs.cloudflare.com/ajax/libs/js-sha256/0.9.0/sha256.min.js
**/
let payload = {
    //your unique request reference
    "reference"           : `SP_REQUEST_${Math.random()}`,
    //URL where you will receive the webhooks from Shufti Pro
    "callback_url"         : "https://yourdomain.com/profile/sp-notify-callback",
    //end user country
    "country"             : "",
    //select ISO2 code for your desired language on verification screen
    "language"           : "EN",
    //URL where end-user will be redirected after verification completed
    "redirect_url"           : "", 
    //what kind of proofs will be provided to Shufti Pro for verification
    "verification_mode"     : "",
    //allow end-user to upload verification proofs or not if webcam is not accessible
    "allow_offline"         : "1",
    //privacy policy screen will be shown to end-user
    "show_privacy_policy" : "1",
    //verification results screen will be shown to end-user
    "show_results"         : "1",
    //consent screen will be shown to user
    "show_consent"       : "1"
}
//face onsite verification
payload['face'] = ""
convertImgToBase64URL('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-face.jpg').then(response=>{
    //face offsite verification
    payload['face'] = {
        proof : response
    }

//document onsite verification with OCR
payload['document'] = {
    
    name              : "",
    dob                : "",
    document_number  : "",
    expiry_date        : "",
    issue_date          : "",
    supported_types    : ['id_card','passport']
}
//document onsite verification without OCR
payload['document'] = {
      name : {
        first_name     : 'Your first name',
        last_name     : 'You last name',
        fuzzy_match   : '1'
    },
    dob                : '1992-10-10',
    document_number  : '2323-5629-5465-9990',
    expiry_date        : '2025-10-10',
    issue_date          : '2015-10-10',
    supported_types    : ['id_card','passport']
}
//address onsite verification with OCR
payload['address'] = {
    name                 : "",
    full_address           : "",
    address_fuzzy_match   : '1',
    issue_date             : "",
    supported_types       : ['utility_bill','passport','bank_statement']
}
//address onsite verification without OCR
payload['address'] = {
    name : {
        first_name     : 'Your first name',
        last_name     : 'You last name',
        fuzzy_match   : '1'
    },
    full_address           : 'your address',
    address_fuzzy_match   : '1',
    issue_date             : '2015-10-10',
    supported_types       : ['utility_bill','passport','bank_statement']
}
//consent onsite verification
payload['consent'] = {
    "proof"            : "",
    "supported_types"  : ["handwritten","printed"],
    "text"              : "this is a customized text"
}
//phone verification
payload['phone'] = {
    "phone_number"  : "+4400000000",
    "random_code"  : "23234",
    "text"            : "Your verification code is 23234"
}
//background check/AML verification without OCR
payload['background_checks'] = {
    name : {
        first_name      : 'Your first name',
        middle_name  : 'Your middle name',
        last_name      : 'You last name',
    },
    dob    : '1994-01-01',
}
//background check/AML verification with OCR
payload['background_checks'] = "" 

var token = btoa("YOUR_CLIENTID:YOUR_SECRET_KEY"); //BASIC AUTH TOKEN
var responseSingature = null;
//Dispatch request via fetch API or with whatever else which best suits for you
fetch('https://shuftipro.com/api/',
{
    method : 'post',
    headers : {
        'Accept'        : 'application/json',
        'Content-Type'  : 'application/json',
        'Authorization'  : 'Basic ' +token
    },
body: JSON.stringify(payload)
})
.then(function(response) {
    responseSingature = response.headers.get('Signature');
    return response.json();
}).then(function(data) {
    if(validateSingature(data,responseSingature,'YOUR_SECRET_KEY')){
        console.log('singature validated',data)
    }else{
        console.log('singature not validated',data)
    }
});
//this method is used to validate the response signature
function validateSingature(data,singature,SK){
    data = JSON.stringify(data);
    data = data.replace(/\//g,"\\/")
    data = `${data}${SK}`;

    sha256(data);
    var hash = sha256.create();
    hash.update(data);

    if(hash.hex() == singature){
        return true;
    }else{
        return false;
    }
}
convertImgToBase64URL('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg').then(response=>{
    //offsite document verification without OCR
    payload['document'] = {
        proof : response,
        additional_proof : response,
         name : {
            first_name    : 'Your first name',
            last_name    : 'You last name',
            fuzzy_match : '1'
        },
        dob                : '1992-10-10',
        document_number : '2323-5629-5465-9990',
        expiry_date        : '2025-10-10',
        issue_date          : '2015-10-10',
        supported_types    : ['id_card','passport']
    }
    //offsite document verification with OCR
    payload['document'] = {
        proof              : response,
        additional_proof    : response,
        
        name              : "",
        dob                : "",
        document_number  : "",
        expiry_date        : "",
        issue_date          : "",
        supported_types    : ['id_card','passport']
    }
    //offsite address verification without OCR
    payload['address'] = {
        proof                  : response,
        name                : {
            first_name    : 'Your first name',
            last_name    : 'You last name',
            fuzzy_match : '1'
        },
        full_address          : 'your address',
        address_fuzzy_match : '1',
        issue_date            : '2015-10-10',
        supported_types      : ['utility_bill','passport','bank_statement']
    }
    //offsite address verification with OCR
    payload['address'] = {
        proof                : response,
        name                : "",
        full_address          : "",
        address_fuzzy_match  : '1',
        issue_date            : "",
        supported_types      : ['utility_bill','passport','bank_statement']
    }
    //offsite consent verification
    payload['consent'] = {
        "proof"            : response,
        "supported_types"  : ["handwritten","printed"],
        "text"              : "this is a customized text"
    }
    var token = btoa("YOUR_CLIENTID:YOUR_SECRET_KEY"); //BASIC AUTH TOKEN
    var responseSingature = null;
    //Dispatch request via fetch API or with whatever else which best suits for you
    fetch('https://shuftipro.com/api/',
    {
    method : 'post',
    headers : {
      'Accept'        : 'application/json',
      'Content-Type'  : 'application/json',
      'Authorization'  : 'Basic ' +token
    },
    body: JSON.stringify(payload)
    })
    .then(function(response) {
        responseSingature = response.headers.get('Signature');
        return response.json();
    }).then(function(data) {
        if(validateSingature(data,responseSingature,'YOUR_SECRET_KEY')){
            console.log('singature validated',data)
        }else{
            console.log('singature not validated',data)
        }
        return data;
    });

    })
})
/*METHOD USED TO Get image BASE 64 string*/
function convertImgToBase64URL(url){
  return new Promise(function(resolve, reject) {
    var img = new Image();
    img.crossOrigin = 'Anonymous';
    img.onload = function(){
        var canvas      = document.createElement('CANVAS'),
        ctx              = canvas.getContext('2d'), dataURL;
        canvas.height  = img.height;
        canvas.width    = img.width;
        ctx.drawImage(img, 0, 0);
        dataURL = canvas.toDataURL('image/jpeg');
        resolve(dataURL);
        canvas = null;
    };
    img.src = url;
  })
}
//this method is used to validate Shufti Pro response signature
function validateSingature(data,singature,SK){
   data = JSON.stringify(data);
   data = data.replace(/\//g,"\\/")
   data = `${data}${SK}`;

   sha256(data);
   var hash = sha256.create();
   hash.update(data);

   if(hash.hex() == singature){
       return true;
   }else{
       return false;
   }
}
    
    
    
//Shufti Pro api base url
$url = 'https://shuftipro.com/api/';
//your Shufti Pro account Client ID
$client_id  = 'YOUR_CLIENTID';
//your Shufti Pro account Secret Key
$secret_key = 'YOUR_SECRET_KEY';

$verification_request = [
    //your unique request reference
    "reference"           => 'ref-'.rand(4,444).rand(4,444),
    //URL where you will receive the webhooks from Shufti Pro
    "callback_url"         => 'https://yourdomain.com/profile/notifyCallback',
    //end user country
    "country"             => "",
    //select ISO2 code for your desired language on verification screen
    "language"           => "EN",
    //URL where end-user will be redirected after verification completed
    "redirect_url"           => "", 
    //what kind of proofs will be provided to Shufti Pro for verification
    "verification_mode"     => "",
    //allow end-user to upload verification proofs or not if webcam is not accessible
    "allow_offline"         => "1",
    //privacy policy screen will be shown to end-user
    "show_privacy_policy" => "1",
    //verification results screen will be shown to end-user
    "show_results"         => "1",
    //consent screen will be shown to user
    "show_consent"       => "1",
];
//face onsite verification
$verification_request['face'] = [];
//face onffite verification
$verification_request['face'] = [
    'proof' => base64_encode(file_get_contents('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-face.jpg'))
];
//document onsite verification with OCR
$verification_request['document'] =[
    'name'              => "",
    'dob'                => "",
    'document_number'  => "",
    'expiry_date'          => "",
    'issue_date'          => "",
    'supported_types'    => ['id_card','passport']
];
//document onsite verification without OCR
$verification_request['document'] =[
    'name' => [
        'first_name'     => 'Your first name',
        'last_name'     => 'You last name',
        'fuzzy_match'   => '1'
    ],
    'dob'                => '1992-10-10',
    'document_number'  => '2323-5629-5465-9990',
    'expiry_date'          => '2025-10-10',
    'issue_date'          => '2015-10-10',
    'supported_types'    => ['id_card','passport']
];
//document offsite verification with OCR
$verification_request['document'] =[
    'proof'                => base64_encode(file_get_contents('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg')),
    'additional_proof'      => base64_encode(file_get_contents('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg')),
    'name'              => "",
    'dob'                => "",
    'document_number'  => "",
    'expiry_date'          => "",
    'issue_date'          => "",
    'supported_types'    => ['id_card','passport']
];
//document offsite verification without OCR
$verification_request['document'] =[
    'proof'                => base64_encode(file_get_contents('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg')),
    'additional_proof'      => base64_encode(file_get_contents('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg')),
    'name'              => [
        'first_name'     => 'Your first name',
        'last_name'     => 'You last name',
        'fuzzy_match'   => '1'
    ],
    'dob'                => '1992-10-10',
    'document_number'  => '2323-5629-5465-9990',
    'expiry_date'          => '2025-10-10',
    'issue_date'          => '2015-10-10',
    'supported_types'    => ['id_card','passport']
];
//address onsite verification with ocr
$verification_request['address'] = [
    'name'                => "",
    'full_address'          => "",
    'address_fuzzy_match'  => '1',
    'issue_date'            => "",
    'supported_types'      => ['utility_bill','passport','bank_statement']
];
//address onsite verification without OCR
$verification_request['address'] = [
    'name' => [
        'first_name'   => 'Your first name',
        'last_name'   => 'You last name',
        'fuzzy_match' => '1'
    ],
    'full_address'          => 'your address',
    'address_fuzzy_match'  => '1',
    'issue_date'            => '2015-10-10',
    'supported_types'      => ['utility_bill','passport','bank_statement']
];
//address offsite verification with ocr
$verification_request['address'] = [
    'proof'                  => base64_encode(file_get_contents('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg')),
    'name'                => "",
    'full_address'          => "",
    'address_fuzzy_match'  => '1',
    'issue_date'            => "",
    'supported_types'      => ['utility_bill','passport','bank_statement']
];
//address onsite verification without OCR
$verification_request['address'] = [
    'proof'                  => base64_encode(file_get_contents('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg')),
    'name'                => [
        'first_name'   => 'Your first name',
        'last_name'   => 'You last name',
        'fuzzy_match' => '1'
    ],
    'full_address'          => 'your address',
    'address_fuzzy_match'  => '1',
    'issue_date'            => '2015-10-10',
    'supported_types'      => ['utility_bill','passport','bank_statement']
];
//consent onsite verification
$verification_request['consent'] =[
    'text'             => 'some text for consent verificaiton',
    'supported_types' => ['handwritten','printed'],
];
//consent offsite verification
$verification_request['consent'] =[
    'proof'             => base64_encode(file_get_contents('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-consent-document.jpg')),
    'text'             => 'some text for consent verificaiton',
    'supported_types' => ['handwritten','printed'],
];
//phone verification
$verification_request['phone'] =[
    'phone_number'  => '+1378746734',
    'random_code'    => '9977',
    'text'            => 'Your verification code is 9977'
];
//background checks/AML verification without OCR
$verification_request['background_checks'] = [
    'name' => [
        'first_name'  => 'Your first name',
        'last_name'  => 'You last name'
    ],
    'dob'             => '1992-10-10',
];
$verification_request['background_checks'] = "";
$auth = $client_id.":".$secret_key;
$headers = ['Content-Type: application/json'];
$post_data = json_encode($verification_request);
//Calling Shufti Pro request API using curl
$response = send_curl($url, $post_data, $headers, $auth);
//Get Shufti Pro API Response
$response_data    = $response['body'];
//Get Shufti Pro Signature
$sp_signature    = get_header_keys($response['headers'])['Signature'];
//Calculating signature for verification
$calculate_signature  = hash('sha256',$response_data.$secret_key);
$decoded_response = json_decode($response_data,true);
$event_name = $decoded_response['event'];

if($event_name == 'request.pending'){
    if($sp_signature == $calculate_signature){
        $verification_url = $decoded_response['verification_url'];
        echo "Verification url : $verification_url";
    }else{
        echo "Invalid signature :  $response_data";
    }
}else{
    echo "Error : $response_data";
}
//method to send cURL request
function send_curl($url, $post_data, $headers, $auth){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_USERPWD, $auth);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    $html_response = curl_exec($ch);
    $curl_info = curl_getinfo($ch);
    $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $headers = substr($html_response, 0, $header_size);
    $body = substr($html_response, $header_size);
    curl_close($ch);
    return ['headers' => $headers,'body' => $body];
}
//method to get response headers, main intention to get response Singature from response headers
function get_header_keys($header_string){
    $headers = [];
    $exploded = explode("\n", $header_string);
    if(!empty($exploded)){
        foreach ($exploded as $key => $header) {
            if (!$key) {
                $headers[] = $header;
            } else {
                $header = explode(':', $header);
                $headers[trim($header[0])] = isset($header[1]) ? trim($header[1]) : "";
            }
        }
    }
    return $headers;
}

    
    
    
"""
If you run into error: 'ImportError: No module named requests'
Please run
- pip install requests
"""

#import required libraries
import urllib2, base64, requests, json, hashlib
from random import randint

#Shufti Pro api base url
url = 'https://shuftipro.com/api/'

# Your Shufti Pro account Client ID
client_id  = 'YOUR_CLIENTID'

# Your Shufti Pro account Secret Key
secret_key = 'YOUR_SECRET_KEY'

verification_request = {
    #your unique request reference
    "reference"           : 'ref-{}{}'.format(randint(1000, 9999), randint(1000, 9999)),
    #URL where you will receive the webhooks from Shufti Pro
    "callback_url"         : 'https://yourdomain.com/profile/notifyCallback',
    #end user country
    "country"             : "",
    #select ISO2 Code for your desired language on verification screen
    "language"           : "EN",
    #URL where end-user will be redirected after verification completed
    "redirect_url"           : "", 
    #what kind of proofs will be provided to Shufti Pro for verification
    "verification_mode"     : "",
    #allow end-user to upload verification proofs or not if webcam is not accessible
    "allow_offline"         : "1",
    #privacy policy screen will be shown to end-user
    "show_privacy_policy" : "1",
    #verification results screen will be shown to end-user
    "show_results"         : "1",
    #consent screen will be shown to user
    "show_consent"       : "1"
}
#face onsite verification
verification_request['face'] = {}
#face offsite verification
verification_request['face'] = {
    'proof'             :   base64.b64encode(urllib2.urlopen('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-face.jpg').read())
        }
#document onsite verification with OCR
verification_request['document'] = {
    'name'              : "",
    'dob'                : "",
    'document_number'  : "",
    'expiry_date'          : "",
    'issue_date'          : "",
    'supported_types'    : ['id_card','passport']
}
#document onsite verification without OCR
verification_request['document'] = {
    'name'      :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name',
        'fuzzy_match'   : '1'
    },
    'dob'                : '1992-10-10',
    'document_number'  : '2323-5629-5465-9990',
    'expiry_date'          : '2025-10-10',
    'issue_date'          : '2015-10-10',
    'supported_types'    : ['id_card','passport']
}
#document offsite verification with OCR
verification_request['document'] = {
    'proof'                : base64.b64encode(urllib2.urlopen('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg').read()),
    'additional_proof'      : base64.b64encode(urllib2.urlopen('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg').read()),
    'name'              : "",
    'dob'                : "",
    'document_number'  : "",
    'expiry_date'          : "",
    'issue_date'          : "",
    'supported_types'    : ['id_card','passport']
}
#document offsite verification without OCR
verification_request['document'] = {
    'proof'                : base64.b64encode(urllib2.urlopen('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg').read()),
    'additional_proof'      : base64.b64encode(urllib2.urlopen('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg').read()),
    'name'              :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name',
        'fuzzy_match'   : '1'
    },
    'dob'                : '1992-10-10',
    'document_number'  :   '2323-5629-5465-9990',
    'expiry_date'          : '2025-10-10',
    'issue_date'          : '2015-10-10',
    'supported_types'    : ['id_card','passport']
}
#address onsite verification with OCR
verification_request['address'] = {
    'name'                : "",
    'full_address'          : "",
    'address_fuzzy_match'  : '1',
    'issue_date'            : "",
    'supported_types'      : ['utility_bill','passport','bank_statement']
}
#address onsite verification without OCR
verification_request['address'] =  {
    'name'      :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name',
        'fuzzy_match'   : '1'
    },
    'full_address'          : 'your address',
    'address_fuzzy_match'  : '1',
    'issue_date'            :   '2015-10-10',
    'supported_types'      : ['utility_bill','passport','bank_statement']
}
#address offsite verification with OCR
verification_request['address'] = {
    'proof'                  :   base64.b64encode(urllib2.urlopen('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg').read()),
    'name'                : "",
    'full_address'          : "",
    'address_fuzzy_match'  : '1',
    'issue_date'            : "",
    'supported_types'      : ['utility_bill','passport','bank_statement']
}
#address offsite verification without OCR
verification_request['address'] = {
    'proof'                  :   base64.b64encode(urllib2.urlopen('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg').read()),
    'name'                :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name',
        'fuzzy_match'   : '1'
    },
    'full_address'          : 'your address',
    'address_fuzzy_match'  : '1',
    'issue_date'            : '2015-10-10',
    'supported_types'      : ['utility_bill','passport','bank_statement']
}
#consent onsite verification
verification_request['consent'] =  {
    'text'            : 'some text for consent verificaiton',
    'supported_type'  : ['handwritten','printed']
}
#consent offsite verification
verification_request['consent'] = {
    'proof'              : base64.b64encode(urllib2.urlopen('https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-consent-document.jpg').read()),
    'text'              : 'some text for consent verificaiton',
    'supported_types'  : ['handwritten','printed']
}
#phone verification
verification_request['phone'] =    {
    'phone_number'  : '+1378746734',
    'random_code'    : '9977',
    'text'            : 'Your verification code is 9977'
}
#background checks/AML verification without OCR
verification_request['background_checks'] =    {
    'name'      :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name'
    },
    'dob'    : '1992-10-10'
}
#background checks/AML verification with OCR
verification_request['background_checks'] = ""
# Calling Shufti Pro request API using python requests
auth = '{}:{}'.format(client_id, secret_key)
b64Val = base64.b64encode(auth)
response = requests.post(url,
                headers={"Authorization": "Basic %s" % b64Val, "Content-Type": "application/json"},
                data=json.dumps(verification_request))

# Calculating signature for verification
calculated_signature = hashlib.sha256('{}{}'.format(response.content, secret_key)).hexdigest()

# Get Shufti Pro Signature
sp_signature = response.headers.get('Signature',"")

# Convert json string to json object
json_response = json.loads(response.content)

# Get event returned
event_name = json_response['event']
print json_response
if event_name == 'request.pending':
    if sp_signature == calculated_signature:
        verification_url = json_response['verification_url']
        print 'Verification URL: {}'.format(verification_url)
    else:
        print 'Invalid signature: {}'.format(response.content)
        
        
    
#include required libraries
require 'uri'
require 'net/http'
require 'base64'
require 'json'
require 'open-uri'

#Shufti Pro api base url
url = URI("https://shuftipro.com/api/")

#your Shufti Pro account Client ID
CLIENT_ID   = 'YOUR_CLIENTID'
#your Shufti Pro account Secret Key
SECRET_KEY  = 'YOUR_SECRET_KEY'
#face offsite sample image
SAMPLE_FACE_IMAGE         =  "https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-face.jpg"
#document offsite sample image
SAMPLE_DOCUMENT_IMAGE   =  "https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-id-card.jpg"
#consent offsite sample image
SAMPLE_CONSENT_IMAGE     =  "https://raw.githubusercontent.com/shuftipro/RESTful-API-v1.3/master/assets/real-consent-document.jpg"

verification_request = {
    #your unique request reference
    "reference"           : 'Ref-'+ (0...8).map { (65 + rand(26)).chr }.join,
    #URL where you will receive the webhooks from Shufti Pro
    "callback_url"         : 'https://yourdomain.com/profile/notifyCallback',
    #end user country
    "country"             : "",
    #select ISO2 Code for your desired language on verification screen
    "language"           : "EN",
    #URL where end-user will be redirected after verification completed
    "redirect_url"           : "", 
    #what kind of proofs will be provided to Shufti Pro for verification
    "verification_mode"     : "",
    #allow end-user to upload verification proofs or not if webcam is not accessible
    "allow_offline"         : "1",
    #privacy policy screen will be shown to end-user
    "show_privacy_policy" : "1",
    #verification results screen will be shown to end-user
    "show_results"         : "1",
    #consent screen will be shown to user
    "show_consent"       : "1"
}
#face onsite verification
verification_request['face'] = {}
#face offsite verification
verification_request["face"] = {
    'proof'                : Base64.encode64(open(SAMPLE_FACE_IMAGE).read),
}
#document onsite verification with OCR
verification_request['document'] = {
    'supported_types'    :   ['id_card','driving_license','passport'],
    'name'              : "",
    'dob'                : "",
    'document_number'  : "",
    'expiry_date'          : "",
    'issue_date'          : "",
}
#document onsite verification without OCR
verification_request['document'] = {
    'supported_types' : ['id_card','driving_license','passport'],
    'name'           :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name',
        'fuzzy_match'    : '1'
    },
    'dob'                : '1992-10-10',
    'document_number'  : '2323-5629-5465-9990',
    'expiry_date'          : '2025-10-10',
    'issue_date'          : '2015-10-10',
}
#document offsite verification with OCR
verification_request['document'] = {
    'proof'                : Base64.encode64(open(SAMPLE_DOCUMENT_IMAGE).read),
    'name'              : "",
    'dob'                : "",
    'document_number'  : "",
    'expiry_date'          : "",
    'issue_date'          : "",
    'supported_types'    : ['id_card','driving_license','passport'],
}
#document offsite verification without OCR
verification_request['document'] = {
    'proof'                : Base64.encode64(open(SAMPLE_DOCUMENT_IMAGE).read),
    'supported_types'    : ['id_card','driving_license','passport'],
    'name'              :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name',
        'fuzzy_match'   : '1'
    },
    'dob'                : '1992-10-10',
    'document_number'  : '2323-5629-5465-9990',
    'expiry_date'          : '2025-10-10',
    'issue_date'          : '2015-10-10',
}
#address onsite verification with OCR
verification_request['address'] = {
    'name'                : "",
    'full_address'          : "",
    'address_fuzzy_match'  : '1',
    'issue_date'            : "",
    'supported_types'      : ['utility_bill','passport','bank_statement']
}
#address onsite verification without OCR
verification_request['address'] =  {
    'name'      :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name',
    },
    'full_address'          : 'your address',
    'address_fuzzy_match'  : '1',
    'issue_date'            :   '2015-10-10',
    'supported_types'      : ['utility_bill','passport','bank_statement']
}
#address offsite verification with OCR
verification_request['address'] = {
    'proof'                  : Base64.encode64(open(SAMPLE_DOCUMENT_IMAGE).read),
    'name'                : "",
    'full_address'          : "",
    'address_fuzzy_match'  : '1',
    'issue_date'            : "",
    'supported_types'      : ['utility_bill','passport','bank_statement']
}
#address offsite verification without OCR
verification_request['address'] = {
    'proof'                  : Base64.encode64(open(SAMPLE_DOCUMENT_IMAGE).read),
    'name'                :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name',
    },
    'full_address'          : 'your address',
    'address_fuzzy_match'  : '1',
    'issue_date'            : '2015-10-10',
    'supported_types'      : ['utility_bill','passport','bank_statement']
}
#consent onsite verification
verification_request['consent'] =  {
    'text'            : 'some text for consent verificaiton',
    'supported_type'  : ['handwritten','printed']
}
#consent offsite verification
verification_request['consent'] = {
    'proof'               : Base64.encode64(open(SAMPLE_CONSENT_IMAGE).read),
    'text'               : 'some text for consent verificaiton',
    'supported_types'   : ['handwritten','printed']
}
#phone verification
verification_request['phone'] =    {
    'phone_number'  : '+1378746734',
    'random_code'    : '9977',
    'text'            : 'Your verification code is 9977'
}
#background checks/AML verification without OCR
verification_request['background_checks'] =    {
    'name'      :   {
        'first_name'     : 'Your first name',
        'last_name'     : 'Your last name'
    },
    'dob'    : '1992-10-10'
}
#background checks/AML verification with OCR
verification_request['background_checks'] = ""

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
#set BASIC AUTH
header_auth = Base64.strict_encode64("#{CLIENT_ID}:#{SECRET_KEY}")

request["Content-Type"]  = "application/json"
request["Authorization"] = "Basic #{header_auth}"
request.body = verification_request.to_json

response = http.request(request)
response_headers =  response.instance_variable_get("@header")
response_data    = response.read_body

sp_signature     = response_headers['signature'].join(',')
calculated_signature = Digest::SHA256.hexdigest response_data + SECRET_KEY

if sp_signature == calculated_signature
   puts response_data
else
    puts "Invalid signature"
end