Breadcrumbs

Create a camera (v2)

The method and parameters

With the release of the new version (v2) of this request, v2 is now the current and recommended version. Support for v1 will continue for six months following the release of v2. After this period, v1 will be deprecated and no longer supported.

POST  /api/v2/billing/cameras

To indicate where to create a camera in the tree, you can send both the ID from our database and the key that is specified when creating the tree element.

If you need to place the camera in a private folder, you can send both the ID from our database and the key that was specified when creating the folder. This folder must be created in the same tree element in which the camera is created. See Create a private folder.

If the request includes the streams field, the settings will be saved for the specified stream type(s) and applied later when creating video streams.

JSON
{
    "name": "Camera 1",
    "mac": "11:11:11:11:11:11",
    "serial_number": "12345678",
    "group_type": "private",
    "group_id": 16,
    "group_external_id": 16,
    "folder_key": 123,
    "folder_id": 3,
    "is_user_owner": false,
    "latitude": -28.776933731993793,
    "longitude": 76.65771489519997,
    "service": "8MP",
    "external_id": "unique_id",
    "onvif_credentials": {
        "login": "login",
        "password": "password",
        "port": 80
    },
    "is_can_manage_archive_storage_days": true,
    "log_extra": {
        "some": "information"
    },
    "streams": [
        {
            "type": "high",
            "is_archive_enabled": true,
            "archive_storage_days": 30
        },
        {
            "type": "low",
            "is_archive_enabled": false
        }
    ]
}

The parameters

string name – the camera name


string mac – the MAC address of a camera


string serial_number – the camera serial number


string group_type – the camera group type


int group_id – the ID of the tree element in which to create the camera


string|int group_external_id – the key of the tree element in which to create the camera


int folder_id – the ID of the private folder where the camera should be placed


string|int folder_key – the key of the private folder in which the camera should be placed


bool is_user_owner – the flag that determines whether the camera belongs to the user


double latitude – the geographical latitude of the camera's location


double longitude – the geographical longitude of the camera's location


string service – the camera profile, used for applying templates


string external_id – the unique camera identifier that can be used for further access to this camera


array onvif_credentials – the credentials for accessing the camera via ONVIF


string|array log_extra– additional information received from an external system


array streams – archive settings array

object array

int streams.archive_storage_days – archive storage days (1‑90)


bool streams.is_archive_enabled – the flag to enable or disable the archive (true | false)


string streams.type – a stream type (high | low)

Note: When streams is sent, the camera is created with the specified archive settings, which are also stored under extra.billing.archive.{type}.





201  Created

A successful response

JSON
{
    "id": 26,
    "status": "empty",
    "name": "Camera 1",
    "is_archive_recording": true,
    "archive_storage_days": 5,
    "group_type": "private",
    "is_user_owner": false,
    "is_need_replace": false,
    "latitude": -28.776933731993793,
    "longitude": 76.65771489519997,
    "network_device": {
        "mac": "11:11:11:11:11:11",
        "serial_number": "12345678"
    },
    "folder": {
        "id": 3,
        "key": "123"
    }
}

422  Unprocessable Entity

Returns a JSON object with an error. For details, see General information/External system validation.

JSON
{
    "message": "No error message here",
    "errors": {
        "any_key": [
            "Error details"
        ]
    }
}
cURL
Bash
curl -k --request POST \
	--url 'https://your-domain/api/v2/billing/cameras' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--data '{
    "name": "string",
    "mac": "string",
    "serial_number": "string",
    "group_type": "string",
    "group_id": 0,
    "group_external_id": "string|int",
    "folder_id": 0,
    "folder_key": "string|int",
    "is_user_owner": true,
    "latitude": 0,
    "longitude": 0,
    "service": "string",
    "external_id": "string",
    "onvif_credentials": [],
    "log_extra": "string|array",
    "streams": 0
}'
PHP
PHP
$data = array (
  'name' => 'string',
  'mac' => 'string',
  'serial_number' => 'string',
  'group_type' => 'string',
  'group_id' => 0,
  'group_external_id' => 'string|int',
  'folder_id' => 0,
  'folder_key' => 'string|int',
  'is_user_owner' => true,
  'latitude' => 0.0,
  'longitude' => 0.0,
  'service' => 'string',
  'external_id' => 'string',
  'onvif_credentials' => 
  array (
  ),
  'log_extra' => 'string|array',
  'streams' => 0,
);
$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/v2/billing/cameras', false, $context);