26.09 26.06 26.05 25.12
26.09 26.06 26.05 25.12 Russian English

Create tree element. API

Create a tree element

POST  /api/v1/billing/tree

The platform has one tree type: a tree of groups (locations). Cameras and access control devices are placed in its leaf groups.

When creating elements, a custom key can be specified to reference the element. These keys must be unique within the tree.

When creating a child element, either the id from the database or the custom key specified at creation can be provided.

A tree element cannot contain both child elements and leaf objects.

After a root tree element is created, it becomes available to administrators who have permission to synchronize root tree elements with a user: – permission groups-root-sync.

JSON
{
    "name": "new name",
    "type": "cameras",
    "external_id": null,
    "parent_external_id": null,
    "parent_id": null,
    "is_last": true,
    "latitude": null,
    "longitude": null,
    "log_extra": {
        "some": "information"
    }
}

Method parameters

string name, Tree element name


string type, Tree type, always `cameras`. The legacy value `intercoms` is accepted for backward compatibility and creates the same group


string|int external_id, Custom key for the tree element


int parent_id, Required to create a child element using the database ID


string|int parent_external_id, Required to create a child element using its unique key


bool is_last, Create a leaf group to which objects can be added


double latitude, Location latitude, -90 to 90. Must be provided together with `longitude`


double longitude, Location longitude, -180 to 180. Must be provided together with `latitude`


string|array log_extra, Additional information received from an external system

201  Created

Successful response

JSON
{
    "id": 15,
    "name": "Name of item",
    "external_id": "unique_key",
    "has_items": false
}

422  Unprocessable Entity

Returns a JSON error object. For more information, see General information > Validation.

JSON
{
    "message": "No informative message is provided here",
    "errors": {
        "any_key": [
            "The reason for the error is described here"
        ]
    }
}
cURL
Bash
curl -k --request POST \
	--url 'https://your-domain/api/v1/billing/tree' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--data '{
    "name": "string",
    "type": "string",
    "external_id": "string|int",
    "parent_id": 0,
    "parent_external_id": "string|int",
    "is_last": true,
    "latitude": 0,
    "longitude": 0,
    "log_extra": "string|array"
}'
PHP
PHP
$data = array (
  'name' => 'string',
  'type' => 'string',
  'external_id' => 'string|int',
  'parent_id' => 0,
  'parent_external_id' => 'string|int',
  'is_last' => true,
  'latitude' => 0.0,
  'longitude' => 0.0,
  'log_extra' => 'string|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/v1/billing/tree', false, $context);