26.09 26.06 26.05 25.12
26.09 26.06 26.05 25.12 Russian English

Update 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.

PATCH  /api/v2/billing/cameras

This method updates a camera in VMS through an external system. Identify the camera using one of these parameters:id, external_idormac. Parameters that aren't provided remain unchanged, except foronvif_credentialsfields: this object replaces all camera ONVIF settings.

Moving a camera to another tree element or private folder uses the same parameters as camera creation: VMS Billing / External system cameras / Create a camera by an external system

If the request contains thestreamsfield with a video stream type that hasn't been created yet, these settings are applied when that stream is created.

JSON
{
    "external_id": "bd0a951f-40a2-4edf-b213-bcd90ff5273d",
    "new_mac": "12:12:12:12:12:12",
    "serial_number": "111111111111",
    "service": "8MP",
    "profile": [
        1,
        0
    ],
    "name": "Camera 1",
    "group_type": "private",
    "group_id": 16,
    "folder_id": 3,
    "is_user_owner": false,
    "latitude": -28.776933731993793,
    "longitude": 76.65771489519997,
    "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": false,
    "is_enabled": true,
    "log_extra": {
        "some": "information"
    },
    "streams": [
        {
            "type": "high",
            "is_archive_enabled": false
        },
        {
            "type": "low",
            "is_archive_enabled": true,
            "archive_storage_days": 14
        }
    ]
}

Method parameters

int id  required , Camera ID in VMS (required if external_id and mac aren't specified; provide only one of the three)


string external_id  required , Current camera external_id (required if id and mac aren't specified)


string mac  required , Current camera MAC address, maximum 48 characters (required if id and external_id aren't specified)


string new_external_id, New camera external_id, maximum 50 characters. Must be unique among VMS cameras


string new_mac, New camera MAC address, for example when replacing a device, maximum 48 characters. 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, New camera serial number as shown on the device, maximum 100 characters. Must be unique among VMS cameras


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 name, Camera name, maximum 255 characters; an empty value isn't allowed. Displayed in the VMS interface


string group_type, 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 is removed from the private folder


int group_id, ID of the leaf tree element in VMS to which the camera is moved. Can't be provided together with group_external_id


string|int group_external_id, Key of the leaf tree element assigned by the external system when it was created, identifying the element to which the camera is moved. Can't be provided together with group_id


int folder_id, ID of the private folder in VMS where the camera is placed. The folder must be in the camera's tree element (the new element, if provided). Applies to a private camera or together with group_type = `private`. Can't be provided together with folder_key


string|int folder_key, Key assigned when the private folder was created. The same conditions apply as for folder_id. Can't be provided together with folder_id


bool is_user_owner, Flag indicating whether the camera belongs to a user


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


array onvif_credentials, Credentials for accessing the camera through ONVIF. Replace all camera ONVIF settings: omitted fields are reset, and network, network_scope, and nat_port receive their default values

object array

string onvif_credentials.ip, ONVIF device IP address, maximum 255 characters. When start_provisioning = `true`, required if the camera's network device has no IP address


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 (required when start_provisioning = `true`)


bool start_provisioning, Start ONVIF provisioning after updating the camera. Requires onvif_credentials.port and an IP address (from the request or the camera's network device); 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


bool is_enabled, Enable or disable camera video stream capture. When capture is disabled, the recorded archive remains available


array shared_groups_to_attach, Tree elements (and their folders) where camera sharing must be enabled

object array

int shared_groups_to_attach.folder_id, Folder ID in this tree element


int shared_groups_to_attach.group_id, Tree element ID in VMS. Required in each item


array shared_groups_to_detach, Tree elements (and their folders) where camera sharing must be disabled

object array

int shared_groups_to_detach.folder_id, Folder ID in this tree element


int shared_groups_to_detach.group_id, Tree element ID in VMS. Required in each item


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


200  OK

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 '{
    "id": 0,
    "external_id": "string",
    "mac": "string",
    "new_external_id": "string",
    "new_mac": "string",
    "serial_number": "string",
    "service": "string",
    "profile": [],
    "name": "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,
    "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,
    "is_enabled": true,
    "shared_groups_to_attach": {
        "group_id": 0,
        "folder_id": 0
    },
    "shared_groups_to_attach.group_id": "void",
    "shared_groups_to_attach.folder_id": "void",
    "shared_groups_to_detach": {
        "group_id": 0,
        "folder_id": 0
    },
    "shared_groups_to_detach.group_id": "void",
    "shared_groups_to_detach.folder_id": "void",
    "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 (
  'id' => 0,
  'external_id' => 'string',
  'mac' => 'string',
  'new_external_id' => 'string',
  'new_mac' => 'string',
  'serial_number' => 'string',
  'service' => 'string',
  'profile' => 
  array (
  ),
  'name' => '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,
  '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,
  'is_enabled' => true,
  'shared_groups_to_attach' => 
  array (
    'group_id' => 0,
    'folder_id' => 0,
  ),
  'shared_groups_to_attach.group_id' => 'void',
  'shared_groups_to_attach.folder_id' => 'void',
  'shared_groups_to_detach' => 
  array (
    'group_id' => 0,
    'folder_id' => 0,
  ),
  'shared_groups_to_detach.group_id' => 'void',
  'shared_groups_to_detach.folder_id' => 'void',
  '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' => 'PATCH',
		'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);