For the complete documentation index, see llms.txt. This page is also available as Markdown.

API reference guide

1. Introduction

This document includes the API description of the libraries provided in the product FacePhi SelphID SDK.

2. SelphID API Description (Front-end)

SelphID SDK is a set of server libraries that uses the information generated by the Widgets of FacePhi for native or web applications. As described in the following sections, some components called Widgets are provided for face capture (Selphi) and identity document capture (SelphID), which can be integrated into the front-end of any application.

2.1. Selphi Widget

Using the widget Selphi, which incorporates the mechanism for facial detection and extraction and the user's liveness, the following information can be obtained through the properties below:

  • Image property: Represents the user's image with the most frontal detected facial pose.

  • TemplateRaw property: Represents the tokenized biometric template of the user with the most frontal detected facial pose. This template is used to perform biometric authentication with SelphID SDK.

Note

Additionally, a tokenized functionality is provided generateTemplateRaw (see API) which allows converting an image or a data buffer into a tokenized data buffer in the form of templateRaw. This templateRaw can be used in several functionalities of SelphID SDK.

2.2. SelphID Widget

Using the widget SelphID, which incorporates the automatic document detection and capture mechanism, the following information can be obtained through the properties below:

  • TokenOCR property: Represents a token (timestamp + AES256 encryption) containing the data detected in the document through the OCR performed.

  • TokenFrontDocument property: Represents the tokenized image (timestamp + AES256 encryption) of the front side of the document cropped to the document edges.

  • TokenBackDocument property: Represents the tokenized image (timestamp + AES256 encryption) of the back side of the document cropped to the document edges.

  • TokenFaceImage property: Represents the tokenized image (timestamp + AES256 encryption) of the user's photograph on the document. This token is used to perform biometric authentication with the SDK.

  • TokenRawFrontDocument property: Represents the tokenized image (timestamp + AES256 encryption) of the front side of the document without cropping to the document edges, that is, as captured by the camera.

  • TokenRawBackDocument property: Represents the tokenized image (timestamp + AES256 encryption) of the back side of the document without cropping to the document edges, that is, as captured by the camera.

3. SelphID API Description (Back-end)

The API of the libraries provided in SelphID is described below, detailing the methods that the integrator can use to incorporate facial recognition, extraction of information from identity documents, and document validation functionalities.

3.1. Library Initialization

SelphIDVerifier represents the main class of the libraries, which contains all the methods available for each of the functionalities.

The initialization of the libraries can be performed in three different ways depending on the configured environment variables:

3.1.1. Initialization using the method loadWithConfigPath()

Prerequisites

Configure the environment variables and the config.cfg file (SDK configuration for On-premise installation):

  • FACEPHI_SELPHID_INSTALL_PATH

  • FACEPHI_SELPHID_INSTALL_BIN

  • LD_LIBRARY_PATH

  • PATH

3.1.2. Initialization using the method load()

Prerequisites

Configure the environment variables and the config.cfg file (SDK configuration for On-premise installation):

  • FACEPHI_SELPHID_INSTALL_PATH

  • FACEPHI_SELPHID_INSTALL_BIN

  • LD_LIBRARY_PATH

  • PATH

It is not necessary to specify the path of the configuration file, since it will be searched automatically in the following path: FACEPHI_SELPHID_INSTALL_PATH/config/selphid.cfg

3.1.3. Initialization using the method loadFromEnvVars()

Prerequisites

Configure the environment variables (SDK configuration for On-premise installation):

  • FACEPHI_SELPHID_INSTALL_PATH

  • FACEPHI_SELPHID_INSTALL_BIN

  • LD_LIBRARY_PATH

  • PATH

  • FACEPHI_SELPHID_DEBUGPATH_KEY

  • FACEPHI_SELPHID_USAGEPATH_KEY

  • FACEPHI_SELPHID_FACIALLIVENESS_PATH_KEY

  • FACEPHI_SELPHID_FACIAL_LICPATH_KEY

