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://app.facia.ai/backend/api/transaction/generate-liveness-url/
Authorization:
Token Type: BearerDescription:
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 "/get-access-token" endpoint to obtain a Bearer token for authorization while connecting to this API. For additional details on Authorization, click Here
Request Body Samples:
- HTTP
- Javascript
- Curl
- PHP
- Python
- Ruby
- Java
- C#
- Go
//POST /backend/api/transaction/generate-liveness-url HTTP/1.1
//Host: app.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,
}
var myHeaders = new Headers();
myHeaders.append("client-secret", "ABC1231231XYZ12321312");
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
var urlencoded = new URLSearchParams();
urlencoded.append("redirect_url", "https://www.example.com");
urlencoded.append("callback_url", "https://www.example.exc.com");
urlencoded.append("customer_id", "10");
urlencoded.append("customer_email", "[email protected]");
urlencoded.append("ttl", 60);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://app.facia.ai/backend/api/transaction/generate-liveness-url", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
curl --location 'https://app.facia.ai/backend/api/transaction/generate-liveness-url/' \
--header 'Content-Type: application/json' \
--data-raw '{
"redirect_url": "https://www.example.com",
"callback_url": "https://www.example.exc.com",
"customer_id": "1",
"customer_email": "[email protected]",
"ttl": 60
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://app.facia.ai/backend/api/transaction/generate-liveness-url',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'redirect_url=https%3A%2F%2Fwww.facia.ai&callback_url=https%3A%2F%2Fwww.facia.ai&customer_id=10&ttl=60&customer_email=test%example.com',
CURLOPT_HTTPHEADER => array(
'client-secret: ABC1231231XYZ12321312',
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://app.facia.ai/backend/api/transaction/generate-liveness-url"
payload='redirect_url=https%3A%2F%2Fwww.facia.ai&callback_url=https%3A%2F%2Fwww.facia.ai&customer_id=10&ttl=60&customer_email=test%example.com' headers = {
'client-secret': 'ABC1231231XYZ12321312',
'Content-Type': 'application/x-www-form-urlencoded'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
require 'net/http'
require 'uri'
url = URI.parse('https://app.facia.ai/backend/api/transaction/generate-liveness-url')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
payload = 'redirect_url=https%3A%2F%2Fwww.facia.ai&callback_url=https%3A%2F%2Fwww.facia.ai&customer_id=10&ttl=60&customer_email=test%example.com'
request = Net::HTTP::Post.new(url.path, {'Content-Type' => 'application/x-www-form-urlencoded', 'client-secret' => 'ABC1231231XYZ12321312'})
request.body = payload
response = http.request(request)
puts response.body
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://app.facia.ai/backend/api/transaction/generate-liveness-url");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
// Corrected payload with properly encoded email
String payload = "redirect_url=https%3A%2F%2Fwww.facia.ai&callback_url=https%3A%2F%2Fwww.facia.ai&customer_id=10&ttl=60&[email protected]";
byte[] postData = payload.getBytes(StandardCharsets.UTF_8);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// Replace "YOUR_CLIENT_SECRET" with your actual client secret
connection.setRequestProperty("client-secret", "YOUR_CLIENT_SECRET");
try (OutputStream outputStream = connection.getOutputStream()) {
outputStream.write(postData);
}
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
System.out.println(response.toString());
} else {
System.out.println("Request failed with response code: " + responseCode);
System.out.println("Response message: " + connection.getResponseMessage());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;
class Program
{
static async Task Main()
{
using (HttpClient client = new HttpClient())
{
string url = "https://app.facia.ai/backend/api/transaction/generate-liveness-url";
string encodedPayload = "redirect_url=https%3A%2F%2Fwww.facia.ai&callback_url=https%3A%2F%2Fwww.facia.ai&customer_id=10&ttl=60&customer_email=test%example.com";
string payload = HttpUtility.UrlDecode(encodedPayload);
client.DefaultRequestHeaders.Add("client-secret", "ABC1231231XYZ12321312");
HttpResponseMessage response = await client.PostAsync(url, new StringContent(payload, Encoding.UTF8, "application/x-www-form-urlencoded"));
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
}
package main
import (
"bytes"
"fmt"
"net/http"
"net/url"
)
func main() {
url := "https://app.facia.ai/backend/api/transaction/generate-liveness-url"
client := &http.Client{}
payload := "redirect_url=https%3A%2F%2Fwww.facia.ai&callback_url=https%3A%2F%2Fwww.facia.ai&customer_id=10&ttl=60&customer_email=test%example.com"
decodedPayload, err := url.QueryUnescape(payload)
if err != nil {
fmt.Println("Error decoding payload:", err)
return
}
req, err := http.NewRequest("POST", url, bytes.NewBufferString(decodedPayload))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("client-secret", "ABC1231231XYZ12321312")
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
buf := new(bytes.Buffer)
buf.ReadFrom(resp.Body)
fmt.Println(buf.String())
}
Request Parameter
Parameters | Description |
---|---|
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
Parameters | Description |
---|---|
liveness_url | The link to perform liveness. Example: liveness_url=https://app.facia.ai/?64db8940a619c1692109120 |
reference_id | The unique identified associated with the created transaction. |
callback_url | The link where the transaction response will be sent. Example: callback_url=https://www.example.exc.com/ |
customer_id | Contains the unique ID defined for the end user. Example: customer_id=10 |
customer_email | This key includes the email that belongs to the end user. |
redirect_url | Indicate the URL to be used for post-transaction redirection. |
Get Liveness Url Status
To check the status of the Liveness generated URL, send a request to the following API endpoint using GET method.
Endpoint
GEThttps://app.facia.ai/backend/api/transaction/liveness-url-status/<liveness_reference_id>
Authorization:
Token Type: BearerDescription:
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 "/get-access-token" endpoint to obtain a Bearer token for authorization while connecting to this API. For additional details on Authorization, click Here
Request Body Samples:
- HTTP
- Javascript
- Curl
- PHP
- Python
- Ruby
- Java
- C#
- Go
//GET /backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ HTTP/1.1
//Host: app.facia.ai
//client-secret: <your client_secret key>
var myHeaders = new Headers();
myHeaders.append("client-secret", "ABC1231231XYZ12321312");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://app.facia.ai/backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
curl --location '"https://app.facia.ai/backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ"' \
--data ''
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://app.facia.ai/backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'client-secret: ABC1231231XYZ12321312'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://app.facia.ai/backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ"
payload={} headers = {
'client-secret': 'ABC1231231XYZ12321312'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
require 'net/http'
require 'uri'
url = URI.parse('https://app.facia.ai/backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url.path, {'client-secret' => 'ABC1231231XYZ12321312'})
response = http.request(request)
puts response.body
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
try {
URL url = new URL("https://app.facia.ai/backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("client-secret", "ABC1231231XYZ12321312");
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
System.out.println(response.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
using (HttpClient client = new HttpClient())
{
string url = "https://app.facia.ai/backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ";
client.DefaultRequestHeaders.Add("client-secret", "ABC1231231XYZ12321312");
HttpResponseMessage response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://app.facia.ai/backend/api/transaction/liveness-url-status/XJZKDN0J3WULFUZ"
client := &http.Client{}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Add("client-secret", "ABC1231231XYZ12321312")
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
fmt.Println(string(body))
}
Response Sample
{
"status": true,
"message": "Success",
"result": {
"data": {
"reference_id": "W4437KIWN0KDM13",
"expired": "true",
"customer_id": "10",
"customer_email": "[email protected]",
"transactions": [
{
"reference_id": "YVJFBNYYKXUMLKU",
"status": "DECLINED",
"image_proof": "https://portal.facia.ai/backend/api/merchant/get-image-stream/?photo_id=64dcf9639c061a573003aeb6&client_id=c20ad4d76f",
"video_proof": null
},
{
"reference_id": "MCC49WVARIXUOQ8",
"status": "DECLINED",
"image_proof": "https://portal.facia.ai/backend/api/merchant/get-image-stream/?photo_id=64dcf96a9c061a573003aeb9&client_id=c20ad4d76f",
"video_proof": null
},
{
"reference_id": "6JSXYUGEJ9DONL6",
"status": "ACCEPTED",
"image_proof": "https://portal.facia.ai/backend/api/merchant/get-image-stream/?photo_id=64dcf9739c061a573003aebc&client_id=c20ad4d76f",
"video_proof": null
}
]
}
}
}
Response Parameter
Parameters | Description |
---|---|
reference_id | Type: string Example: reference_id = W4437KIWN0KDM13 |
expired | Type: boolean Example: expired = true |
customer_id | Type: string Example: customer_id=10 |
customer_email | Type: string Example: customer_email = [email protected] |
transactions | Type: array List of transactions. |