Copy saved objects to space API
[experimental] This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. Copy saved objects between spaces.
It also allows you to automatically copy related objects, so when you copy a dashboard
, this can automatically copy over the associated visualizations, index patterns, and saved searches, as required.
You can request to overwrite any objects that already exist in the target space if they share an ID, or you can use the Resolve copy saved objects conflicts API to do this on a per-object basis.
Request
POST <kibana host>:<port>/api/spaces/_copy_saved_objects
POST <kibana host>:<port>/s/<space_id>/api/spaces/_copy_saved_objects
Path parameters
space_id
(Optional, string) The ID of the space that contains the saved objects you want to copy. When space_id
is unspecified in the URL, the default space is used.
Request body
spaces
(Required, string array) The IDs of the spaces where you want to copy the specified objects.
objects
(Required, object array) The saved objects to copy.
Properties of objects
type
(Required, string) The saved object type.
id
(Required, string) The saved object ID.
includeReferences
(Optional, boolean) When set to true
, all saved objects related to the specified saved objects will also be copied into the target spaces. The default value is false
.
overwrite
(Optional, boolean) When set to true
, all conflicts are automatically overidden. When a saved object with a matching type
and id
exists in the target space, that version is replaced with the version from the source space. The default value is false
.
Response body
<space_id>
(object) An object that describes the result of the copy operation for the space. Includes the dynamic keys in the response.
Properties of <space_id>
success
(boolean) The copy operation was successful. When set to
false
, some objects may have been copied. For additional information, refer to thesuccessCount
anderrors
properties.successCount
(number) The number of objects that successfully copied.
errors
(Optional, array) The errors that occurred during the copy operation. When errors are reported, the
success
flag is set tofalse
.Properties of
errors
id
(string) The saved object ID that failed to copy.
type
(string) The type of saved object that failed to copy.
error
(object) The error that caused the copy operation to fail.
Properties of
error
type
:(string) The type of error. For example,
unsupported_type
,missing_references
, orunknown
. Errors marked asconflict
may be resolved by using the Resolve copy saved objects conflicts API.
Examples
Copy a dashboard with the my-dashboard
ID, including all references from the default
space to the marketing
and sales
spaces:
$ curl -X POST api/spaces/_copy_saved_objects
{
"objects": [{
"type": "dashboard",
"id": "my-dashboard"
}],
"spaces": ["marketing", "sales"],
"includeReferences": true
}
The API returns the following:
{
"marketing": {
"success": true,
"successCount": 5
},
"sales": {
"success": false,
"successCount": 4,
"errors": [{
"id": "my-index-pattern",
"type": "index-pattern",
"error": {
"type": "conflict"
}
}]
}
}
The marketing
space succeeds, but the sales
space fails due to a conflict in the index pattern.
Copy a visualization with the my-viz
ID from the marketing
space to the default
space:
$ curl -X POST s/marketing/api/spaces/_copy_saved_objects
{
"objects": [{
"type": "visualization",
"id": "my-viz"
}],
"spaces": ["default"]
}
The API returns the following:
{
"default": {
"success": true,
"successCount": 1
}
}