Instead of configuring the config.cfg file, these variables are set directly as environment variables.

Important

The initialization of the libraries using the method load(), loadWithConfigPath() or loadFromEnvVars() load()

should only be performed once during the lifecycle of your application. Once all processes involving the use of these libraries are finished, it is important to release the resources associated with them;.

The unloading of the libraries using the method unload() load() Once the method unload(), it is no longer possible to perform a load().

If any condition occurs that prevents the libraries from loading correctly, an SelphIDException. To learn about the exception types, see the corresponding section 3.10. Description of SelphIDException in the provided API.

3.2. Facial extraction methods

To perform the extraction of a user's facial data, the integrator has different methods available in the class SelphIDVerifier. The integrator must use one method or another depending on the data generated on the client. The possible situations are described below.

Note

The result of these methods will always be an object SelphIDFacialExtractionResult, explained in 3.9.1. SelphIDFacialExtractionResult.

3.2.1. Facial extraction using an image

The method to use is the following:

The steps necessary to perform facial extraction using an image are as follows (example method):

Prerequisites

  • Obtain the image (base64 string) through the Image property using the Selphi widget.

  • Send the image base64 string to the server.

3.2.2. Facial extraction using a template

The method to use is the following:

The steps necessary to perform facial extraction using a biometric template are as follows (example method):

Prerequisites

  • Obtain the biometric template (base64 string) through the TemplateRaw property using the Selphi widget.

  • Send the biometric template base64 string to the server.

3.3. Facial authentication methods

To perform a user's facial authentication, the integrator has different methods available in the class SelphIDVerifier. The integrator must use one method or another depending on the data generated on the client. Each of the possible situations is described in the following subsections.

Note

The result of these methods will always be an object SelphIDFacialAuthenticationResult, explained in 3.9.2. SelphIDFacialAuthenticationResult.

3.3.1. Facial authentication using images

The steps necessary to perform facial authentication using two images are as follows (example method):

Prerequisites

  • Obtain the first image (base64 string) through the Image property using the Selphi widget.

  • Obtain the second image (base64 string) through the Image property using the Selphi widget.

  • Send both base64 strings to the server.

3.3.2. Facial authentication using biometric templates

The method to use is the following:

The steps necessary to perform facial authentication using two biometric templates are as follows (example method):

Prerequisites

  • Obtain the first biometric template (base64 string) through the TemplateRaw property using the Selphi widget.

  • Obtain the second biometric template (base64 string) through the TemplateRaw property using the Selphi widget.

  • Send both base64 strings to the server.

3.3.3. Facial authentication using an image and a biometric template

The method to use is the following:

The steps necessary to perform facial authentication using an image and a biometric template are as follows (example method):

Prerequisites

  • Obtain the image (base64 string) through the Image property using the Selphi widget.

  • Obtain the biometric template (base64 string) through the TemplateRaw property using the Selphi widget.

  • Send both base64 strings to the server.

3.3.4. Facial authentication using the photograph on the document and an image

The method to use is the following:

The steps necessary to perform facial authentication using the document photograph and an image are as follows (example method):

Prerequisites

  • Obtain the document photograph token (base64 string) through the TokenFaceImage property using the SelphID widget.

  • Obtain the image (base64 string) through the Image property using the Selphi widget.

  • Send both base64 strings to the server.

3.3.5. Facial authentication using the photograph on the document and a biometric template

The method to use is the following:

  • The steps necessary to perform facial authentication using the document photograph and the user's biometric template are as follows (example method):

Prerequisites

  • Obtain the document photograph token (base64 string) through the TokenFaceImage property using the SelphID widget.

  • Obtain the biometric template (base64 string) through the TemplateRaw property using the Selphi widget.

  • Send both base64 strings to the server.

3.4. Document data extraction method

To obtain the document data necessary in digital Onboarding processes, the integrator has a method in the class SelphIDVerifier.

Note

The result of this method will be an object SelphIDDocumentResult that contains all the data detected in the document. For more information, see the section 3.9.3. SelphIDDocumentResult.

