Import objects API

edit

[preview] This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Create a set of Kibana saved objects from a file created by the export API.

Compatibility across versions

edit

Saved objects can only be imported into the same version, a newer minor on the same major, or the next major. Exported saved objects are not backwards compatible and cannot be imported into an older version of Kibana. See the table below for compatibility examples:

Exporting version

Importing version

Compatible?

6.7.0

6.8.1

Yes

6.8.1

7.3.0

Yes

7.3.0

7.11.1

Yes

7.11.1

7.6.0

No

6.8.1

8.0.0

No

Request

edit

POST /api/saved_objects/_import

POST /s/<space_id>/api/saved_objects/_import

Path parameters

edit
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

edit
overwrite
(Optional, boolean) Overwrites saved objects.

Request body

edit

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

file
A file exported using the export API.

Response body

edit
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

edit
200
Indicates a successful call.

Examples

edit

Import an index pattern and dashboard:

$ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form [email protected] 

The file.ndjson file contains the following:

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

The API returns the following:

{
  "success": true,
  "successCount": 2
}

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

$ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form [email protected]

The file.ndjson file contains the following:

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

The API returns the following:

{
  "success": false,
  "successCount": 1,
  "errors": [
    {
      "id": "my-pattern",
      "type": "index-pattern",
      "title": "my-pattern-*",
      "error": {
        "type": "conflict"
      },
    },
  ],
}

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

$ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form [email protected]

The file.ndjson file contains the following:

{"type":"visualization","id":"my-vis","attributes":{"title":"my-vis"},"references":[{"name":"ref_0","type":"index-pattern","id":"my-pattern-*"}]}
{"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:

  "success": false,
  "successCount": 0,
  "errors": [
    {
      "id": "my-vis",
      "type": "visualization",
      "title": "my-vis",
      "error": {
        "type": "missing_references",
        "references": [
          {
            "type": "index-pattern",
            "id": "my-pattern-*"
          }
        ],
        "blocking": [
          {
            "type": "dashboard",
            "id": "my-dashboard"
          }
        ]
      }
    }
  ]