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 the successCount and errors 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 to false.

    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, or unknown. Errors marked as conflict 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:

  1. $ curl -X POST api/spaces/_copy_saved_objects
  2. {
  3. "objects": [{
  4. "type": "dashboard",
  5. "id": "my-dashboard"
  6. }],
  7. "spaces": ["marketing", "sales"],
  8. "includeReferences": true
  9. }

The API returns the following:

  1. {
  2. "marketing": {
  3. "success": true,
  4. "successCount": 5
  5. },
  6. "sales": {
  7. "success": false,
  8. "successCount": 4,
  9. "errors": [{
  10. "id": "my-index-pattern",
  11. "type": "index-pattern",
  12. "error": {
  13. "type": "conflict"
  14. }
  15. }]
  16. }
  17. }

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:

  1. $ curl -X POST s/marketing/api/spaces/_copy_saved_objects
  2. {
  3. "objects": [{
  4. "type": "visualization",
  5. "id": "my-viz"
  6. }],
  7. "spaces": ["default"]
  8. }

The API returns the following:

  1. {
  2. "default": {
  3. "success": true,
  4. "successCount": 1
  5. }
  6. }

Most Popular