3.4.1. Obtaining the data detected in a document

The method to use is the following:

The steps necessary to obtain the data from a document are as follows (example method):

Prerequisites

  • Get the value of the property TokenOCR (base64 string) using the SelphID widget.

  • Send the base64 string to the server.

3.5. Liveness evaluation methods

To evaluate the user's liveness on the server, a necessary functionality in the digital Onboarding process to avoid fraud by photo or video, the integrator has a method for this purpose in the class SelphIDVerifier.

Note

The result of these methods will always be an object SelphIDFacialLivenessResult, explained in 3.9.4. SelphIDFacialAuthenticationResult.

3.5.1. Liveness evaluation from an image

The steps necessary to perform facial authentication using two images are as follows (example method):

Prerequisites

  • Obtain a user image (base64 string) using the Selphi widget.

  • Send the image base64 string to the server.

3.5.2. Liveness evaluation from a tokenized image

From version 6.21.0, the tokenized image incorporates a defense mechanism against injection attacks. If an invalid token is detected, it will return NoneBecauseTokenDataError or NoneBecauseTokenSecurity as the diagnosis.

The steps necessary to perform facial authentication using two images are as follows (example method):

Prerequisites

  • Obtain a user image (base64 string) using the Selphi widget.

  • Send the image base64 string to the server.

3.6. 1:N identification methods

To perform 1:N searches that allow a specific biometric pattern to be identified against a database and thus obtain a set of candidates with a higher percentage of similarity, the integrator has different methods available in the class SelphIDIdentifier.

As a prerequisite for performing identification operations, a gallery must be created and the set of biometric patterns on which the search will be carried out must be registered in it. To add templates to the gallery, you can use the following methods:

In both methods, the identifier of the gallery to which the template should be added will be specified, as well as a logical identifier referring to the application's business logic, so that the candidates obtained as a result of a search in the gallery can be linked to it.

Note

To register a biometric template in a gallery, it will be necessary to generate the equivalent facial pattern or FacialTemplate by means of any of the following methods of the class SelphIDVerifier:

  • ExtractFacialWithRawTemplate

  • ExtractFacialWithImageBuffer

See the section 3.2.1. Facial extraction using an image.

The search process will be carried out using either of the following two methods of the class SelphIDIdentifier:

The gallery identifier and an object will be specified SelphIDIdentifierOptions with the following search options:

  • MaxIdentificationCandidates, to indicate the maximum number of returned candidates, sorted from highest to lowest similarity percentage.

  • MinIdentificationSimilarity, to indicate the minimum similarity threshold in the comparison for a candidate to be included in the result set.

Note

By default, MaxIdentificationCandidates it will be 20 and MinIdentificationSimilarity it will be 0f.

Next, we will see an example with both methods:

Note

To learn more about SelphIDIdentifierResult, see the section 3.9.5. SelphIDIdentifierResult.

The deletion process consists of blocking a biometric template from a specific gallery so that it is not taken into account in identification processes. If we use the environment variable FACEPHI_SELPHID_GALLERY_REMOVE_METHOD=noerase, this deletion does not reduce the size of the gallery or the indexing of the associated biometric templates. Conversely, omitting this variable or using FACEPHI_SELPHID_GALLERY_REMOVE_METHOD=erase will reduce the gallery size after deletion, altering the indexing of the templates.

The deletion process is carried out with the following method of the class SelphIDIdentifier:

3.6.4. Query and remove obsolete templates

From version 6.17.0, each biometric pattern stores the timestamp (system clock) at which it was indexed in the gallery. This allows querying and deleting "expired" templates according to specific criteria.

In both cases, the template IDs whose timestamps are earlier than the specified interval (in seconds) will be listed. In the case of removeObsoleteGalleryTemplateIDs(), the operation will be atomic and will remove all obsolete patterns in a single operation. If FACEPHI_SELPHID_GALLERY_REMOVE_METHOD=erase, the gallery size will be reduced and the remaining patterns will be reindexed.

