Skip to main content
Skip table of contents

Create an administrator role

Create an administrator role

РRoles serve as templates for sets of permissions. Updating and deleting roles does not affect the permissions of users to whom they were applied.

POST /api/admin/v1/roles

Method parameters

string name, role name


string type, role type


array permissions, array of permission IDs, existing with the type specified in the 'type' parameter

200 OK

Successful response

JSON
{
    "id": 7,
    "name": "admin",
    "type": "admin",
    "type_pretty": "Administrator",
    "created_at": "2022-03-18 14:41:00",
    "updated_at": "2022-06-06 10:46:14",
    "permissions": [
        {
            "id": 58,
            "name": "cameras-inactive",
            "display_name": "Viewing problem cameras",
            "group": "Cameras"
        },
        {
            "id": 60,
            "name": "cameras-search",
            "display_name": "Camera search",
            "group": "Cameras"
        },
        {
            "id": 66,
            "name": "cameras-destroy",
            "display_name": "Deleting a camera",
            "group": "Cameras"
        }
    ]
}

401 Unauthorized

Authorization token is not provided or is invalid. Obtaining a token

cURL
BASH
curl -k --request POST \
	--url 'https://your-domain/api/admin/v1/roles' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--data '{
    "name": "string",
    "type": "string",
    "permissions": []
}'
PHP
PHP
$data = array (
  'name' => 'string',
  'type' => 'string',
  'permissions' => 
  array (
  ),
);
$context = stream_context_create([
	'ssl'=>['verify_peer' => false],
	'http' => [
		'method' => 'POST',
		'header' => "Content-Type: application/json\r
Accept: application/json",
		'content'=>json_encode($data)
	]
]);
$result = file_get_contents('https://your-domain/api/admin/v1/roles', false, $context);
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.