Copy saved objects to space API
editCopy saved objects to space API
editThe underlying Spaces concepts are stable, but the APIs for managing Spaces are experimental.
Description
editCopy 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.
Path parameters
edit-
space_id
-
(Optional, string) Identifies the source space from which saved objects will be copied. If
space_id
is not specified in the URL, the default space is used.
Request body
edit-
spaces
- (Required, string array) The ids of the spaces the specified object(s) will be copied into.
-
objects
-
(Required, object array) The saved objects to copy.
-
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 isfalse
. -
overwrite
-
(Optional, boolean) When set to
true
, all conflicts will be automatically overidden. If a saved object with a matchingtype
andid
exists in the target space, then that version will be replaced with the version from the source space. The default value isfalse
.
Response body
edit-
<space_id>
-
(object) Specifies the dynamic keys that are included in the response. An object describing the result of the copy operation for this particular space.
-
success
-
(boolean) Indicates if the copy operation was successful. Note that some objects may have been copied even if this is set to
false
. Consult thesuccessCount
anderrors
properties of the response for additional information. -
successCount
- (number) The number of objects that were successfully copied.
-
errors
-
(Optional, array) Collection of any errors that were encountered during the copy operation. If any errors are reported, then the
success
flag will be set tofalse
.-
id
- (string) The saved object id which failed to copy.
-
type
- (string) The type of saved object which failed to copy.
-
error
-
(object) The error which caused the copy operation to fail.
-
type
: -
(string) Indicates the type of error. May be one of:
conflict
,unsupported_type
,missing_references
,unknown
. Errors marked asconflict
may be resolved by using the Resolve copy saved objects conflicts API.
-
-
-
Examples
editThe following example attempts to copy a dashboard with id my-dashboard
, including all references from the default
space to the marketing
and sales
spaces. The marketing
space succeeds, while the sales
space fails due to a conflict on the underlying index pattern:
POST /api/spaces/_copy_saved_objects { "objects": [{ "type": "dashboard", "id": "my-dashboard" }], "spaces": ["marketing", "sales"], "includeReferences": true }
The API returns the following result:
{ "marketing": { "success": true, "successCount": 5 }, "sales": { "success": false, "successCount": 4, "errors": [{ "id": "my-index-pattern", "type": "index-pattern", "error": { "type": "conflict" } }] } }
The following example successfully copies a visualization with id my-viz
from the marketing
space to the default
space:
POST /s/marketing/api/spaces/_copy_saved_objects { "objects": [{ "type": "visualization", "id": "my-viz" }], "spaces": ["default"] }
The API returns the following result:
{ "default": { "success": true, "successCount": 1 } }