The purpose of querying a gallery is to serve as a preliminary step before being able to perform other queries on it.

The process will be carried out with the following class of SelphIDIdentifier:

A gallery identifier must be used to query the specific gallery. Next, we will see what the object SelphIDFacialGalleryInfo:

3.6.6. Query the indices that match a templateID specific

The process of querying all the indices in a gallery that match an exact value of templateID must be carried out with the following method of SelphIDFacialGalleryInfo that we have seen in the previous section:

Important

Starting with SelphID 6.15.0, items with duplicate templateID are not allowed.

A templateID that matches the templateID being searched for in the gallery.

To do this, it is necessary to have an instance of SelphIDFacialGalleryInfo with valid data:

3.7. Orchestrator

The orchestrator allows facial authentication and the person's liveness check to be obtained in the same call. We can choose to perform the check with an image and a template, or with two templates.

Important

The liveness check will only be performed after a successful authentication.

Note

For more information about SelphIDVerifierResult, see the section 3.9.6. SelphIDVerifierResult.

3.8. API Tracking

From version 4.1.0, SelphID-SDK incorporates event tracking functionality that allows monitoring and visualizing API activity through a web interface. The SelphID license will include all the necessary data to access the platform (in the single-tenant version).

All the previous methods from other API versions are still valid. Some duplicate methods have been added that now receive a new parameter containing tokenized data with the essential information to communicate with the tracking server. This parameter is called extraData.

3.8.1. Multi-tenant Version

From version 4.3.0, SelphID-SDK allows two operating modes with respect to event logging through API Tracking:

  • Single-tenant: The API Tracking service connection data are encrypted inside the SelphID-SDK license and will be used in all service calls.

  • Multi-tenant: The connection data will be received in each call through the mobile application. This will allow the SDK to log events on different servers depending on the client making the call.

Important

To enable multi-tenant mode, the tracking data must not be included in the SelphID-SDK license. Otherwise, single-tenant mode will be activated when the backend starts.

From version 5.0.0, it is possible to switch between Single-tenant and Multi-tenant modes at runtime, using these methods of SelphIDVerifier:

3.8.2. Logging

The following method allows decrypted tokenized data in rawDocumentBuffer, such as OCR, document images, etc. The parameter extraData must be sent the data required for the tracking service.

The following methods receive an encrypted image rawTemplateBufferTarget or an unencrypted image imageBufferTarget, to compare it with the image extracted from the document rawDocumentBufferQuery. In both cases, the data required for the tracking service must be sent in the parameter extraData.

3.8.3. SelphIDVerifierOptions

The following methods, added to the class SelphIDVerifierOptions, allow the information entered by the client to be represented on the tracking servers, in the logging use case.

The input parameter of the method setOptionalDataClientInformation must be a well-formed JSON that will accept the following keys:

Note

Any other key will be ignored. More keys will be supported in the future.

From version 6.17.0, the property was added futureTimeAllowed. This allows setting a time interval (in seconds) during which tokenized templates and images with a future date will be accepted, returning true in the method getValidTimeStamp(). This aims to mitigate time zone differences between devices. This value can be configured globally through the environment variable FACEPHI_SELPHID_FUTURE_TIME_ALLOWED=3600.

From version 6.18.0, we can specify which Liveness pipelines we want to run for each operation through setLivenessDepth(). In the case of None (default value), the global configuration established by FACEPHI_SELPHID_FACIALLIVENESS_DEPTH.

3.8.4. Authentication

The following methods are available to perform authentication. The parameters rawTemplateBuffer receive the encrypted image, and the parameter imagebufferQuery receives the unencrypted image. In both cases, the data required for the tracking service must be sent in the parameter extraData.

3.8.5. Passive liveness

The following methods are available to perform the passive liveness check. The parameter tokenBuffer receives the encrypted image and imageBuffer the unencrypted image. In both cases, the data required for the tracking service must be sent in the parameter extraData.

3.8.6. Custom events

