Liveness Session Operations - Create Liveness With Verify Session

Create a new liveness session with verify. Provide the verify image during session creation.
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 /detectLivenessWithVerify/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 With Verify Session operation.
    • To retrieve a result, use the Get Liveness With Verify Session.
    • To audit the individual requests that a client has made to your resource, use the List Liveness With Verify Session Audit Entries.
POST {endpoint}/face/{apiVersion}/detectLivenessWithVerify-sessions

URI Parameters

Name In Required Type Description
livenessOperationMode
formData True

LivenessOperationMode

Type of liveness mode the client should follow.

verifyImage
formData True

file

The image stream for verify. Content-Disposition header field for this part must have filename.

authTokenTimeToLiveInSeconds
formData

integer

int32

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

deviceCorrelationId
formData

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
formData

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
formData

boolean

Whether or not store the session image.

livenessModelVersion
formData

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

returnVerifyImageHash
formData

boolean

Whether or not return the verify image hash.

verifyConfidenceThreshold
formData

number

float

Threshold for confidence of the face verification. Please refer to the documentation for more details. https://learn.microsoft.com/legal/cognitive-services/face/characteristics-and-limitations?context=%2Fazure%2Fai-services%2Fcomputer-vision%2Fcontext%2Fcontext#recognition-confidence-score

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).

Responses

Name Type Description
200 OK

LivenessWithVerifySession

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 LivenessWithVerify Session

Sample request

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

Sample response

{
  "sessionId": "b12e033e-bda7-4b83-a211-e721c661f30e",
  "authToken": "eyJhbGciOiJFUzI1NiIsIm",
  "status": "NotStarted",
  "modelVersion": "2024-11-15",
  "results": {
    "attempts": [],
    "verifyReferences": [
      {
        "referenceType": "image",
        "faceRectangle": {
          "top": 316,
          "left": 131,
          "width": 498,
          "height": 677
        },
        "qualityForRecognition": "high"
      }
    ]
  }
}

Definitions

Name Description
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.

ImageType

The type of image.

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.

LivenessWithVerifyOutputs

The face verification output.

LivenessWithVerifyReference

The detail of face for verification.

LivenessWithVerifyResult

The results of the liveness with verify call.

LivenessWithVerifySession

Session result of detect liveness with verify.

LivenessWithVerifySessionAttempt

The liveness with verify session attempt.

LivenessWithVerifySessionResults

The results of the liveness with verify session.

OperationState

The current status of the session.

QualityForRecognition

Indicates quality of image for recognition.

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.

ImageType

The type of image.

Name Type Description
Color

string

Color image.

Depth

string

Depth image.

Infrared

string

Infrared image.

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.

LivenessWithVerifyOutputs

The face verification output.

Name Type Description
isIdentical

boolean

Whether the target liveness face and comparison image face match.

matchConfidence

number

The target face liveness face and comparison image face verification confidence.

LivenessWithVerifyReference

The detail of face for verification.

Name Type Description
faceRectangle

FaceRectangle

The face region where the comparison image's classification was made.

qualityForRecognition

QualityForRecognition

Quality of face image for recognition.

referenceType

ImageType

The image type which contains the face rectangle where the liveness classification was made on.

LivenessWithVerifyResult

The results of the liveness with verify call.

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.

verifyImageHash

string

The sha256 hash of the verify-image in the request.

verifyResult

LivenessWithVerifyOutputs

The face verification output. Only available when the request is liveness with verify.

LivenessWithVerifySession

Session result of detect liveness with verify.

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

LivenessWithVerifySessionResults

The results of the liveness with verify session.

sessionId

string

The unique ID to reference this session.

status

OperationState

The current status of the session.

LivenessWithVerifySessionAttempt

The liveness with verify 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 with verify call, will be null if there is result.

result

LivenessWithVerifyResult

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

LivenessWithVerifySessionResults

The results of the liveness with verify session.

Name Type Description
attempts

LivenessWithVerifySessionAttempt[]

The attempts data of underlying liveness with verify call with the session.

verifyReferences

LivenessWithVerifyReference[]

The references used for face verification.

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.

QualityForRecognition

Indicates quality of image for recognition.

Name Type Description
high

string

High quality.

low

string

Low quality.

medium

string

Medium quality.