# Export Saved Objects via REST APi

**URL:** <https://discuss.elastic.co/t/export-saved-objects-via-rest-api/72028>\
**Category:** Kibana\
**Created:** [January 18, 2017, 2:48pm UTC](https://discuss.elastic.co/t/export-saved-objects-via-rest-api/72028 "2017-01-18T14:48:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_McClain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_mcclain/32/8613_2.png) [@David\_McClain](https://discuss.elastic.co/u/David_McClain)\
**Post date:** [January 18, 2017, 2:48pm UTC](https://discuss.elastic.co/t/export-saved-objects-via-rest-api/72028/1 "2017-01-18T14:48:08Z")

</div>

Hi,

I'm trying to figure out the best way to programatically export all of the saved objects - Saved Searches, Visualizations, and Dashboard - as individual documents.

I want to be able to create an SDLC around the Dashboard development process and I need to be able to capture anything/everything that a final Dashboard is dependent on, and then store that into a repository for versioning.

So far, the only way I've been able to find (at least per the documentation) to export these items is through the Kibana gui. And even then, Doing an 'Export All' creates a single document that contains everything.

I would like to be able to call the REST API to get a listing of the Saved Objects. And then I would like to use that listing to export each one individually into its own file. Is this possible?

As a secondary question to this - how can I make it so that a newly created index, with no data, can successfully use any saved objects regardless of the fields they contain? This would be for when I know what fields my data will contain (Because we've built dashboards against the data), but I'm building out a new environment, and I don't want to wait for the data to come in and create those fields before I can import the Saved Objects that rely those fields?

_Edit: Moved to Kibana category_

Thanks

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [January 27, 2017, 6:17pm UTC](https://discuss.elastic.co/t/export-saved-objects-via-rest-api/72028/2 "2017-01-27T18:17:33Z")

</div>

Hi @David_McClain,

I have been in the same situation before and this is how I made it work:

- I accessed the Kibana index (`.kibana` by default) directly through the Elasticsearch API, because the internal Kibana import/export API is not documented and I wanted to be able to import the saved objects before Kibana starts.
- In order to store the state in version control, a custom script would...
  - dump the mappings of the Kibana index (`GET ${ES_HOST}/${KIBANA_INDEX}/_mapping`)
  - dump the kibana settings (`GET ${ES_HOST}/${KIBANA_INDEX}/config/${KIBANA_VERSION}/_source`)
  - list the dashboards, visualizations,searches and index-patterns: (`GET ${ES_HOST}/${KIBANA_INDEX}/dashboard,visualization,search,index-pattern/_search` + some json parsing)
  - dump the dashboards, visualizations, searches and index-patterns (`GET ${ES_HOST}/${KIBANA_INDEX}/${OBJECT_TYPE}/${OBJECT_ID}/_source`)

- When provisioning a new cluster and Kibana a script would...
  - load the mappings into the Kibana index (`PUT ${ES_HOST}/${KIBANA_INDEX}`)
  - load the settings and saved objects (`PUT ${ES_HOST}/${KIBANA_INDEX}/${OBJECT_TYPE}/${OBJECT_ID}`)

If you don't want to modify the settings or saved objects, an export tool like [elasticdump](https://github.com/taskrabbit/elasticsearch-dump) might be useful. To selectively export only specific saved objects and their dependencies custom code has to be written at the moment.

This setup would allow for provisioning of the Kibana settings and saved objects before Kibana has been started and before the environment has been populated with data.

---

<div class="post-metadata">

**Author:** ![David\_McClain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_mcclain/32/8613_2.png) [@David\_McClain](https://discuss.elastic.co/u/David_McClain)\
**Post date:** [January 27, 2017, 6:21pm UTC](https://discuss.elastic.co/t/export-saved-objects-via-rest-api/72028/3 "2017-01-27T18:21:14Z")

</div>

Awesome. Thanks for your reply.

Followup question:  
If I load a bunch of data into an index, and then build dashboards against that data - where it depends on certain fields to exist.

And then I export the mapping (I'm assuming the mapping is updated each time a new field is added), and import that into an empty Elasticsearch, that effectively brings all the fields and their definitions over to the new Elasticsearch, and I should be able to import all the saved objects and use the Dashboard, even though there is no data there right?

This would be an attempt to solve the problem of not being able to import a Dashboard until the field it requires exists.

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [January 27, 2017, 6:31pm UTC](https://discuss.elastic.co/t/export-saved-objects-via-rest-api/72028/4 "2017-01-27T18:31:37Z")

</div>

Kibana stores the information about the fields of each index pattern in documents of type `index-pattern` in the the `.kibana` index. There is no hard requirement of those fields actually existing in the corresponding Elasticsearch data indices (as long as you don't click "refresh field list" in Kibana's management section).

Just to avoid misunderstandings, the mapping I was talking about are the mappings of the `.kibana` index itself that define the schema of Kibana's saved objects. These mappings need to be imported into the new `.kibana` index before any saved object is imported, because Elasticsearch might otherwise automatically derive the wrong mappings.

_Edited for typos_

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 24, 2017, 6:32pm UTC](https://discuss.elastic.co/t/export-saved-objects-via-rest-api/72028/5 "2017-02-24T18:32:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
