Get Account Data
Once Verisoul's frontend SDK is initialized with a valid session token, it takes care of verifying a user's liveness and uniqueness. All your application has to do is get the account data Verisoul collected during the session.
To collect this information Verisoul offers two options:
- 1.Query Verisoul's APIYour application can listen for a
Completed
event on the client side and then make a call to Verisoul'sGET /account/{accountId}
endpoint to retrieve the account information. See example below. - 2.Configure a web hookUpon completion of a user verification Verisoul will POST the results of the session to a previously configured web hook.
Your application will know once a user verification is complete by listening for a
Completed
event emitted by the frontend SDK. The event will contain pertinent data about the session including an account_id
. This id is what Verisoul has associated with that completed user verification and can subsequently be used to enroll or block that user. /*FRONTEND*/
const eventHandler = async (event) => {
if (event?.step === 'Complete') {
try {
// pass account_id of completed session to your app's backend
let accountId = event.data.account_id;
const response = await fetch(`my-api.com/${accountId}`);
...
} catch (err) {
console.error(err);
}
}
}
return (
<div>
...
{sessionToken
? <Verisoul session={...}
onComplete={eventHandler}
environment={...}/>
: null
}
</div>
);
Once your application's backend has the account_id it get the session results via Verisoul's API. Verisoul's information provides both metadata and attributes from the user verification. This can include pertinent aspects of a user like if a user has other blocked accounts within your application (
hasBlockedAccounts
) and how many other accounts this person already has (numAccounts
). /*BACKEND*/
try {
// Get a session result with Verisoul API
let response = await fetch(`https://api.verisoul.xyz/account/${accountId}`, {
method: 'GET',
x-api-key: {VERISOUL_API_KEY}
});
if (!response.ok) {
throw new Error(`failed to get Verisoul account: ${response.status}`);
}
let {attributes, numAccounts, hasBlockedAccounts} = await response.json();
} catch (err) {
console.error(err);
}
The account's attributes and metadata will be useful when decisioning an account in the next step.
Last modified 8mo ago