{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/azure-ai-foundry/json-schema/azure-ai-foundry-liveness-session-schema.json",
  "title": "LivenessSession",
  "description": "Session result of detect liveness.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_superseded/azure-ai-foundry-detectliveness-sessions-api-openapi.yml#/components/schemas/LivenessSession",
  "type": "object",
  "properties": {
    "sessionId": {
      "type": "string",
      "description": "The unique ID to reference this session.",
      "readOnly": true
    },
    "authToken": {
      "type": "string",
      "description": "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."
    },
    "status": {
      "$ref": "#/$defs/Azure.Core.Foundations.OperationState",
      "description": "The current status of the session."
    },
    "modelVersion": {
      "$ref": "#/$defs/LivenessModel",
      "description": "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": {
      "$ref": "#/$defs/LivenessSessionResults",
      "description": "The results of the liveness session."
    }
  },
  "required": [
    "sessionId",
    "authToken",
    "status",
    "results"
  ],
  "$defs": {
    "Azure.Core.Foundations.OperationState": {
      "type": "string",
      "description": "Enum describing allowed operation states.",
      "enum": [
        "NotStarted",
        "Running",
        "Succeeded",
        "Failed",
        "Canceled"
      ],
      "x-ms-enum": {
        "name": "OperationState",
        "modelAsString": true,
        "values": [
          {
            "name": "NotStarted",
            "value": "NotStarted",
            "description": "The operation has not started."
          },
          {
            "name": "Running",
            "value": "Running",
            "description": "The operation is in progress."
          },
          {
            "name": "Succeeded",
            "value": "Succeeded",
            "description": "The operation has completed successfully."
          },
          {
            "name": "Failed",
            "value": "Failed",
            "description": "The operation has failed."
          },
          {
            "name": "Canceled",
            "value": "Canceled",
            "description": "The operation has been canceled by the user."
          }
        ]
      }
    },
    "FaceRectangle": {
      "type": "object",
      "description": "A rectangle within which a face can be found.",
      "properties": {
        "top": {
          "type": "integer",
          "format": "int32",
          "description": "The distance from the top edge if the image to the top edge of the rectangle, in pixels."
        },
        "left": {
          "type": "integer",
          "format": "int32",
          "description": "The distance from the left edge if the image to the left edge of the rectangle, in pixels."
        },
        "width": {
          "type": "integer",
          "format": "int32",
          "description": "The width of the rectangle, in pixels."
        },
        "height": {
          "type": "integer",
          "format": "int32",
          "description": "The height of the rectangle, in pixels."
        }
      },
      "required": [
        "top",
        "left",
        "width",
        "height"
      ]
    },
    "LivenessColorDecisionTarget": {
      "type": "object",
      "description": "The target from color image used for liveness classification.",
      "properties": {
        "faceRectangle": {
          "$ref": "#/$defs/FaceRectangle",
          "description": "The face region where the liveness classification was made on."
        }
      },
      "required": [
        "faceRectangle"
      ]
    },
    "LivenessDecision": {
      "type": "string",
      "description": "The outcome of the liveness classification.",
      "enum": [
        "uncertain",
        "realface",
        "spoofface"
      ],
      "x-ms-enum": {
        "name": "LivenessDecision",
        "modelAsString": true,
        "values": [
          {
            "name": "uncertain",
            "value": "uncertain",
            "description": "The algorithm could not classify the target face as either real or spoof."
          },
          {
            "name": "realFace",
            "value": "realface",
            "description": "The algorithm has classified the target face as real."
          },
          {
            "name": "spoofFace",
            "value": "spoofface",
            "description": "The algorithm has classified the target face as a spoof."
          }
        ]
      }
    },
    "LivenessDecisionTargets": {
      "type": "object",
      "description": "The targets used for liveness classification.",
      "properties": {
        "color": {
          "$ref": "#/$defs/LivenessColorDecisionTarget",
          "description": "The target from color image used for liveness classification."
        }
      },
      "required": [
        "color"
      ]
    },
    "LivenessError": {
      "type": "object",
      "description": "The error of the liveness classification.",
      "properties": {
        "code": {
          "type": "string",
          "description": "The error code."
        },
        "message": {
          "type": "string",
          "description": "The error message."
        },
        "targets": {
          "$ref": "#/$defs/LivenessDecisionTargets",
          "description": "Targets used for liveness classification."
        }
      },
      "required": [
        "code",
        "message",
        "targets"
      ]
    },
    "LivenessModel": {
      "type": "string",
      "description": "The model version used for liveness classification.",
      "enum": [
        "2024-11-15"
      ],
      "x-ms-enum": {
        "name": "LivenessModel",
        "modelAsString": true,
        "values": [
          {
            "name": "v2024_11_15",
            "value": "2024-11-15"
          }
        ]
      }
    },
    "LivenessResult": {
      "type": "object",
      "description": "The results of the liveness classification.",
      "properties": {
        "livenessDecision": {
          "$ref": "#/$defs/LivenessDecision",
          "description": "The liveness classification for the target face."
        },
        "targets": {
          "$ref": "#/$defs/LivenessDecisionTargets",
          "description": "Targets used for liveness classification."
        },
        "digest": {
          "type": "string",
          "description": "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."
        },
        "sessionImageId": {
          "type": "string",
          "description": "The image ID of the session request."
        }
      },
      "required": [
        "targets",
        "digest"
      ]
    },
    "LivenessSessionAttempt": {
      "type": "object",
      "description": "The liveness session attempt.",
      "properties": {
        "attemptId": {
          "type": "integer",
          "format": "int32",
          "description": "The attempt ID, start from 1."
        },
        "attemptStatus": {
          "$ref": "#/$defs/Azure.Core.Foundations.OperationState",
          "description": "The status of the attempt."
        },
        "result": {
          "$ref": "#/$defs/LivenessResult",
          "description": "The result of the liveness call, will be null if there is error."
        },
        "error": {
          "$ref": "#/$defs/LivenessError",
          "description": "The error of the liveness call, will be null if there is result."
        }
      },
      "required": [
        "attemptId",
        "attemptStatus"
      ]
    },
    "LivenessSessionResults": {
      "type": "object",
      "description": "The results of the liveness session.",
      "properties": {
        "attempts": {
          "type": "array",
          "description": "The attempts data of underlying liveness call with the session.",
          "items": {
            "$ref": "#/$defs/LivenessSessionAttempt"
          }
        }
      },
      "required": [
        "attempts"
      ]
    }
  }
}