This article will guide you through how to add or update an existing user's user PIN via BioStar 2 API. 


The following API will add/update PIN for a user : 


PUT        /api/users/{user_id}


[Body Parameters]

ParametersTypeRequiredDescription
pinNumberYPIN of user. Maximum 16 digits. 

 

Request Body Example : 

{

     "User": {

         "pin": <my_pin>

    }

}



Example : I will now demonstrate actual usage of the above API. 

  1. check current user PIN info
  2. add PIN to user
  3. check updated user PIN info 


1. First, let's retrieve an existing user's information and check the PIN value using the API below: 


GET    /api/users/{user_id}

To retrieve the current user Information, for example (for user_id=2):


 

Body response:

A screenshot of a computer code

Description automatically generated


In this example, you can see that the selected user does not have a PIN assigned to his profile yet.

 

2. Now, let's go ahead and add the PIN to the user : 

PUT        /api/users/{user_id}

Request Body Example : 

{

     "User": {

         "pin": <my_pin>

    }

}


Then you would get a response like:

A white background with black and red text

Description automatically generated

 

3. After successfully adding the PIN to the user, let's retrieve the user data again and check that the PIN has been updated :

 GET    /api/users/{user_id}

A screenshot of a computer code

Description automatically generated

In contrast with the first result you can see the encrypted value equivalent to the PIN you previously configured. 

And the “pin_exists” flag set to true.

 

IMPORTANT:

For security concerns the “pin” is encrypted, then you will be able to use the previously configured PIN, and in case the user would not remember its previous PIN, one shall configure or set a new PIN.

 

NOTICE:

A PIN only auth method is not allowed, the least you would need to configure as an auth method will be ID+PIN