API / Usergroups

Usergroups endpoint enables you to get usergroup information and manage usergroups in Silverbucket's database. Endpoint's URL is:

https://<your_environment_url>/customer-api/1.0/usergroups/


GET


When calling /usergroups/ endpoint without parameters you will get all the usergroups from database. Example response:
{
    "count": 1,
    "csvUrl": "/customer-api/1.0/usergroups/?csv=true",
    "itemsPerPage": 500,
    "excelUrl": "/customer-api/1.0/usergroups/?excel=true",
    "next": null,
    "current": 1,
    "lastPage": 1,
    "data": [
        {
            "id": 1,
            "name": "Usergroup 1",
            "code": "U1",
            "active": true,
            "lead": null,
            "users": [
                1,
                2
            ]
        }
    ],
    "previous": null
}

POST


You can add usergroups with POST method to the same URL than get. POST body contains new usergroup's data in JSON format. Successful call will give response code 200 and return the newly created usergroups's JSON. Minimum JSON for adding a usergroup is:
{
    "name": "<string>",
}

ADD PEOPLE


You can add users to usergroup with POST method to URL: /usergroups/add_people/  . POST body contains id of usergroup and list of id's of users to add in JSON format. Successful call will give response code 200 and return the modified data of just modified usergroup in JSON. Example of post:
{
    "usergroup": "<usergroup_id>",
    "people": "<list of user ids>"
}

REMOVE PEOPLE


You can remove users from usergroup with POST method to URL: /usergroups/remove_people/  . POST body contains id of usergroup and list of id's of users to remove in JSON format. Successful call will give response code 200 and return the modified data of just modified usergroup in JSON. Example of post:
{
    "usergroup": "<usergroup_id>",
    "people": "<list of user ids>"
}
How did we do with this article?