26.09 26.06 26.05 25.12
26.09 26.06 26.05 25.12 Russian English

Create camera by external system (v2)

With the release of the new request version v2, version v1 is moved to legacy.
For new integrations, use the current version v2.
Version v1 remains available to support existing integrations.

POST  /api/v2/billing/cameras

This method creates a camera in VMS through an external system.

A camera is created in a leaf tree element – an element without children. Cameras can be assigned only to such elements. Specify the element bygroup_id– its ID in VMS, or bygroup_external_id– the key assigned by the external system when the element was created. VMS Billing / Tree / Create a tree element

To restrict camera access to specific users within a single tree element, passgroup_type = privateand place the camera in a private folder: specify eitherfolder_id– the folder ID in VMS, orfolder_key– the key assigned when the folder was created. The folder must be in the same tree element where the camera is created.VMS Billing / Tree / Folders / Create a private folder. A public camera (group_type = public) isn't placed in a folder.

If the request contains thestreamsfield, archive settings for the specified stream types are saved and applied later when the video streams are created.

JSON
{
    "name": "Camera 1",
    "mac": "AA:BB:CC:DD:EE:FF",
    "serial_number": "12345678",
    "group_type": "private",
    "group_id": 16,
    "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,
        "ip": "192.168.1.100",
        "network": "direct",
        "network_scope": "local",
        "nat_port": 8080
    },
    "start_provisioning": true,
    "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
        }
    ]
}

Method parameters

string name  required , Camera name, maximum 255 characters. Displayed in the VMS interface; specified by the external system


string mac, Camera MAC address, maximum 48 characters (for example, `AA:BB:CC:DD:EE:FF`). Found in the camera specifications or network equipment settings. Must be unique among VMS cameras; `00:00:00:00:00:00` and `11:11:11:11:11:11` aren't allowed


string serial_number, Camera serial number as shown on the device, maximum 100 characters. Must be unique among VMS cameras. Omit this parameter if the serial number is unknown


int intercom_id, ID of the intercom for which the camera is created. The intercom must not already have a camera; the camera counts toward the intercom camera license limit


string group_type  required , Camera group type: `private` – the camera is available to a limited set of users, with access controlled by a private folder (folder_id or folder_key is required); `public` – the camera is available to all users of the tree element, and folder_id and folder_key must not be provided


int group_id  required , ID of the leaf tree element in VMS where the camera is created (required if group_external_id isn't specified; can't be provided together with it). The ID is returned when the tree element is created and in the response fromVMS Billing / Tree / Get the platform tree.


