Active Liveness Sessions
A session is required when you want integrate our Prebuilt Web Pages into your product/platform. It contains the unique URL for your user to access the prebuilt web pages.
Active Liveness Sessions Object
- Name
status
- Type
- string
- Description
The status of the session. Possible values are:
PENDING
when the user has not finished the session.FINISHED
when the user has finished the session.
- Name
expired
- Type
- number
- Description
Number (in milliseconds since epoch) indicating the session expiration.
- Name
url
- Type
- string
- Description
The URL to access the session.
- Name
success_url
- Type
- string
- Description
The URL the user will be directed to after the session is successful.
- Name
cancel_url
- Type
- string
- Description
If set, the prebuilt web pages will show a back button and users will be directed to this URL if they decide to cancel.
- Name
number_of_gestures
- Type
- number
- Description
The number of gestures you want to detect.
- Name
result
- Type
- string
- Description
Contains the result. When the session has not been finished. The
result
will be null.
Create an Active Liveness Session
Create an active liveness session. By default, a session will automatically expire after 24 hours.
Required parameter
- Name
success_url
- Type
- string
- Description
When the session is successful, GLAIR will redirect to this URL. When GLAIR redirects your user to
success_url
, GLAIR will appendsid
to the query parameter. Use thissid
to retrieve the result if necessary.
Optional parameter
- Name
number_of_gestures
- Type
- number
- Description
Set the number of gestures you want to detect in this parameter. If not set, the default will be
1
. See the list of gestures at Active Liveness.
- Name
cancel_url
- Type
- string
- Description
If set, GLAIR will show a back button on the prebuilt-UI and your user will be directed to this URL when the button is clicked.
Sample Request
1
2
3
4
5
6
7
8
import { Vision } from '@glair/vision';
const vision = new Vision({ apiKey: 'api-key', username: 'username', password: 'password' });
await vision.faceBio.activeLivenessSessions.create({
success_url: `SUCCESS_URL`,
cancel_url: `CANCEL_URL`
});
Sample Response
1
2
3
4
5
6
7
{
"status": "PENDING",
"success_url": "https://yourdomain.com?success=true",
"cancel_url": "https://yourdomain.com?cancel=true",
"number_of_gestures": 1,
"url": "https://vision.glair.ai/active-liveness/eyJhbgc9asdalkja"
}
Retrieve an Active Liveness Session
Create an active liveness session. By default, a session will automatically expire after 24 hours.
Required parameter
- Name
sid
- Type
- string
- Description
The session ID you want to retrieve.
Sample Request
1
2
3
4
5
import { Vision } from '@glair/vision';
const vision = new Vision({ apiKey: 'api-key', username: 'username', password: 'password' });
await vision.faceBio.activeLivenessSessions.retrieve({ sid: 'SID' });
Sample Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"status": "FINISHED",
"expired": 1678247333160,
"url": "https://vision.glair.ai/active-liveness/eyJhbgc9asdalkja",
"success_url": "https://yourdomain.com?success=true",
"cancel_url": "https://yourdomain.com?cancel=true",
"result": {
"status": "success",
"result": {
"gesture_status": "MATCH",
"detected_gesture": "HEAD_LEFT"
}
}
}