Breadcrumbs

Update a camera by an external system (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.

PATCH  /api/v2/billing/cameras

The camera is specified by mac or external_id.

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
{
    "external_id": "bd0a951f-40a2-4edf-b213-bcd90ff5273d",
    "mac": "12:12:12:12:12:11",
    "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,
    "group_external_id": 16,
    "folder_key": 123,
    "folder_id": 3,
    "is_user_owner": false,
    "latitude": -28.776933731993793,
    "longitude": 76.65771489519997,
    "onvif_credentials": {
        "login": "login",
        "password": "password",
        "port": 80
    },
    "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
        }
    ]
}

The parameters

string external_id – a current external_id of a camera.


string mac – a current MAC address of a camera (alternative is external_id).


string new_mac – a new MAC address of a camera.


string serial_number – a new serial number of a camera.


string service – a camera profile used to apply configuration templates.


array profile – additional camera details.


string name – a camera name.


string group_type – a camera group type.


int group_id – an ID of a tree element where the camera will be created.


string|int group_external_id – a key of the tree element where the camera will be created.


int folder_id, Id of the private folder where the camera should be placed


string|int folder_key –  a private folder ID where the camera will be placed.


bool is_user_owner – a flag that indicates if the camera is assigned to a user.


double latitude – denotes the latitude of the camera's location.


double longitude – denotes the longitude of the camera's location.


array onvif_credentials– credentials to access the camera via ONVIF.


bool is_enabled – a flag to enable or disable the archive.


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


array streams – archive streams settings

object array

int streams.archive_storage_days – Archive depth (1-90 days)


bool streams.is_archive_enabled – the flag to turn on/off archive (true | false)


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


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 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 PATCH \
	--url 'https://your-domain/api/v2/billing/cameras' \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	--data '{
    "external_id": "string",
    "mac": "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": [],
    "is_enabled": 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 (
  'external_id' => 'string',
  'mac' => '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 (
  ),
  'is_enabled' => 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' => '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);