Breadcrumbs

Create a tree element

The method and parameters

POST  /api/v1/billing/tree

There are two types of tree structures: one for cameras and one for intercoms.

When creating elements, you can specify a custom key to reference that element. These keys must be unique within the same tree type.

When creating a subtree element, you can provide either an ID from the VMS database or the custom key specified during creation.

A tree element cannot simultaneously contain both child elements and terminal objects.

After creating a root tree element, it will become accessible to administrators who have permission to Synchronize tree root elements to user (groups-root-sync).

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

The parameters

string name, Name of the tree element


string type, Tree type


string|int external_id, Key for tree element


int parent_id, Necessary for creating a subelement in the tree through id in VMS database


string|int parent_external_id, Required to create a subelement in the tree through the unique key specified when creating it


bool is_last, To create a final group to which elements can be added


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 object with an error. For details, see General information > Validation.

JSON
{
    "message": "No error message here",
    "errors": {
        "any_key": [
            "Error details"
        ]
    }
}
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,
    "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,
  '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);