One of BioStar 2's core features is the ability to create and assign Access Groups, which is essential for efficiently managing user access control.

This guide walks you through the process of creating an access group using the BioStar 2 API.



API Endpoint


To create an Access Group, send a POST Request to:


/api/access_groups


There are a couple of body parameters for this API. 

The only mandatory parameter to send this API successfully is 'name'. 

Please check the following body parameters information and put in the necessary information when creating your access group. 

BODY Parameters:

ParameterTypeRequiredDescription
nameStringYThe name of the AG. Must be unique
descriptionStringNAG's description
usersNumberNList of user(s) IDs of the AG
user_groupNumberNList of user group(s) IDs of the AG
access_levelsNumberNList of access level(s) IDs of the AG
floor_levelsNumberNList of floor level(s) IDs of the AG


NOTES:


* If BioStar 2 does not have a license for the Elevator module, skip the floor_levels parameter or put it like this: "floor_levels": "" 

Please refer to the following article for more information on BioStar 2 license: Server License Specification


* For numeric values such as IDs, you may include them with or without quotation marks. Both formats are accepted.


* How to get the IDs for the request body parameter:


Refer to the following guides and endpoints to retrieve the required IDs for each parameter field. You can find the access level/user group/user you'd like to add to the access group you are creating, get the ID, and input it as the parameter value.


Example Request:

    "AccessGroup": {
        "name": "Test1",
        "description": "Test1 AG'\''s description",
        "users": [
            {
                "user_id": "1"
            },
            {
                "user_id": "2"
            }
        ],
        "user_groups": [
            {
                "id": 1005,
                "name": "Administrative"
            },
            {
                "id": 1004,
                "name": "Executive"
            }
        ],
        "access_levels": [
            {
                "id": "1",
                "name": "Administrative Employee"
            },
            {
                "id": "3",
                "name": "All Access"
            }
        ],
        "floor_levels": [
            {
                "name": "FL1",
                "id": "32769"
            }
        ]
}



Successful Response

If successful, the API returns HTTP 200 OK response with the details of the newly created Access Group.

Response Properties:

ParameterTypeDescription
AccessGroupObjectAccess Group object
AccessGroup.idNumberID of the Access Group which was created
AccessGroup.nameStringName of the Access Group which was created
DeviceResponseObjectDevice Response object
DeviceResponse.rowsArrayList of device responses
DeviceResponse.idNumberID of the device which updated it's AG.
DeviceResponse.codeNumberResponse code from the device. 0=Success
DeviceResponse.resultBooleanSummary of device response. True when all devices successfully updated (code=0), False when even one is failed (code != 0).



Additional Tips

  • If adding users, user groups, or access levels, verify their IDs first to prevent errors.
  • After creation, confirm that all indetended devices updated successfully by checking the DeviceResponse.