Skip to main content

3D Liveness Detection

3D Liveness Detection in FACIA serves as a cutting-edge technology within our biometric authentication systems. Its primary function is to verify that the facial data captured during authentication belongs to a live individual, thereby strengthening security measures and thwarting potential spoofing attempts. This feature plays a vital role in our facial recognition systems, ensuring heightened security and the prevention of unauthorized access.

Generate Liveness URL

To generate the Liveness verification, send a request to the following endpoint with the mentioned sample payload. The liveness URL can be obtained from the API at:

Endpoint

POSThttps://api.facia.ai/generate-liveness-url

Authorization:

Token Type: Bearer
Description:

This API utilizes Access token or Client-Secret key in header for authentication.

You can use your client_id and client_secret key when using the "/request-access-token" endpoint to obtain a Bearer token for authorization while connecting to this API. For additional details on Authorization, click Here

Run in Postman

Request Body Samples:

//POST /generate-liveness-url  HTTP/1.1
//Host: api.facia.ai
//Content-Type: application/json
//Authorization: Bearer <access-token-here>

{
"redirect_url": "https://www.example.com",
"callback_url": "https://www.example.exc.com",
"customer_id": "10",
"customer_email": "[email protected]",
"ttl": 60
}

Request Parameter

ParametersDescription
redirect_url Required: No
Type: String
Example: redirect_url = https://www.example.com/?64db8940a619c1692109120
Indicate the URL to be used for post-transaction redirection.
callback_url Required: No
Type: String
Example: callback_url=https://www.example.exc.com/
Multiple server-to-server calls are initiated to communicate updates on verification status to Facia’s clients. This functionality ensures that clients can maintain real-time updates on their end, even if the end-user's session is interrupted during the process.
customer_id Required: No
Type: String Example: customer_id=10
The id of customer for whom link is being generated.
customer_email Required: No
Type: String
Example: [email protected]
The email of customer for whom link is being generated.
ttl Required: No
Type: Integer
Example: ttl=60
Minimum: 1 minute
Maximum: 43200 minutes (30 days)
Default: 60 minutes
The 'ttl' parameter specifies the time-to-live (ttl) in minutes, indicating the duration until the link expires.

Response Sample


{
"status": true,
"message": "Success",
"result": {
"data": {
"liveness_url": "https://app.facia.ai/?64db8940a619c1692109120",
"reference_id": "W4437KIWN0KDM13",
"callback_url": "https://www.example.exc.com",
"customer_id": "10",
"customer_email": "[email protected]",
"redirect_url": "https://www.example.com"
}
}
}


Response Parameter

ParametersDescription
liveness_urlThe link to perform liveness.
Example: liveness_url=https://app.facia.ai/?64db8940a619c1692109120
reference_idThe unique identified associated with the created transaction.
callback_urlThe link where the transaction response will be sent.
Example: callback_url=https://www.example.exc.com/
customer_idContains the unique ID defined for the end user.
Example: customer_id=10
customer_emailThis key includes the email that belongs to the end user.
redirect_urlIndicate the URL to be used for post-transaction redirection.

iFrame Integration

Integrate the liveness iFrame into your platform to ensure users are physically present during interactions. Use the code snippet below to embed the iframe and pass the liveness_url which you got in response of generate-liveness-url endpoint within the src attribute of the iFrame.

<iframe 
src="liveness_url"
allow="camera"
style="width: 100%; height: 600px; border: none;"
></iframe>

For optimal user experience, we recommend:

  • Minimum width: 375px
  • Minimum height: 600px
  • Responsive layout that adjusts to the container size

Listening to Events from the iFrame

To handle the iFrame communication and capture the events emitted from the liveness verification process, you can use the window.addEventListener method to listen for message events. These events are sent using the postMessage API from the iFrame to the parent window. Here's a detailed explanation and example implementation:

Listening to iFrame Events

The iFrame sends the following events to the parent window:

1. proofSubmitted

  • Purpose: Indicates that the user has submitted the required proof for verification.
  • Response Structure:
    {
    "event": "proofSubmitted",
    "response": {
    "message": "Proof Submitted"
    }
    }

2. livenessProcessing

  • Purpose: Indicates that the liveness verification is in progress.
  • Response Structure:
    {
    "event": "livenessProcessing",
    "response": {
    "message": "Liveness Processing"
    }
    }

3. livenessResultReceived

  • Purpose: Indicates that the liveness verification result has been received.
  • Response Structure (Success):
    {
    "event": "livenessResultReceived",
    "response": {
    "message": "Liveness Passed",
    "client_reference": "<client_reference>",
    "liveness_response": "<liveness_response>",
    "reference_id": "<reference_id>",
    "proof": "<accepted_proof>"
    }
    }
  • Response Structure (Failure):
    {
    "event": "livenessResultReceived",
    "response": {
    "message": "Liveness Failed",
    "client_reference": "<client_reference>",
    "liveness_response": "<liveness_response>",
    "reference_id": "<reference_id>",
    "proof": "<declined_proof>"
    }
    }

Implementation Example

Here's how to listen for these events:

// Add an event listener for messages from the iFrame
window.addEventListener("message", (event) => {
// Verify the origin of the message
if (event.origin !== "https://app.facia.ai") {
return; // Reject messages from unauthorized sources
}

// Handle the received event
const { event: eventName, response } = event.data || {};

switch (eventName) {
case "proofSubmitted":
console.log("Proof submitted:", response.message);
// Handle proof submission logic
break;

case "livenessProcessing":
console.log("Liveness verification in progress:", response.message);
// Handle liveness processing logic
break;

case "livenessResultReceived":
if (response.message === "Liveness Passed") {
console.log("Liveness verification passed:", response);
// Handle success logic
} else if (response.message === "Liveness Failed") {
console.error("Liveness verification failed:", response);
// Handle failure logic
}
break;

default:
console.warn("Unknown event received:", eventName);
}
});