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:
Parameter | Type | Required | Description |
---|
name | String | Y | The name of the AG. Must be unique |
description | String | N | AG's description |
users | Number | N | List of user(s) IDs of the AG |
user_group | Number | N | List of user group(s) IDs of the AG |
access_levels | Number | N | List of access level(s) IDs of the AG |
floor_levels | Number | N | List 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:
Parameter | Type | Description |
---|
AccessGroup | Object | Access Group object |
AccessGroup.id | Number | ID of the Access Group which was created |
AccessGroup.name | String | Name of the Access Group which was created |
DeviceResponse | Object | Device Response object |
DeviceResponse.rows | Array | List of device responses |
DeviceResponse.id | Number | ID of the device which updated it's AG. |
DeviceResponse.code | Number | Response code from the device. 0=Success |
DeviceResponse.result | Boolean | Summary 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.