This guide explains how to view and update a device's Auth Mode using the BioStar 2 API. 


The Auth Mode defines how users verify their identity, ex: face, fingerprint, PIN, card, or a combination. 

You can configure this through our API.



Prerequisites

  1. You must know the device ID. 
  2. Ensure your logged in account has permission to read and update device settings. 

Step 1. Retrieve Current Auth Mode Data of the Device 


This step is necessary to retrieve the 'operation_modes' data that will be used in the next step.


If you already know the current 'operation_modes' data, or if you wish to change the device's auth mode completely and remove all of the existing auth mode data, you can go to Step 2 directly. 


When you modify the device auth mode in step 2, it will overwrite the current data with whatever you send in. So, if you want to keep the current data and modify part of it or add a new auth mode, this step will be necessary to avoid overwriting them unintentionally. 


To check the current auth modes of a device, 


1. Send a GET request to the following endpoint: 


/api/devices/<device id> 


Replace <device id> with the ID of the device whose authentication mode you want to check. 


2. Check operation_modes in the response

It provides the list of current Auth Modes configured on the device. 


Each Auth Mode object includes: 

  1. mode: The Auth Mode code (see table below at the end of this article). 
  2. schedule_id: the ID of the schedule to which this Auth Mode applies.


Example: 


For the above device auth modes data, you will find operation_modes data as below after running the API:


"operation_modes":

[

    { "mode":"11", "schedule_id":{"id":"1"} },

    {"mode":"40", "schedule_id":{"id":"1"} }

]



Step 2. Modify Authentication Modes 


When you update operation_modes, you overwrite all existing Auth Modes with the new ones you provide. 


For example, if you want to add an Auth Mode while keeping existing ones, include the current Auth Modes in your request along with the new one. 


To update the auth modes, send a PUT request to the same device endpoint: 


/api/devices/<device id> 


In the request body, provide the new "operation_modes" array. 


Each object must include: 

  1. mode: The Auth Mode code (see table below at the end of this article). 
  2. schedule_id: the ID of the schedule to which this Auth Mode applies. 


Example - Adding a New Auth Mode: 


Current Modes: 

[

    { "mode":"11", "schedule_id":{"id":"1"} },

    {"mode":"40", "schedule_id":{"id":"1"} }

] 


If I want to add another Auth Mode(add 'Card Only' Auth Mode = 21)  from the current Auth Modes above, I can use the following request body:

[

    { "mode":"11", "schedule_id":{"id":"1"} },

    {"mode":"40", "schedule_id":{"id":"1"} },

    {"mode":21, "schedule_id":{"id":"1"} }

]


Result:


Previous: 


After:

You can see that a new auth mode with just the card has been added. 



'mode' codes:

11 | FACE_ONLY
12 | FACE_FINGERPRINT
13 | FACE_PIN
14 | FACE_FINGERPRINT_OR_PIN
15 | FACE_FINGERPRINT_PIN
16 | FINGERPRINT_ONLY
17 | FINGERPRINT_FACE
18 | FINGERPRINT_PIN
19 | FINGERPRINT_FACE_OR_PIN
20 | FINGERPRINT_FACE_PIN
21 | CARD_ONLY
22 | CARD_FACE
23 | CARD_FINGERPRINT
24 | CARD_PIN
25 | CARD_FACE_OR_FINGERPRINT
26 | CARD_FACE_OR_PIN
27 | CARD_FINGERPRINT_OR_PIN
28 | CARD_FACE_OR_FINGERPRINT_OR_PIN
29 | CARD_FACE_FINGERPRINT
30 | CARD_FACE_PIN
31 | CARD_FINGERPRINT_FACE
32 | CARD_FINGERPRINT_PIN
33 | CARD_FACE_OR_FINGERPRINT_PIN
34 | CARD_FACE_FINGERPRINT_OR_PIN
35 | CARD_FINGERPRINT_FACE_OR_PIN
36 | ID_FACE
37 | ID_FINGERPRINT
38 | ID_PIN
39 | ID_FACE_OR_FINGERPRINT
40 | ID_FACE_OR_PIN
41 | ID_FINGERPRINT_OR_PIN
42 | ID_FACE_OR_FINGERPRINT_OR_PIN
43 | ID_FACE_FINGERPRINT
44 | ID_FACE_PIN
45 | ID_FINGERPRINT_FACE
46 | ID_FINGERPRINT_PIN
47 | ID_FACE_OR_FINGERPRINT_PIN
48 | ID_FACE_FINGERPRINT_OR_PIN
49 | ID_FINGERPRINT_FACE_OR_PIN