Skip to main content
Skip table of contents

Obtaining a token

Obtaining a token

User authorization by login and password

POST /api/admin/v1/auth/token

Method parameters

string login, user login


string password, user password

200 OK

Returns a JSON object with an API access token and the current user object

JSON
{
    "user": {
        "id": 87,
        "name": "Name",
        "login": "user@mail.com",
        "created_at": "2022-03-24 11:26:58",
        "updated_at": "2022-03-30 16:48:54",
        "expired_at": null,
        "is_licence_limit_reached": false,
        "permissions": [
            {
                "id": 72,
                "name": "streams-update",
                "display_name": "Updating a video Stream",
                "group": "Video streams"
            },
            {
                "id": 115,
                "name": "dhcp-subnets-destroy",
                "display_name": "Deleting a DHCP network",
                "group": "DHCP subnets"
            },
            {
                "id": 120,
                "name": "servers-update",
                "display_name": "Updating a media server",
                "group": "Servers"
            }
        ],
        "ptz_priority": 10,
        "admin_camera_groups": [
            {
                "id": 97,
                "name": "Cameras",
                "full_pretty": null,
                "is_house": 0,
                "cameras_count": 27,
                "parent_id": null,
                "csa_id": null,
                "intercoms_count": 315
            }
        ],
        "dhcp_subnet_groups": [],
        "access_token_id": null
    },
    "expires_at": "2022-09-08 13:47:18",
    "token_type": "Bearer",
    "access_token": "Bearer token"
}

422 Unprocessable Entity

Returns a JSON object with an error. Validation

JSON
{
    "message": "There will be no informative message here",
    "errors": {
        "any_key": [
            "The reason for the error will be described here"
        ]
    }
}
cURL
BASH
curl -k --request POST \
	--url 'https://your-domain/api/admin/v1/auth/token' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--data '{
    "login": "string",
    "password": "string"
}'
PHP
PHP
$data = array (
  'login' => 'string',
  'password' => 'string',
);
$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/auth/token', false, $context);
JavaScript errors detected

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

If this problem persists, please contact our support.