Import objects 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. Create sets of Kibana saved objects from a file created by the export API.

Request

POST <kibana host>:<port>/api/saved_objects/_import

POST <kibana host>:<port>/s/<space_id>/api/saved_objects/_import

Path parameters

space_id

(Optional, string) An identifier for the space. If space_id is not provided in the URL, the default space is used.

Query parameters

overwrite

(Optional, boolean) Overwrites saved objects.

Request body

The request body must include the multipart/form-data type.

file

A file exported using the export API.

Response body

success

Top-level property that indicates if the import was successful.

successCount

Indicates the number of successfully imported records.

errors

(array) Indicates the import was unsuccessful and specifies the objects that failed to import.

Response code

200

Indicates a successful call.

Examples

Import an index pattern and dashboard:

  1. $ curl -X POST api/saved_objects/_import -H "kbn-xsrf: true" --form file=@file.ndjson

The file.ndjson file contains the following:

  1. {"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}}
  2. {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}}

The API returns the following:

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

Import an index pattern and dashboard that includes a conflict on the index pattern:

  1. $ curl -X POST api/saved_objects/_import -H "kbn-xsrf: true" --form file=@file.ndjson

The file.ndjson file contains the following:

  1. {"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"}}
  2. {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"}}

The API returns the following:

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

Import a visualization and dashboard with an index pattern for the visualization reference that doesn’t exist:

  1. $ curl -X POST api/saved_objects/_import -H "kbn-xsrf: true" --form file=@file.ndjson

The file.ndjson file contains the following:

  1. {"type":"visualization","id":"my-vis","attributes":{"title":"my-vis"},"references":[{"name":"ref_0","type":"index-pattern","id":"my-pattern-*"}]}
  2. {"type":"dashboard","id":"my-dashboard","attributes":{"title":"Look at my dashboard"},"references":[{"name":"ref_0","type":"visualization","id":"my-vis"}]}

The API returns the following:

  1. "success": false,
  2. "successCount": 0,
  3. "errors": [
  4. {
  5. "id": "my-vis",
  6. "type": "visualization",
  7. "title": "my-vis",
  8. "error": {
  9. "type": "missing_references",
  10. "references": [
  11. {
  12. "type": "index-pattern",
  13. "id": "my-pattern-*"
  14. }
  15. ],
  16. "blocking": [
  17. {
  18. "type": "dashboard",
  19. "id": "my-dashboard"
  20. }
  21. ]
  22. }
  23. }
  24. ]

Most Popular