Liveness Session Operations - Create Liveness Session

Create a new detect liveness session.
A session is best for client device scenarios where developers want to authorize a client device to perform only a liveness detection without granting full access to their resource. Created sessions have a limited life span and only authorize clients to perform the desired action before access is expired.

Permissions includes...

    • Ability to call /detectLiveness/singleModal for up to 3 retries.
    • A token lifetime of 10 minutes.

Note

Client access can be revoked by deleting the session using the Delete Liveness Session operation. To retrieve a result, use the Get Liveness Session. To audit the individual requests that a client has made to your resource, use the List Liveness Session Audit Entries.

POST {endpoint}/face/{apiVersion}/detectLiveness-sessions

URI Parameters

Name In Required Type Description
apiVersion
path True

string

API Version

endpoint
path True

string

uri

Supported Cognitive Services endpoints (protocol and hostname, for example: https://{resource-name}.cognitiveservices.azure.com).

Request Body

Name Required Type Description
livenessOperationMode True

LivenessOperationMode

Type of liveness mode the client should follow.

authTokenTimeToLiveInSeconds

integer

Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600.

deviceCorrelationId

string

Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null.

deviceCorrelationIdSetInClient

boolean

Whether or not to allow client to set their own 'deviceCorrelationId' via the Vision SDK. Default is false, and 'deviceCorrelationId' must be set in this request body.

enableSessionImage

boolean

Whether or not store the session image.

livenessModelVersion

LivenessModel

The model version used for liveness classification. This is an optional parameter, and if this is not specified, then the latest supported model version will be chosen

Responses

Name Type Description
200 OK

LivenessSession

A successful call create a session for a client device and provide an authorization token for use by the client application for a limited purpose and time.

Other Status Codes

FaceErrorResponse

An unexpected error response.

Headers

x-ms-error-code: string

Security

Ocp-Apim-Subscription-Key

The secret key for your Azure AI Face subscription.

Type: apiKey
In: header

AADToken

The Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: accessCode
Authorization URL: https://api.example.com/oauth2/authorize
Token URL: https://api.example.com/oauth2/token

Scopes

Name Description
https://cognitiveservices.azure.com/.default

Examples

Create Liveness Session

Sample request

POST {endpoint}/face/v1.2/detectLiveness-sessions

{
  "livenessOperationMode": "Passive",
  "deviceCorrelationIdSetInClient": false,
  "deviceCorrelationId": "your_device_correlation_id",
  "authTokenTimeToLiveInSeconds": 60
}

Sample response

{
  "sessionId": "b12e033e-bda7-4b83-a211-e721c661f30e",
  "authToken": "eyJhbGciOiJFUzI1NiIsIm",
  "status": "NotStarted",
  "modelVersion": "2024-11-15",
  "results": {
    "attempts": []
  }
}

Definitions

Name Description
CreateLivenessSessionContent

Request model for creating liveness session.

FaceError

The error object. For comprehensive details on error codes and messages returned by the Face Service, please refer to the following link: https://aka.ms/face-error-codes-and-messages.

FaceErrorResponse

A response containing error details.

FaceRectangle

A rectangle within which a face can be found.

LivenessColorDecisionTarget

The target from color image used for liveness classification.

LivenessDecision

The outcome of the liveness classification.

LivenessDecisionTargets

The targets used for liveness classification.

LivenessError

The error of the liveness classification.

LivenessModel

The model version used for liveness classification.

LivenessOperationMode

The liveness operation mode to drive the client's end-user experience.

LivenessResult

The results of the liveness classification.

LivenessSession

Session result of detect liveness.

LivenessSessionAttempt

The liveness session attempt.

LivenessSessionResults

The results of the liveness session.

OperationState

The current status of the session.

CreateLivenessSessionContent

Request model for creating liveness session.

Name Type Default value Description
authTokenTimeToLiveInSeconds

integer

600

Seconds the session should last for. Range is 60 to 86400 seconds. Default value is 600.

deviceCorrelationId

string

Unique Guid per each end-user device. This is to provide rate limiting and anti-hammering. If 'deviceCorrelationIdSetInClient' is true in this request, this 'deviceCorrelationId' must be null.

deviceCorrelationIdSetInClient

boolean

Whether or not to allow client to set their own 'deviceCorrelationId' via the Vision SDK. Default is false, and 'deviceCorrelationId' must be set in this request body.

enableSessionImage

boolean

Whether or not store the session image.

livenessModelVersion

LivenessModel

The model version used for liveness classification. This is an optional parameter, and if this is not specified, then the latest supported model version will be chosen

livenessOperationMode

LivenessOperationMode

Type of liveness mode the client should follow.

FaceError

The error object. For comprehensive details on error codes and messages returned by the Face Service, please refer to the following link: https://aka.ms/face-error-codes-and-messages.

Name Type Description
code

string

One of a server-defined set of error codes.

message

string

A human-readable representation of the error.

FaceErrorResponse

A response containing error details.

Name Type Description
error

FaceError

The error object.

FaceRectangle

A rectangle within which a face can be found.

Name Type Description
height

integer

The height of the rectangle, in pixels.

left

integer

The distance from the left edge if the image to the left edge of the rectangle, in pixels.

top

integer

The distance from the top edge if the image to the top edge of the rectangle, in pixels.

width

integer

The width of the rectangle, in pixels.

LivenessColorDecisionTarget

The target from color image used for liveness classification.

Name Type Description
faceRectangle

FaceRectangle

The face region where the liveness classification was made on.

LivenessDecision

The outcome of the liveness classification.

Name Type Description
realface

string

The algorithm has classified the target face as real.

spoofface

string

The algorithm has classified the target face as a spoof.

uncertain

string

The algorithm could not classify the target face as either real or spoof.

LivenessDecisionTargets

The targets used for liveness classification.

Name Type Description
color

LivenessColorDecisionTarget

The target from color image used for liveness classification.

LivenessError

The error of the liveness classification.

Name Type Description
code

string

The error code.

message

string

The error message.

targets

LivenessDecisionTargets

Targets used for liveness classification.

LivenessModel

The model version used for liveness classification.

Name Type Description
2024-11-15

string

LivenessOperationMode

The liveness operation mode to drive the client's end-user experience.

Name Type Description
Passive

string

Utilizes a passive liveness technique that requires no additional actions from the user. Requires normal indoor lighting and high screen brightness for optimal performance. And thus, this mode has a narrow operational envelope and will not be suitable for scenarios that requires the end-user's to be in bright lighting conditions. Note: this is the only supported mode for the Mobile (iOS and Android) solution.

PassiveActive

string

This mode utilizes a hybrid passive or active liveness technique that necessitates user cooperation. It is optimized to require active motion only under suboptimal lighting conditions. Unlike the passive mode, this mode has no lighting restrictions, and thus offering a broader operational envelope. This mode is preferable on Web based solutions due to the lack of automatic screen brightness control available on browsers which hinders the Passive mode's operational envelope on Web based solutions.

LivenessResult

The results of the liveness classification.

Name Type Description
digest

string

The server calculated digest for this request. If the client reported digest differs from the server calculated digest, then the message integrity between the client and service has been compromised and the result should not be trusted. For more information, see how to guides on how to leverage this value to secure your end-to-end solution.

livenessDecision

LivenessDecision

The liveness classification for the target face.

sessionImageId

string

The image ID of the session request.

targets

LivenessDecisionTargets

Targets used for liveness classification.

LivenessSession

Session result of detect liveness.

Name Type Description
authToken

string

Bearer token to provide authentication for the Vision SDK running on a client application. This Bearer token has limited permissions to perform only the required action and expires after the TTL time. It is also auditable.

modelVersion

LivenessModel

The model version used for liveness classification. This is an optional parameter, and if this is not specified, then the latest supported model version will be chosen

results

LivenessSessionResults

The results of the liveness session.

sessionId

string

The unique ID to reference this session.

status

OperationState

The current status of the session.

LivenessSessionAttempt

The liveness session attempt.

Name Type Description
attemptId

integer

The attempt ID, start from 1.

attemptStatus

OperationState

The status of the attempt.

error

LivenessError

The error of the liveness call, will be null if there is result.

result

LivenessResult

The result of the liveness call, will be null if there is error.

LivenessSessionResults

The results of the liveness session.

Name Type Description
attempts

LivenessSessionAttempt[]

The attempts data of underlying liveness call with the session.

OperationState

The current status of the session.

Name Type Description
Canceled

string

The operation has been canceled by the user.

Failed

string

The operation has failed.

NotStarted

string

The operation has not started.

Running

string

The operation is in progress.

Succeeded

string

The operation has completed successfully.