Face Enrollment
In FACIA, face enrollment goes beyond a mere process – it's a personalized journey of capturing and preserving distinctive facial features to craft a unique biometric template. This template serves as the key to seamless identity verification through our advanced facial recognition algorithms, providing a secure and user-friendly authentication method.
Create Face Enrollment Transaction
This endpoint enables users to enroll one or more faces using the POST method:
Endpoint
POSThttps://api.facia.ai/enroll-face
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 "/request-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 /enroll-face HTTP/1.1
//HOST : https://api.facia.ai/
//Content-Type: application/json
//Authorization: Bearer <access-token-here>
{
"file_list": [
"file",
"file"
],
"client_reference": "QWERTY12345",
"allow_override": 0
}
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer token");
var formdata = new FormData();
formdata.append("file_list[0]", fileInput.files[0], "file_example_IMAGE_640_3MG.jpg");
formdata.append("file_list[1]", fileInput.files[0], "file_example_IMAGE_640_3MG.jpg");
formdata.append("client_reference", "QWERTY12345");
formdata.append("allow_override", false);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("/enroll-face", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
curl --location 'https://api.facia.ai/enroll-face' \
--header 'Content-Type: application/json' \
--data '{
{
"file_list[0]": file,
"file_list[1]": file,
"client_reference":"QWERTY12345",
"allow_override":false
}
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/enroll-face',
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 => array('client_reference' => 'QWERTY12345','allow_override'=> false, 'file_list[0]'=> new CURLFILE('file_example_IMAGE_640_3MG.jpg'), 'file_list[1]'=> new CURLFILE('file_example_IMAGE_640_3MG.jpeg')),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer token'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "/enroll-face"
payload={'client_reference': 'QWERTY12345', 'allow_override'=> false}
files=[
('file_list[0]',('file_example_IMAGE_640_3MG.jpg',open('/file_example_IMAGE_640_3MG.jpg','rb'),'image/jpeg')),
('file_list[1]',('file_example_IMAGE_640_3MG.jpg',open('/file_example_IMAGE_640_3MG.jpg','rb'),'image/jpeg')) ]
headers = {
'Authorization': 'Bearer token'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
require 'net/http'
require 'uri'
require 'json'
url = URI.parse('/enroll-face')
token = 'your_token'
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url.path)
request['Authorization'] = "Bearer #{token}"
boundary = '*****'
request['Content-Type'] = "multipart/form-data; boundary=#{boundary}"
body = []
file1 = File.new('file_example_IMAGE_640_3MG.jpg')
file2 = File.new('file_example_IMAGE_640_3MG.jpg')
body << "--#{boundary}\r\n"
body << "Content-Disposition: form-data; name=\"file_list[0]\"; filename=\"#{file1.path}\"\r\n"
body << "Content-Type: #{file1.content_type}\r\n\r\n"
body << file1.read
body << "\r\n"
body << "--#{boundary}\r\n"
body << "Content-Disposition: form-data; name=\"file_list[1]\"; filename=\"#{file2.path}\"\r\n"
body << "Content-Type: #{file2.content_type}\r\n\r\n"
body << file2.read
body << "\r\n"
body << "--#{boundary}\r\n"
body << "Content-Disposition: form-data; name=\"client_reference\"\r\n\r\nQWERTY12345\r\n"
body << "--#{boundary}\r\n"
body << "Content-Disposition: form-data; name=\"allow_override\"\r\n\r\nfalse\r\n"
body << "--#{boundary}--\r\n"
request.body = body.join
response = http.request(request)
puts "Response Code: #{response.code}"
puts "Response Body: #{response.body}"
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class FaceEnrollExample {
public static void main(String[] args) {
try {
String endpoint = "/enroll-face";
String token = "your_token";
URL url = new URL(endpoint);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Authorization", "Bearer " + token);
connection.setDoInput(true);
connection.setDoOutput(true);
String boundary = "*****";
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
OutputStream outputStream = connection.getOutputStream();
File file1 = new File("file_example_IMAGE_640_3MG.jpg");
File file2 = new File("file_example_IMAGE_640_3MG.jpg");
appendFileToFormData(outputStream, boundary, "file_list[0]", file1);
appendFileToFormData(outputStream, boundary, "file_list[1]", file2);
appendFormField(outputStream, boundary, "client_reference", "QWERTY12345");
appendFormField(outputStream, boundary, "allow_override", "false");
outputStream.write(("--" + boundary + "--\r\n").getBytes());
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
private static void appendFileToFormData(OutputStream outputStream, String boundary, String fieldName, File file) throws Exception {
outputStream.write(("--" + boundary + "\r\n").getBytes());
outputStream.write(("Content-Disposition: form-data; name=\"" + fieldName + "\"; filename=\"" + file.getName() + "\"\r\n").getBytes());
outputStream.write(("Content-Type: " + HttpURLConnection.guessContentTypeFromName(file.getName()) + "\r\n\r\n").getBytes());
FileInputStream fileInputStream = new FileInputStream(file);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.write("\r\n".getBytes());
fileInputStream.close();
}
private static void appendFormField(OutputStream outputStream, String boundary, String fieldName, String fieldValue) throws Exception {
outputStream.write(("--" + boundary + "\r\n").getBytes());
outputStream.write(("Content-Disposition: form-data; name=\"" + fieldName + "\"\r\n\r\n" + fieldValue + "\r\n").getBytes());
}
}
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string endpoint = "https://api.facia.ai/enroll-face";
string token = "your_token";
using (var httpClient = new HttpClient())
using (var form = new MultipartFormDataContent())
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var file1 = new FileStream("file_example_IMAGE_640_3MG.jpg", FileMode.Open);
var file2 = new FileStream("file_example_IMAGE_640_3MG.jpg", FileMode.Open);
form.Add(new StreamContent(file1), "file_list[0]", "file_example_IMAGE_640_3MG.jpg");
form.Add(new StreamContent(file2), "file_list[1]", "file_example_IMAGE_640_3MG.jpg");
form.Add(new StringContent("QWERTY12345"), "client_reference");
form.Add(new StringContent("false"), "allow_override");
using (var response = await httpClient.PostAsync(endpoint, form))
{
Console.WriteLine($"Response Code: {response.StatusCode}");
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response Body: {result}");
}
}
}
}
package main
import (
"bytes"
"fmt"
"mime/multipart"
"net/http"
"os"
)
func main() {
endpoint := "/enroll-face"
token := "your_token"
client := &http.Client{}
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
headers := map[string]string{
"Authorization": "Bearer " + token,
}
fileNames := []string{"file_example_IMAGE_640_3MG.jpg", "file_example_IMAGE_640_3MG.jpg"}
for _, fileName := range fileNames {
file, err := os.Open(fileName)
if err != nil {
fmt.Println("Error opening file:", err)
return
}
defer file.Close()
part, err := writer.CreateFormFile("file_list[]", fileName)
if err != nil {
fmt.Println("Error creating form file:", err)
return
}
_, err = io.Copy(part, file)
if err != nil {
fmt.Println("Error copying file to form:", err)
return
}
}
formFields := map[string]string{
"client_reference": "QWERTY12345",
"allow_override": "false",
}
for fieldName, value := range formFields {
_ = writer.WriteField(fieldName, value)
}
writer.Close()
req, err := http.NewRequest("POST", endpoint, body)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
for key, value := range headers {
req.Header.Set(key, value)
}
req.Header.Set("Content-Type", writer.FormDataContentType())
response, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer response.Body.Close()
fmt.Println("Response Code:", response.Status)
responseBody, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
fmt.Println("Response Body:", string(responseBody))
}
Request Parameter
Parameters | Description |
---|---|
file_list[0] | Required: Yes Example: file_list[0]=file file_list is of type array. |
file_list[1] | Required: No Example: file_list[1]=file file_list is of type array. |
client_reference | Required: No Type: string Minimum: 5 characters Maximum: 255 characters Example: client_reference="QWERTY12345" Required if allow_override field set to 1. |
allow_override | Required: No Type: boolean Default value: 0 Accepted values: 0,1 The client reference is mandatory if the value of the override key is set as 1. The override key allow the system to replace the latest previous image with the new one against the specified reference number of the client’s reference. |
Response Sample
{
"status": true,
"message": "Success",
"result": {
"data": {
"client_reference": "QWERTY12345"
"reference_id": [
"GTVFX9YABAOTZAQ",
"9NVFX9YABAOTAVE"
]
}
}
}
Response Parameter
Parameters | Description |
---|---|
client_reference | Type: string Example: client_reference:QWERTY12345 Contains the unique ID defined for the end user. |
reference_id | Type: array Example: reference_id:["GTVFX9YABAOTZAQ","9NVFX9YABAOTAVE"] These are the references of provided proofs that were to be enrolled. |
Get Enrolled Faces
This endpoint facilitates the retrieval of all enrolled faces with an option for pagination using the POST method:
Endpoint
POSThttps://api.facia.ai/enrolled-faces
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 "/request-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 /enrolled-faces HTTP/1.1
//Host: https://api.facia.ai/
//Content-Type: application/json
//client-secret: <your client_secret key>
{
"page": 1,
"pagination": 10
}
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer token");
var formdata = new FormData();
formdata.append("pagination", "20");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("/enrolled-faces", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
curl --location 'https://api.facia.ai/enrolled-faces' \
--header 'Content-Type: application/json' \
--data '{
"pagination": "1"
}'
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '/enrolled-faces',
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 => array(),
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer token'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "/enrolled-faces"
payload={}
files=[
]
headers = {
'Authorization': 'Bearer token'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
require 'net/http'
require 'uri'
url = URI.parse('/enrolled-faces')
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url.path)
request['Authorization'] = 'Bearer token'
response = http.request(request)
puts "Response Code: #{response.code}"
puts "Response Body: #{response.body}"
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class EnrolledFacesRequest {
public static void main(String[] args) {
try {
URL url = new URL("/enrolled-faces");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Authorization", "Bearer token");
int responseCode = connection.getResponseCode();
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 Code: " + responseCode);
System.out.println("Response Body: " + response.toString());
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string apiUrl = "/enrolled-faces";
string authToken = "Bearer token";
using (HttpClient httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", authToken);
HttpResponseMessage response = await httpClient.PostAsync(apiUrl, null);
Console.WriteLine($"Response Code: {response.StatusCode}");
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response Body: {responseBody}");
}
}
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
apiURL := "/enrolled-faces"
authToken := "Bearer token"
client := &http.Client{}
req, err := http.NewRequest("POST", apiURL, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Authorization", authToken)
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("Response Code:", resp.Status)
fmt.Println("Response Body:", string(body))
}
Request Parameter
Parameters | Description |
---|---|
pagination | Type: string Example: pagination=10 |
Response Sample
{
"status": true,
"message": "Success",
"result": {
"data": {
"current_page": 1,
"data": [
{
"reference_id": "123456789",
"client_reference": "QWERTY12345",
"created_at": "2024-01-24T07:13:02.774000Z",
"url": "https://app.facia.ai/backend/api/image-url/65b0b87ef8f644072d0a4124?expires=1706082328&signature=363262c02122e678fb21b3366eb1f7f0221cfc3cb045805f110a6e35df9d0was"
}
],
"first_page_url": "https://api.facia.ai/enrolled-faces?page=1",
"from": 1,
"last_page": 453,
"last_page_url": "https://api.facia.ai/enrolled-faces?page=453",
"links": [
{
"url": null,
"label": "« Previous",
"active": false
},
{
"url": "https://api.facia.ai/enrolled-faces?page=1",
"label": "1",
"active": true
},
{
"url": null,
"label": "...",
"active": false
},
{
"url": "https://api.facia.ai/enrolled-faces?page=452",
"label": "452",
"active": false
},
{
"url": "https://api.facia.ai/enrolled-faces?page=453",
"label": "453",
"active": false
},
{
"url": "https://api.facia.ai/enrolled-faces?page=2",
"label": "Next »",
"active": false
}
],
"next_page_url": "https://api.facia.ai/enrolled-faces?page=2",
"path": "https://api.facia.ai/enrolled-faces",
"pagination": 1,
"prev_page_url": null,
"to": 1,
"total": 453
}
}
}
Response Parameter
Parameters | Description |
---|---|
data | Type: array This includes the enrolled images. |
reference_id | Type: string Example: reference_id=123456789 |
client_reference | Type: string Example: client_reference=QWERTY123456789 Contains the unique ID defined for the end user. |
url | Type: string URL of the proof with the expiry of 15 minutes. |