REST API v4: POST view copy

This method is used to copy a view with the REST API. It uses an HTTP POST request to the following address:

https://api.copernica.com/v4/view/$id/copy

The $id in the URL should be replaced by the view you want to copy. After a successful call the ID of copy is returned. Please note that it may take a while for the copy to be completed.

Available parameters

This method can only be used to create a new view and takes the following parameters:

  • name: Name for the new view (required)
  • options: Array with options for copying (optional)

The options array can contain the following option:

  • views: Boolean that indicates whether the underlying views should be included in the copy.

JSON example

The following JSON demonstrates how to use the API method:

{
    "name": "View_copy",
    "options": {
        "views": true
    }
}

PHP example

The following PHP script demonstrates how to use the API method:

// dependencies
require_once('copernica-rest-api.php');

// change this into your access token
$api = new CopernicaRestAPI("your-access-token", 4);

// set the options for copying
$options = array(
    'views'         =>  true
);

// copy data
$data = array(
    'name'      =>  'View (copy)',
    'options'   =>  $options
);

// copy the database
print_r($copyID = $api->post("view/{$viewID}/copy", $data));

// return id of created request if successful

The example above requires the CopernicaRestApi class.

More information