Events and Callbacks
The start() method in the Shufti Web SDK initiates the verification process and provides a mechanism to capture the response through a callback function. This response object contains valuable information about the verification flow, allowing you to handle different verification stages.
There are two ways to listen to response:
 Callback Function
 Callback Function  Event Listeners
 Event Listeners Using a Callback Function
 Pass a callback function as an argument to the `start()` method.
Pass a callback function as an argument to the `start()` method. The SDK will execute this function once the verification process reaches a stage or encounters an error.
The SDK will execute this function once the verification process reaches a stage or encounters an error. The callback function receives a single argument, which is the response object containing details about the verification flow.
The callback function receives a single argument, which is the response object containing details about the verification flow.shuftiPro.start((response) => {
    console.log('Verification response:', response);
    // Update your application UI based on the response event (e.g., display success/failure message)
});
Using Event Listeners
 Alternatively, you can subscribe to specific verification events using the `on()` method.
Alternatively, you can subscribe to specific verification events using the `on()` method. The SDK will trigger these events as the verification process progresses.
The SDK will trigger these events as the verification process progresses. Event listeners typically don't receive a response object directly, but you can access the current verification state through the ShuftiPro instance.
Event listeners typically don't receive a response object directly, but you can access the current verification state through the ShuftiPro instance.   shuftiPro.on('shuftiResponse', (response) => {
        console.log('Verification response:', response);
   });
Response
In case of WebSDK initialization with a journey_id, a callback function can be passed to the start() method. This will return a response containing information about the verification process.
The response includes the following key properties:
| Parameters | Description | 
|---|---|
| status_code | Type: int Shufti Verification API uses conventional HTTP response codes to indicate the success or failure of an API request. Details can be found here. | 
| event | Type: String Events are sent in responses that show the status of the request. These events are sent in callbacks for both onsite and offsite verifications. | 
| body | Type: Object Contains additional details related to the verification request. | 
| verification_url | Type: String URL for the verification flow if applicable (e.g., for redirecting the user) | 
Example Response Object
response-object
{
    "body": {
        "reference": "sp-bc-prod-xyz",
        "event": "request.pending",
        "verification_url": "https://app.shuftipro.com/verification/process/",
        "email": null,
        "country": null
    },
    "event": "request.pending",
    "status_code": 200,
}
Response Events
Some of response events are following:
| Event | Description | 
|---|---|
| request.pending | This event is returned for all on-site verifications until the verification is completed or timeout. | 
| verification.accepted | Verification accepted callback. | 
| verification.declined | Verification declined callback. | 
| verification.cancelled | This callback is returned when verification is cancelled midway by the end user. | 
| request.received | This event states that the verification request has been received and is under processing. |