string|int group_external_id  required , Key of the leaf tree element assigned by the external system when it was created (required if group_id isn't specified). Allows referring to the element without its VMS ID


int folder_id  required , ID of the private folder in VMS where the camera is placed (when group_type = `private`, required if folder_key isn't specified; can't be provided together with it). The ID is returned when the private folder is created


string|int folder_key  required , Key assigned when the private folder was created (when group_type = `private`, required if folder_id isn't specified)


bool is_user_owner, Flag indicating whether the camera belongs to a user. Default: `false`


double latitude, Latitude of the camera installation location, from -90 to 90. Provided together with longitude; used to display the camera on the map


double longitude, Longitude of the camera installation location, from -180 to 180. Provided together with latitude


string service, Camera profile used to apply configuration templates (video quality settings). Allowed values: `1.3MP`, `2MP`, `3MP`, `4MP`, `6MP`, `8MP`, `Any`


array profile, Additional camera profile data (for example, resolution and frame rate) in any format. VMS stores the data unchanged


string external_id, Camera identifier in the external system, used to refer to the camera in other methods. Must be unique among VMS cameras


bool is_sound_enabled, Enable camera audio. Default: `false`


array onvif_credentials, Credentials for accessing the camera through ONVIF. Omit this parameter if the camera doesn't support ONVIF

object array

string onvif_credentials.ip, ONVIF device IP address, maximum 255 characters (required when start_provisioning = `true`)


string onvif_credentials.login, ONVIF login, maximum 255 characters. Required if onvif_credentials.password is specified


int onvif_credentials.nat_port, ONVIF NAT port, from 1 to 65535; default: 554


string onvif_credentials.network, ONVIF connection mode: `direct` (default) or `proxy`


string onvif_credentials.network_scope, ONVIF network scope: `local` (default), `intranet`, or `internet`


string onvif_credentials.password, ONVIF password, maximum 255 characters, without spaces, Cyrillic characters, or the characters `: / ? # [ ] @ ! $ & ' ( ) * + , ; =`. Required if onvif_credentials.login is specified


int onvif_credentials.port, ONVIF port, from 1 to 65535; default: 80 (required when start_provisioning = `true`)


bool start_provisioning, Start ONVIF provisioning after creating the camera. Requires onvif_credentials.ip and onvif_credentials.port; returns 422 if they're missing


bool is_can_manage_archive_storage_days, Whether the camera archive retention period can be changed in VMS. If `false`, only the external system sets the retention period. Default: `true`


string|array log_extra, Additional information from the external system: a string or array


array streams, Archive settings by stream type

object array

int streams.archive_storage_days, Archive retention period in days, from 1 to 360 (required if is_archive_enabled = `true`)


bool streams.is_archive_enabled, Enable or disable archive recording for the stream


string streams.type, Stream type: `high` or `low`. Required in each item


201  Created

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 error object.

For more information, seeGeneral 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/v2/billing/cameras' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--data '{
    "name": "string",
    "mac": "string",
    "serial_number": "string",
    "intercom_id": 0,
    "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",
    "profile": [],
    "external_id": "string",
    "is_sound_enabled": true,
    "onvif_credentials": {
        "login": "string",
        "password": "string",
        "port": 0,
        "ip": "string",
        "network": "string",
        "network_scope": "string",
        "nat_port": 0
    },
    "onvif_credentials.login": "void",
    "onvif_credentials.password": "void",
    "onvif_credentials.port": "void",
    "onvif_credentials.ip": "void",
    "onvif_credentials.network": "void",
    "onvif_credentials.network_scope": "void",
    "onvif_credentials.nat_port": "void",
    "start_provisioning": true,
    "is_can_manage_archive_storage_days": true,
    "log_extra": "string|array",
    "streams": {
        "type": "string",
        "is_archive_enabled": true,
        "archive_storage_days": 0
    },
    "streams.type": "void",
    "streams.is_archive_enabled": "void",
    "streams.archive_storage_days": "void"
}'
PHP
PHP
$data = array (
  'name' => 'string',
  'mac' => 'string',
  'serial_number' => 'string',
  'intercom_id' => 0,
  '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',
  'profile' => 
  array (
  ),
  'external_id' => 'string',
  'is_sound_enabled' => true,
  'onvif_credentials' => 
  array (
    'login' => 'string',
    'password' => 'string',
    'port' => 0,
    'ip' => 'string',
    'network' => 'string',
    'network_scope' => 'string',
    'nat_port' => 0,
  ),
  'onvif_credentials.login' => 'void',
  'onvif_credentials.password' => 'void',
  'onvif_credentials.port' => 'void',
  'onvif_credentials.ip' => 'void',
  'onvif_credentials.network' => 'void',
  'onvif_credentials.network_scope' => 'void',
  'onvif_credentials.nat_port' => 'void',
  'start_provisioning' => true,
  'is_can_manage_archive_storage_days' => true,
  'log_extra' => 'string|array',
  'streams' => 
  array (
    'type' => 'string',
    'is_archive_enabled' => true,
    'archive_storage_days' => 0,
  ),
  'streams.type' => 'void',
  'streams.is_archive_enabled' => 'void',
  'streams.archive_storage_days' => 'void',
);
$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);