This article will guide you through enrolling a card and assigning it to a user via BioStar 2 API. 


    1) List All Added Devices 

    2)  Scan Card

    3) Enroll Card 

    4) Add Card Credentials to a User



STEP 1. List All Added Devices 


GET            /api/devices 


* This step can be skipped if you already know the Id of the device you are going to use for scanning the card. *


This API is used to view all devices recorded on BioStar 2 database. 

Obtain the Id of the device you'd like to use to scan card that's going to be added to the user's credentials. 


Postman Request Example : 


If successful, you'll receive a 200 response code and a response body with a list of all devices.


Find and keep "id" of device you'd like to use to scan card in the next step. The "id" value of device will be used as part of the path variable in the next API.


Device to be used must have a connected status. You can find 'status' of the device from the 'status' field in the response :

 

ParameterTypeDescription
statusIntegerConnection status of the device.
0: Disconnected
1: Connected
2: Sync Error


Postman Response Example : 


STEP 2. Scan Card 


POST         /api/devices/:id/scan_card


This API is used to scan card using a specified device. 


Path Variable : 

'Id' value can be obtained from STEP 1.

ParameterDescription
idId of device used for scanning


Postman Request Example : 


If successful, you'll receive a 200 response code and a response body with scanned card's information. 


Find and keep "card_type" and "card_id" values

For a wiegand card, find and keep "wiegand_format_id" value as well. 

These values will be used as parameters for API to enroll card to BioStar 2 database in the next step.


Postman Response Example : 

In this specific example,  I am reading a wiegand card so you can also see the "wiegand_format_id" field in the response.



STEP 3. Enroll Card


POST         /api/cards


This API is used to add a card to BioStar 2 database. 


Body Parameters : 

Use "card_type", "card_id" and "wiegand_format_id" (only for wiegand type card) values obtained from Step 2. 

ParameterTypeRequiredDescription
card_type:idNumberYCard Type id of the card.
0: CSN card
1: Wiegand Card
2: Secure Credential Card (Smart card)
3: Access on Card (Smart card)
4: Mobile CSN Card
5: Wiegand Mobile
6: QR/Barcode
7: BioStar 2 QR
card_type:typeNumberYType allocation of the card type.
card_idNumberYInput value shown/read when scanning the card.
wiegand_format_id:idNumberYMandatory only when enrolling a wiegand type card.
0: 26 bit format
1: HID 37 bit-H10302
2: HID 37 bit-H10304
3: HID Corporate 1000 (35 bit)
4: HID Corporate 1000 (48 bit)
5~14: Custom formats. 


Postman Request Example : 


If successful, you'll receive a 200 response code and a response body with enrolled card's information. 


Find and keep "id" value of the newly enrolled card for the next Step. This value will be used as a parameter when adding this card credential to a user. 


Postman Response Example :


You can also check from BioStar Web UI that there is a newly enrolled wiegand card that hasn't been assigned yet. 



STEP 4. Add Card Credentials to a User


PUT         /api/users/:id


Path Variable : 

ParameterDescription
iduser Id of user you want to add card credentials to 


Body Parameters : 

Use "id" value obtained from Step 3. 

ParameterTypeRequiredDescription
cards:idNumberYID of card


Postman Request Example : 


If successful, you'll receive a 200 response code.


Postman Response Example : 


You can also check in BioStar 2 Web UI that user with User Id "4" now has a wiegand type card credential.