From version 4.5.0, SelphID implements the ability to send custom events to the Tracking API, not linked to any internal SDK operation. All custom event operations return a status code and a message, within an object SelphIDApiTrackingResult.

The following method allows sending the following event to the Tracking API: Facial authentication, using the parameters authStatus and similarity. We can also log the image(s) involved in the authentication in the API Tracking service. Both images are optional, accepting null or empty buffers.

Possible values of TrackingFamily:

The following method allows sending the following event to the Tracking API: Liveness, using the parameters diagnostic and similarity. We can also log the image involved in the liveness process in the API Tracking service, although it is optional, accepting a null or empty buffer.

The following method allows sending the following event to the Tracking API: Voice authentication, using the parameter probability. We can also log the audio traces involved in the voice authentication process in the API Tracking service. Both buffers are optional, accepting null or empty values.

The following method allows sending a custom OCR event to the API Tracking server.

ocrDataJson is a key-value dictionary in well-formed JSON format. It accepts any kind of key name with any string value:

The following method allows sending a custom SECURITY_INFO_DATA event to the API Tracking server:

securityDataJson are the security data in JSON format:

succeed is a boolean value indicating whether the retrieval of the security data was successful or not, and source is the name of the service or the source of the security data.

For all custom event operations, we can modify the encrypted field eventSource within the token extraData.

Within custom events, there is the possibility of closing the operation using the following method:

This method will log the events of Operation result (Operation result) and Step change finish (Step change finish), which close the operation.

Important

The meaning of these attributes, including those enums, will be determined by the user.

Possible values of OperationResultStatus:

Possible values of OperationResultReason:

3.8.7. Proxy server

Since version 4.5.5 of SelphID-SDK, it is possible to send requests to the Tracking API through a proxy server. To configure the proxy parameters, use the following method:

To disable the proxy, an empty string must be passed as the parameter proxyHost.

3.9. Description of API results

The following properties, in the result classes, allow you to evaluate the results of each of the methods mentioned above.

From version 6.18.0, in addition to verifying the validity of a token through getValidTimeStamp(), we can now obtain the timestamp embedded in the token itself through getTokenTimeStamp(). This affects:

  • SelphIDFacialExtractionResult.

  • SelphIDFacialAuthenticationResult.

  • SelphIDDocumentResult.

  • SelphIDFacialLivenessResult.

3.9.1. SelphIDFacialExtractionResult

It presents different properties for evaluating the result of facial extraction:

Possible values of FacialPose:

Possible values of FacialQuality:

Possible values of Glasses:

Possible values of Gender:

3.9.2. SelphIDFacialAuthenticationResult

It presents different properties for evaluating the result of biometric authentication:

Important

To evaluate the result you must use the property FacialAuthenticationStatus; the value similarity is only used for statistical purposes.

Possible values of FacialAuthenticationStatus:

3.9.3. SelphIDDocumentResult

It presents different methods for retrieving the images used in the process and the data read from the document. The methods are as follows:

3.9.4. SelphIDFacialLivenessResult

Presents the property FacialLivenessDiagnostic to evaluate the result of the passive liveness check diagnostic.

Possible values of FacialLivenessDiagnostic:

Starting with version 6.18.0, the structure SelphIDNoLiveDetails is included with additional information about the case NoLive. In the case Live, we can also consult the pipeline scores.

3.9.5. SelphIDIdentifierResult

It presents different methods for obtaining the comparison information for each of the candidates returned as a result of a 1:N search. They are as follows:

Possible values of FacialAuthenticationStatus:

Possible values of FacialAuthenticationDetail:

3.9.6. SelphIDVerifierResult

It presents different methods for obtaining information from the orchestrator. They are as follows:

Note

For more information:

3.9.7. SelphIDApiTrackingResult

It presents different methods for obtaining information on the API Tracking operation. They are as follows:

3.10. Description of SelphIDException

If an error occurs within SelphID-SDK, the SelphIDException exception will be thrown.

Possible values of SelphIDExceptionType:

Last updated